Also make consistent the fallback versions. This patch uses a RELEASE-based approach rather than a tag-based one. There are several reasons for this. First, the -dev tags never convey more information than RELEASE. Second, RELEASE can provide a version even without Git.
The new script is designed to be fairly robust, tested under a plethora of conditions. --- RELEASE | 2 +- version.sh | 50 +++++++++++++++++++++++++++++++------------------- 2 files changed, 32 insertions(+), 20 deletions(-) diff --git a/RELEASE b/RELEASE index b889d20..f25eb1f 100644 --- a/RELEASE +++ b/RELEASE @@ -1 +1 @@ -3.0.git +n3.1-master diff --git a/version.sh b/version.sh index c46aec5..e92c811 100755 --- a/version.sh +++ b/version.sh @@ -4,42 +4,54 @@ export GIT_DIR="$1/.git" -# check for git short hash +# Check version using git describe. if ! test "$revision"; then - if (cd "$1" && grep git RELEASE 2> /dev/null >/dev/null) ; then + if (cd "$1" && grep -q master RELEASE); then + # If we are not in a release branch, use the N-based + # revision. revision=$(git describe --tags --match N 2> /dev/null) else - revision=$(git describe --tags --always 2> /dev/null) + # Check if there is a tag on this commit. + test "$version" || version=$(git describe --tags --exact-match 2> /dev/null) + + # If not, use git describe to find delta from latest tag + # as the revision. + revision=$(git describe --tags 2> /dev/null | cut -d- -f2-) fi fi # Shallow Git clones (--depth) do not have the N tag: -# use 'git-YYYY-MM-DD-hhhhhhh'. -test "$revision" || revision=$( - git log -1 --pretty=format:"git-%cd-%h" --date=short 2> /dev/null) +# use 'ghhhhhhh'. +if ! test "$revision"; then + revision=$(git log -1 --pretty=format:"%h" 2> /dev/null) + test "$revision" && revision=g$revision +fi # Snapshots from gitweb are in a directory called ffmpeg-hhhhhhh or # ffmpeg-HEAD-hhhhhhh. if [ -z "$revision" ]; then - srcdir=$(cd "$1" && pwd) - case "$srcdir" in - */ffmpeg-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]) - git_hash="${srcdir##*-}";; - */ffmpeg-HEAD-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]) - git_hash="${srcdir##*-}";; - esac + srcdir=$(cd "$1" && pwd) + case "$srcdir" in + */ffmpeg-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]) + revision="g${srcdir##*-}";; + */ffmpeg-HEAD-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]) + revision="g${srcdir##*-}";; + esac fi -# no revision number found -test "$revision" || revision=$(cd "$1" && cat RELEASE 2> /dev/null) +# If we have a revision prepend it with a hyphen. +test "$revision" && revision="-$revision" + +# Prepend RELEASE. +revision=$(cat "$1/RELEASE" | cut -d- -f1)-dev$revision -# Append the Git hash if we have one -test "$revision" && test "$git_hash" && revision="$revision-$git_hash" +# Check if this is a release through the VERSION file +test "$version" || version=$(cd "$1" && cat VERSION 2> /dev/null) -# releases extract the version number from the VERSION file -version=$(cd "$1" && cat VERSION 2> /dev/null) +# If not a release, use the revision. test "$version" || version=$revision +# Append any extra version string. test -n "$3" && version=$version-$3 if [ -z "$2" ]; then -- 1.9.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel