Skip to contentSkip to conversation

git-project-version.sh

new tool Nico -telmich- Schottelius 5 participants 8 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

Hello!

As I want to use the latest commit id in all my projects, so I know which commit the version is based on, I wrote an extremly simple script that is based on git-show to display only the version named git-project-version.sh.

You can find it in
http://unix.schottelius.org/git/git-tools.git/.git/
http://unix.schottelius.org/cgi-bin/gitweb.cgi?p=git-tools.git/.git;a=summary
and more information is available on
http://nico.schottelius.org/notizbuch-blog/archive/2008/04/15/git-project-version-sh-written-versions-with-git/

Sincerly

Nico

ps: please cc on reply, I am not subscribed.

Signature · 4 lines
Think about Free and Open Source Software (FOSS).
http://nico.schottelius.org/documentations/foss/the-term-foss/

PGP: BFE4 C736 ABE5 406F 8F42  F7CF B8BE F92A 9885 188C
#1 lore raw
Quoted 7 lines · Nico -telmich- Schottelius

Hello!

As I want to use the latest commit id in all my projects, so I know which commit the version is based on, I wrote an extremly simple script that is based on git-show to display only the version named git-project-version.sh.

Quoted 5 lines

You can find it in
http://unix.schottelius.org/git/git-tools.git/.git/
http://unix.schottelius.org/cgi-bin/gitweb.cgi?p=git-tools.git/.git;a=summary
and more information is available on
http://nico.schottelius.org/notizbuch-blog/archive/2008/04/15/git-project-version-sh-written-versions-with-git/

Hm, except for the three trailing dots that you get with --abbrev-commit, you can get the same results with rev-parse

$ git rev-parse  HEAD
8a18e8fe4e0e64222de6b063a976d0fe24955ddb
$ git rev-parse --short HEAD
8a18e8f

Björn

#2 lore raw

Björn Steinbrink [Tue, Apr 15, 2008 at 01:55:29PM +0200]:

Quoted 11 lines
Quoted 2 lines

[...git-project-version.sh...]

Hm, except for the three trailing dots that you get with --abbrev-commit, you can get the same results with rev-parse

$ git rev-parse  HEAD
8a18e8fe4e0e64222de6b063a976d0fe24955ddb
$ git rev-parse --short HEAD
8a18e8f

Should have known that before... thank you for the hint!

So just forget my previous post :-)

Nico

Signature · 4 lines
Think about Free and Open Source Software (FOSS).
http://nico.schottelius.org/documentations/foss/the-term-foss/

PGP: BFE4 C736 ABE5 406F 8F42  F7CF B8BE F92A 9885 188C
#3 lore raw
In reply to Nico -telmich- Schottelius
Quoted 9 lines · Nico -telmich- Schottelius

Hello!

As I want to use the latest commit id in all my projects, so I know which commit the version is based on, I wrote an extremly simple script that is based on git-show to display only the version named git-project-version.sh.

You can find it in
http://unix.schottelius.org/git/git-tools.git/.git/

I couldn't clone:
Cannot get remote repository information. Perhaps git-update-server-info needs to be run there?

Quoted 3 lines

http://unix.schottelius.org/cgi-bin/gitweb.cgi?p=git-tools.git/.git;a=summary
and more information is available on
http://nico.schottelius.org/notizbuch-blog/archive/2008/04/15/git-project-version-sh-written-versions-with-git/

I use "git describe" for this, it's more user-friendly.

Signature · 2 lines
Luciano Rocha <[email protected]>
Eurotux Informática, S.A. <http://www.eurotux.com/>
#4 lore raw

Santi Béjar [Tue, Apr 15, 2008 at 02:01:06PM +0200]:
Luciano Rocha [Tue, Apr 15, 2008 at 01:05:07PM +0100]:

Quoted 1 line

[...git describe...]

Looks also quite nice, also added it to the blog entry, but it seems to work wrong here:

The last tag I created on the master branch is called 1.20.3pre6, but git-describe uses pre5:

[14:39] denkbrett:gpm% git-describe
1.20.3pre5-17-gfccc331
[14:43] denkbrett:gpm% git tag
1.20.3pre1
1.20.3pre2
1.20.3pre3
1.20.3pre4
1.20.3pre5
1.20.3pre6
1.99.0
1.99.1
1.99.2
1.99.2.1
1.99.2.2
1.99.3
1.99.4
1.99.5
[14:44] denkbrett:gpm% git branch
gpm-1-stable
gpm-2-dev
* master
[14:51] denkbrett:gpm% git --version
git version 1.5.4.4

Nico

Signature · 4 lines
Think about Free and Open Source Software (FOSS).
http://nico.schottelius.org/documentations/foss/the-term-foss/

PGP: BFE4 C736 ABE5 406F 8F42  F7CF B8BE F92A 9885 188C
#5 lore raw
Quoted 9 lines · Nico Schottelius

Santi Béjar [Tue, Apr 15, 2008 at 02:01:06PM +0200]:
Luciano Rocha [Tue, Apr 15, 2008 at 01:05:07PM +0100]:

Quoted 1 line

[...git describe...]

Looks also quite nice, also added it to the blog entry, but it seems to work wrong here:

The last tag I created on the master branch is called 1.20.3pre6, but git-describe uses pre5:

Is your 1.20.3pre6 tag annotated? git-describe only uses annotated tags by default; pass the --tags option to have it consider all tags. (This caught me be surprise a few times as well.)

Elijah

#6 lore raw

Elijah Newren [Tue, Apr 15, 2008 at 06:55:18AM -0600]:

Quoted 1 line

[...Is your 1.20.3pre6 tag annotated?...]

Got me, it is not!

Also added your hint, thank you!

Nico

Signature · 4 lines
Think about Free and Open Source Software (FOSS).
http://nico.schottelius.org/documentations/foss/the-term-foss/

PGP: BFE4 C736 ABE5 406F 8F42  F7CF B8BE F92A 9885 188C
#7 lore raw
In reply to Nico -telmich- Schottelius
Quoted 6 lines · Nico -telmich- Schottelius

Hello!

As I want to use the latest commit id in all my projects, so I know which commit the version is based on, I wrote an extremly simple script that is based on git-show to display only the version named git-project-version.sh.

an equivalent simpler version is:

git rev-parse [--short] HEAD

Also "git show" is a porcelain command, that means it is for humans, not for scripts. The output of "git show" can change while the output of "git rev-parse" (and the plumbing) is stable.

But maybe what you really want is:

git describe [--always]

Santi