threads / discuss / 13122

[new tool] git-project-version.sh

Subject: [new tool] git-project-version.sh

## tl;dr

8 messages between Apr 15, 2008 and Apr 15, 2008.

replies: 7people: 5as markdown or json

Nico -telmich- Schottelius· Apr 15, 2008, 11:36 UTC · lore
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.
-- 
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
Björn Steinbrink· Apr 15, 2008, 11:55 UTC · re: Nico -telmich- Schottelius · lore

Re: [new tool] git-project-version.sh

On 2008.04.15 13:36:29 +0200, Nico -telmich- Schottelius wrote:
Show 12 quoted lines
> 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/

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
Nico -telmich- Schottelius· Apr 15, 2008, 12:02 UTC · re: Björn Steinbrink · lore

Re: [new tool] git-project-version.sh

Björn Steinbrink [Tue, Apr 15, 2008 at 01:55:29PM +0200]:
Show 11 quoted 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
-- 
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
Santi Béjar· Apr 15, 2008, 12:01 UTC · re: Nico -telmich- Schottelius · lore

Re: [new tool] git-project-version.sh

On Tue, Apr 15, 2008 at 1:36 PM, Nico -telmich- Schottelius <nico-git-20080415@schottelius.org> wrote:

Show 6 quoted lines
> 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
Luciano Rocha· Apr 15, 2008, 12:05 UTC · re: Nico -telmich- Schottelius · lore

Re: [new tool] git-project-version.sh

On Tue, Apr 15, 2008 at 01:36:29PM +0200, Nico -telmich- Schottelius wrote:
Show 9 quoted lines
> 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?

>    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.
-- 
Luciano Rocha <luciano@eurotux.com>
Eurotux Informática, S.A. <http://www.eurotux.com/>
Nico Schottelius· Apr 15, 2008, 12:52 UTC · re: Luciano Rocha · lore

Re: [new tool] git-project-version.sh

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

> [...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
-- 
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
Elijah Newren· Apr 15, 2008, 12:55 UTC · re: Nico Schottelius · lore

Re: [new tool] git-project-version.sh

On Tue, Apr 15, 2008 at 6:52 AM, Nico Schottelius <nico-git-20080415@schottelius.org> wrote:

Show 9 quoted lines
> Santi Béjar [Tue, Apr 15, 2008 at 02:01:06PM +0200]:
>  Luciano Rocha [Tue, Apr 15, 2008 at 01:05:07PM +0100]:
>  > [...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
Nico Schottelius· Apr 15, 2008, 13:09 UTC · re: Elijah Newren · lore

Re: [new tool] git-project-version.sh

Elijah Newren [Tue, Apr 15, 2008 at 06:55:18AM -0600]:
> [...Is your 1.20.3pre6 tag annotated?...]
Got me, it is not!
Also added your hint, thank you!
Nico
-- 
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

← back to recent threads