Reputation: 4484
How do I write a script which will create a source file containing the version number? I would like the build number (4th number in the version quadruple) to be autoincremented for each commit.
I found some examples on how to use bash commands to do it:
INCREMENT=`git-rev-list $BRANCH..HEAD | wc -l | awk '{print $1}'`
but I am using Windows and I don't have a clue how to run that as a script (or a Windows batch file).
I used to work with SVN, and it worked nicely from the command prompt, so I just used it in a batch file, but I don't know how to execute git-rev-list
without starting git bash
.
Upvotes: 1
Views: 2402
Reputation: 20406
AssemblyInfomationalVersionAttribute
may hold any string, including the hash or shorthash or output of git describe
Upvotes: 2
Reputation: 28981
As the git is distributed VCS it is impossible to keep global incremented number, there is no place for it. So, the right thing to do is to use the <commit sha1>
(or its fragment) as a build number. You could use git describe
to generate nice version names automatically, including an incremented number.
Another good option is to have a build server (e.g. Jenkins or similar) which has built-in version numbering.
If you want use the hackish approach, you could use git installation, e.g. msysgit, it has all commands such as ws
or awk
. Not sure then why your doesn't work, maybe you don't have Git\bin
folder in your PATH.
Upvotes: 3