I like having build numbers, just because it is cool. Please don't judge me :D.
However, I develop on two machines (one OS X and one Windows for portability checks). I have on both machines a script that automatically increases the build number every time I build the project. However, when doing changes on both machines without synchronising with git, this obviously gives a merge conflict, because the file holding the build number changed on both machines.
Is there a neat way to automatically merge these files? I would be cool if I could define a rule like:
If file
buildnumber.txt
has a merge conflict, run scriptauto-merge-build-number.sh
and continue commit.
Where auto-merge-build-number.sh
would be a simple script that parses the conflicted file and adds up the two numbers (found on the conflicting lines) and rewrites the file with that sum. I don't know if this is possible in git or not.
There is another way I can think of myself, but is less neat, imho: Keep track of a build counter file on every machine that is used only for that machine. If the project is build on that machine, the build counter file for that machine is increased. Afterwards, all files holding build numbers are added up together and the result is written to a file that is in the .gitignore
. This way, there would be no merge conflicts by developing on multiple machines. Only merge conflicts by developing on multiple branches. I don't really like this approach because you need n+1 files to keep track of the total build number (when having n machines) and the script on every machine needs to be slightly different, to make it increase the right file.
Any thoughts on how this could be done?