You are not logged in.

#1 2015-10-20 16:50:08

Salamandar
Member
Registered: 2015-09-02
Posts: 15

My pkgver function. Is it good ?

Hi there !
Well, i spent some time creating my pkgver function for git repos.
The main point is that, when a tag is present, the hash value should NOT be the tag one but the LAST COMMIT one smile Well that's my point of view.
That's not the case for the examples in the wiki.

pkgver() {
    cd "$srcdir/$_gitname"
    printf "%s.%s" "$( set -o pipefail
        git describe --long --tags 2>/dev/null \
            | sed 's/\([^-]*-g\)/r\1/;s/-/./g' \
            | sed -r 's/.([0-9,a-g,A-G]{7}.*)//' ||
        printf "r%s" "$(git rev-list --count HEAD)"
    )" "$(git rev-parse --short HEAD)"
}

What do you think about this ?

Thanks wink
Salamandar

Offline

#2 2015-10-20 17:52:15

Alad
Wiki Admin/IRC Op
From: Bagelstan
Registered: 2014-05-04
Posts: 2,412
Website

Re: My pkgver function. Is it good ?

Personally, I'm a proponent of simple pkgver functions shaped to the git repo in question, rather than .. things like this. But whatever works I suppose...


Mods are just community members who have the occasionally necessary option to move threads around and edit posts. -- Trilby

Offline

#3 2015-10-20 18:05:33

Salamandar
Member
Registered: 2015-09-02
Posts: 15

Re: My pkgver function. Is it good ?

Well I understand what you mean ^^
But the whole "sed" thing is just here to make versions pretty and useable.

Offline

#4 2015-10-20 18:33:21

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,565

Re: My pkgver function. Is it good ?

Salamandar wrote:

The main point is that, when a tag is present, the hash value should NOT be the tag one but the LAST COMMIT one smile Well that's my point of view.
That's not the case for the examples in the wiki.

Are you certain of that? Completely certain?

Online

#5 2015-10-20 18:42:02

Salamandar
Member
Registered: 2015-09-02
Posts: 15

Re: My pkgver function. Is it good ?

Yup, absolutely. If I use the last example (I added the missing "--tags") :

$ cd fretwork 
$ pkgver() {
  cd "$srcdir$pkgname"
  ( set -o pipefail
    git describe --tags --long 2>/dev/null | sed 's/\([^-]*-g\)/r\1/;s/-/./g' ||
    printf "r%s.%s" "$(git rev-list --count HEAD)" "$(git rev-parse --short HEAD)"
  )
}
$ pkgver 
0.1.1.r2.g7d1bb80
$ git tag | xargs git tag -d # Delete all the tags from the git repo
Étiquette '0.1.1' supprimée (elle était sur f7ea800)
$ pkgver # This will give the last commit on master
r12.7d1bb80

So you can see the last string is not the same…

EDIT :
Hum, well, I can see where i missread. I did not see there was a "g" before the commit hash in "0.1.1.r2.g7d1bb80". So I just assumed it was a different hash value ^^''
What does this "g" mean ?

Last edited by Salamandar (2015-10-20 18:48:38)

Offline

#6 2015-10-20 18:45:42

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,565

Re: My pkgver function. Is it good ?

The "g" is just git describe's identifier that it's the hash. It's not part of the hash itself.

Online

#7 2015-10-20 18:55:42

Salamandar
Member
Registered: 2015-09-02
Posts: 15

Re: My pkgver function. Is it good ?

Yeah. But I don't understand why there is a "g" with git describe but not with git rev-parse.
Anyways… So my "hack" is useless ^^''

Offline

Board footer

Powered by FluxBB