From 36f349f3f005ab105c7e665dfee00b9b7e8d6939 Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Thu, 10 Apr 2008 18:59:54 +0200 Subject: rbot: don't fail in git checkout if git can't be run --- bin/rbot | 39 ++++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 17 deletions(-) (limited to 'bin') diff --git a/bin/rbot b/bin/rbot index a5b7865a..ed6b57f8 100755 --- a/bin/rbot +++ b/bin/rbot @@ -68,24 +68,29 @@ $opts = Hash.new if $version =~ /git/ if defined?(SCM_DIR) and File.exists?(File.join(SCM_DIR, '.git')) - git_out = `git status` - - git_out.match(/^# On branch (.*)\n/) - 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})" + begin + git_out = `git status` + git_out.match(/^# On branch (.*)\n/) + 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 - else # older gits - git_out = `git branch` - git_out.match(/^\* (.*)\n/) - branch = $1.dup rescue "unknown" - rev = "revision " + `git rev-parse HEAD`[0,6] + rescue => e + puts e.inspect + branch = "unknown branch" + rev = "unknown revision" end $version << " (#{branch} branch, #{rev})" -- cgit v1.2.3