]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
bin/rbot: be compatible with older gits
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 11 Feb 2008 09:16:25 +0000 (10:16 +0100)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 11 Feb 2008 09:16:25 +0000 (10:16 +0100)
bin/rbot

index b06c5745b066403f49346c3b5031289d8dfb9f1f..382725c2dc660dd7e408e7db6dbb7347dd852f65 100755 (executable)
--- a/bin/rbot
+++ b/bin/rbot
@@ -48,15 +48,22 @@ if $version =~ /svn/
     git_out = `git status`
 
     git_out.match(/^# On branch (.*)\n/)
-    branch = $1.dup || "unknown"
-    changed = git_out.match(/^# Change(.*)\n/)
-    rev = "revision "
-    git_out = `git log -1 --pretty=format:"%h%n%b"`.split("\n")
-    rev << git_out.first
-    if git_out.last.match(/^git-svn-id: \S+@(\d+)/)
-      rev << "(svn #{$1})"
+    if $1 # git 1.5.x
+      branch = $1.dup || "unknown"
+      changed = git_out.match(/^# Change(.*)\n/)
+      rev = "revision "
+      git_out = `git log -1 --pretty=format:"%h%n%b"`.split("\n")
+      rev << git_out.first
+      if git_out.last.match(/^git-svn-id: \S+@(\d+)/)
+        rev << "(svn #{$1})"
+      end
+      rev << ", local changes" if changed
+    else # older gits
+      git_out = `git branch`
+      git_out.match(/^\* (.*)\n/)
+      branch = $1.dup rescue "unknown"
+      rev = "revision " + `git rev-parse HEAD`[0,6]
     end
-    rev << ", local changes" if changed
 
     $version << " (#{branch} branch, #{rev})"
   else