Le 01/08/13 13:33, info(a)gno.de a écrit :
Hi folks,
unfortunately the git Id numer is not a sequential release number as
in svn but a hash. I find it a good idea to have a release number in
the code as it was before git migration. A git statement generates
it:
git rev-list HEAD | wc -l
which is the revision number. A better idea would be the gerrit
number which gives us the last and actual change for that code. It is
posible to merge such a number to the __version__ header of the
script instead or in addition to the hash?
In git, you can mark a commit with an arbitrary text such as a
sequential version numbering. You could use the usual v1.0.0 or
something like 2013Q2 for quaterly releases.
Once you have created such tags, you can easily describe the ongoing
version using `git describe` which lookup the most recent tags
reacheable, adds the number of commit and the current sha1.
Example:
# lets create an example repository
$ git init foo; cd foo
Initialized empty Git repository in /tmp/foo/.git/
# generate 5 commits
$ for i in 1 2 3 4 5; do git commit -m $i --allow-empty; done;
[master (root-commit) f162d3d] 1
[master d2b4825] 2
[master 54ac942] 3
[master 38e4f38] 4
[master c97d909] 5
$
Here is the log:
$ git log --oneline
c97d909 5
38e4f38 4
54ac942 3
d2b4825 2
f162d3d 1
$
Lets tag the two first commits (1 and 2) has respectively version v1.0
and v1.1:
$ git tag v1.0 f162d3d
$ git tag v1.1 d2b4825
The log becomes:
$ git log --oneline --decorate
c97d909 (HEAD, master) 5
38e4f38 4
54ac942 3
d2b4825 (tag: v1.1) 2
f162d3d (tag: v1.0) 1
$
When you checkout v1.1, git describe yields 'v1.0':
$ git checkout v1.0
...
$ git describe --tags
v1.0
$
If I checkout the latest commit (text is '5'):
$ git checkout c97d909
v1.1-3-gc97d909
$
Which shows that I am ahead of the tag 'v1.1' by '3' commits and the
corresponding git commit is c97d909.
cheers,
--
Antoine "hashar" Musso