]> git.netwichtig.de Git - user/henk/code/ruby/rbot.git/commitdiff
When running from a git repository, expose the current git revision
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 27 Aug 2007 01:41:30 +0000 (01:41 +0000)
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>
Mon, 27 Aug 2007 01:41:30 +0000 (01:41 +0000)
bin/rbot

index c6d62daa1e2da674788f432c7eecc8b389c88696..946344586bfbac2c0bc3632219733cecccad5228 100755 (executable)
--- a/bin/rbot
+++ b/bin/rbot
@@ -44,6 +44,17 @@ $opts = Hash.new
 if $version =~ /svn/
   if defined?(SVN_DIR) and File.exists?(File.join(SVN_DIR, '.git'))
     $version.sub!('svn', 'git')
+
+    git_out = `git status`
+
+    git_out.match(/^# On branch (.*)\n/)
+    branch = $1
+    changed = git_out.match(/^# Change(.*)\n/)
+    rev = " @ #{`git rev-parse HEAD`[0..6]}"
+    rev << ", local changes" if changed
+
+    $version << "-#{branch}" unless branch.empty?
+    $version << rev
   else
     up = File.dirname(__FILE__) + "/.."
     rev = " (unknown revision)"