You can use git hooks for that.
The pre-commit
hook specifically. You can create one from the sample in .git/hooks/pre-commit.sample
by removing the .sample
suffix and editing it. The content of pre-commit
will be executed just before the commit.
It could contain something like this
#!/bin/sh
command-that-increases-version version.text
git add version.text
Any modification of version.text
will then be included in the commit.
Finally some advice: you may want to avoid doing this altogether, since it may lead to a lot of merge conflicts when different branches store different values in version.text
.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…