1

There is a git repository and some property files in it like that:

//application.properties
bKey=12345
aKey=myValue

After git push executed a remote git server should sort these files like that:

//application.properties
aKey=myValue
bKey=12345

How write hook for that?

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
Cherry
  • 31,309
  • 66
  • 224
  • 364

2 Answers2

0

Create a new custom alias in bashrc which would perform both git push and trigger your bash script (which will sort your properties file).

It's not exactly a hook but your problem can be solved by this way.

Edit: you can use pre-commit hook: https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks

RAQ
  • 119
  • 8
0

On the server side, a hook wxould not modify files.
But if your remote repo does checkout those files into a working tree (through a post-receive hook for instance, then you can associate to your remote git a content filter driver that would make that kind of transformation.

This assume you have access to the remote Git hosting server (meaning it is not GitHub.com or BitBucket.org or GitLab.com)

If that is the case, through a .gitattributes declaration, you can declare a smudge script which would, for any application.properties file, make a sort of its content.

smudge on checkout

That would be done automatically on checkout.

Community
  • 1
  • 1
VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250