From f0d8f105004137c9b05a8e2d9f807ae859fecbe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Herv=C3=A9=20Cauwelier?= Date: Sun, 16 Aug 2009 00:36:12 +0200 Subject: [PATCH] makepkg: get pkgver of a git checkout from the last commit This fixes issue FS#15895 "PKGBUILD git feature is systematically setting pkgver to today date, not date of the last commit" Remains to take the timezone into account, but this is not really an issue. --- doc/PKGBUILD.5.txt | 5 ++++- scripts/makepkg.sh.in | 14 +++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/doc/PKGBUILD.5.txt b/doc/PKGBUILD.5.txt index e6f6edf..ce97ea8 100644 --- a/doc/PKGBUILD.5.txt +++ b/doc/PKGBUILD.5.txt @@ -357,7 +357,10 @@ from. The URL (all protocols supported) to the GIT repository. *_gitname*;; - GIT tag or branch to use. + The name of the local repository. + + *_gitbranch*;; + GIT tag or branch to use (defaults to "master"). *Mercurial*:: The generated pkgver will be the hg tip revision number. diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in index ac6db80..21129f1 100644 --- a/scripts/makepkg.sh.in +++ b/scripts/makepkg.sh.in @@ -1252,7 +1252,19 @@ devel_check() { elif [ -n "${_gitroot}" -a -n "${_gitname}" ] ; then [ $(type -p git) ] || return 0 msg "$(gettext "Determining latest git revision...")" - newpkgver=$(date +%Y%m%d) + if [ -d ./src/$_gitname ] ; then + cd ./src/$_gitname + git pull + else + [[ ! -d ./src/ ]] && mkdir ./src/ + git clone $_gitroot ./src/$_gitname + cd ./src/$_gitname + fi + author=$(git cat-file commit ${_gitbranch:-master}|grep author) + # Trim TZ, date doesn't apply it anyway + ts=$(echo $author|cut -d' ' -f5) + newpkgver=$(date -d "@$ts" +%Y%m%d) + cd ../../ elif [ -n "${_svntrunk}" -a -n "${_svnmod}" ] ; then [ $(type -p svn) ] || return 0 msg "$(gettext "Determining latest svn revision...")" -- 1.6.4.4