Вопрос

In svn, we used to use post deployment hooks to write the deployed version checkin number as a build suffix for the application version deployed.

I.e. if we were deploying a 3.0 build of our app, the about window in the app would display 3.0.1234 where 1234 was the build revision from svn.

This allows QA to see a revision number and look at resolved bugs, comparing the build number in the resolved bugs, and if the deployed app's revision was higher than the one in the bug report, theyd be assured the fix was deployed (or not).

With git and mercurial, revision hashes dont provide similar features. How do u guys work around this using git?

Это было полезно?

Решение

Use git describe. The output looks like this: v5.19.5-55-ga854082, a committish with three parts: v5.19.5 is the most recent tag in the current branch, 55 is the number of commits since this tag, and ga854082 is an abbreviated SHA1 with a preceding g. The number of commits may be used for checking if something is newer.

(The git describe output above is actually a real world example from the perl source code)

Другие советы

You could use a hook on tags in Git. Tags are made for versioning, among the others purposes.

You could even use the hash itself for versioning, see Debian for instance: a few packages have version strings like 4.8.5+git121-g2a9ea11. Why is it not OK?

I use a post-checkout, post-commit, post-merge and post-rewrite hook with:

M=2228.1
rev=`git rev-parse --verify --short HEAD`

b=$(git branch --no-color 2> /dev/null | \
    sed -e '/^[^*]/d' -e 's/* \(.*\)/\1/')

case $b in
  (_tmp*)
        cnt=`git rev-list "$M"..$rev -- | wc -l`

        printf '#define AUTO_REVISION TEST%u+%s\n' "$cnt" "$rev" > auto-version.h
        ...
        ;;
  (*)
        cnt=`git rev-list $rev -- | wc -l`

        printf '#define AUTO_REVISION g%05u+%s\n' "$cnt" "$rev" > auto-version.h
        ...
        ;;
esac

cat << EOF >> auto-version.mk
AUTO_REVISION_CNT = $cnt
AUTO_REVISION_REV = $rev
EOF

The 'cnt' variable contains the number of commits since beginning or a certain branch/tag (2228.1 in this case) and depending on the actual branch (release/test) different schemes are applied.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top