tags:

views:

106

answers:

2

I'm writing a git-install.sh script: http://gist.github.com/419201

To get Git's latest stable release version number, I do:

LSR_NUM=$(curl -silent http://git-scm.com/ | sed -n '/id="ver"/ s/.*v\([0-9].*\)<.*/\1/p')

2 Questions:

  1. Refactor my code: Is there a better way programmatically to do this?

  2. This works now, but it's brittle: if the web page at http://git-scm.com/ changes, the line above may stop working.

    PHP has a reliable URL for getting the latest release version: http://stackoverflow.com/questions/288206/is-there-a-site-which-simply-outputs-the-latest-stable-version-numbers-of-php-and

    Is there something like this for Git? This comes close: http://www.kernel.org/pub/software/scm/git/

A: 

I generally just use the maint branch. It only gets commits that have been rigorously tested in other branches like pu or next. It is generally very stable and at any given time is actually likely to contain less bugs than the latest official release.

Jörg W Mittag
+3  A: 

I'd just do this:

git ls-remote --tags git://git.kernel.org/pub/scm/git/git.git | ...

The location of the public repository is pretty much guaranteed to stay fixed, so I wouldn't really consider it brittle. The output of git-ls-remote will pretty definitely not change either.

The version number should be the last tag; you could grab it with something like this:

git ls-remote ... | tail -n 1 | sed 's@.*refs/tags/\(.*\)\^{}@\1@'
Jefromi
MattDiPasquale
@MattDiPasquale: Oh, duh. Well... yeah, I guess take your pick of the many many places that display the information, like the gitweb pages Dennis suggested. Those are pretty solidly tied to the locations of the repositories, and I doubt gitweb will ever stop showing tags.
Jefromi