2

We currently store our version number in a file in git. Due to our crazy process, when in stabilisation phase - i.e. code freeze - every commit to the remote repository needs to update the version number in the file.

Our remote repository is hosted on Stash.

How can we enforce that every commit has modified this file as part of the commit, and ensure that no one accidentally forgets to update the file? If we have a pre-commit hook, then it requires every developer to be running the same environment (windows/linux) and it requires every developer to manually install the pre-commit hook (I think). Should it be enforced as a pre-push hook in git? What's the best way?

dan
  • 1,525
  • 1
  • 17
  • 35
  • Isn't that something similar to what you want to achieve? http://stackoverflow.com/questions/16524225/how-can-i-populate-the-git-commit-id-into-a-file-when-i-commit – Wookie88 Jul 09 '14 at 14:06
  • @Wookie88 I don't think so, I don't need to update any files or worry about hashes. I just want to check that a file has been changed before it is merged into the remote repo – dan Jul 09 '14 at 14:25
  • I mean you could make git automatically paste the version number into this file you want. Or maybe some shell script to do that automatically before commit... maybe just simple git commit wrapper? Leaving that to human is tiresome and unreliable ;). – Wookie88 Jul 09 '14 at 14:52
  • can't avoid saying git really sucks at facilitating this kind of scenario, or most scenarios where human-readable incremental versioning is required. What you could do, is have a CI server take the latest hash and manufacture a new version number from it... which would be managed outside of git. – matanster Nov 07 '14 at 07:34

0 Answers0