diff options
author | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-04-10 18:59:54 +0200 |
---|---|---|
committer | Giuseppe Bilotta <giuseppe.bilotta@gmail.com> | 2008-04-10 18:59:54 +0200 |
commit | 36f349f3f005ab105c7e665dfee00b9b7e8d6939 (patch) | |
tree | a7ae4c56c417cba4d2277f85fc75f2b84032a6fe /bin | |
parent | 173c64800b2bf9b7a36c83eeadd74d974cb7ec15 (diff) |
rbot: don't fail in git checkout if git can't be run
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/rbot | 39 |
1 files changed, 22 insertions, 17 deletions
@@ -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})" |