Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

version.sh: handle shallow clones and snapshots.

Shallow clones (--depth X) lack the N tag used to compute
the revision number: use 'git-YYYY-MM-DD-hhhhhhh' as revision,
where hhhhhhh is the short git hash.

Snapshots from gitweb do not have git information at all,
but they have the short git hash in the directory name:
append it to the release number.
  • Loading branch information...
commit 657eac048eb267d781de83849fe7616d29320832 1 parent ba99474
authored July 21, 2011

Showing 1 changed file with 20 additions and 0 deletions. Show diff stats Hide diff stats

  1. 20  version.sh
20  version.sh
@@ -5,9 +5,29 @@ if ! test "$revision"; then
5 5
     revision=$(cd "$1" && git describe --tags --match N 2> /dev/null)
6 6
 fi
7 7
 
  8
+# Shallow Git clones (--depth) do not have the N tag:
  9
+# use 'git-YYYY-MM-DD-hhhhhhh'.
  10
+test "$revision" || revision=$(cd "$1" &&
  11
+  git log -1 --pretty=format:"git-%cd-%h" --date=short 2> /dev/null)
  12
+
  13
+# Snapshots from gitweb are in a directory called ffmpeg-hhhhhhh or
  14
+# ffmpeg-HEAD-hhhhhhh.
  15
+if [ -z "$revision" ]; then
  16
+  srcdir=$(cd "$1" && pwd)
  17
+  case "$srcdir" in
  18
+    */ffmpeg-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])
  19
+      git_hash="${srcdir##*-}";;
  20
+    */ffmpeg-HEAD-[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f])
  21
+      git_hash="${srcdir##*-}";;
  22
+  esac
  23
+fi
  24
+
8 25
 # no revision number found
9 26
 test "$revision" || revision=$(cd "$1" && cat RELEASE 2> /dev/null)
10 27
 
  28
+# Append the Git hash if we have one
  29
+test "$revision" && test "$git_hash" && revision="$revision-$git_hash"
  30
+
11 31
 # releases extract the version number from the VERSION file
12 32
 version=$(cd "$1" && cat VERSION 2> /dev/null)
13 33
 test "$version" || version=$revision

0 notes on commit 657eac0

Please sign in to comment.
Something went wrong with that request. Please try again.