summaryrefslogtreecommitdiff
path: root/launch_here.rb
diff options
context:
space:
mode:
authorGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-01-30 23:41:14 +0100
committerGiuseppe Bilotta <giuseppe.bilotta@gmail.com>2009-01-31 00:17:23 +0100
commit2f6286930d5a8f246c83c4c83dd60ba5f1119f8e (patch)
treeb7ef896e65aef0a32aaf8c9151caffa03906658b /launch_here.rb
parent152b9e19975942341b77c94bc3765cbee6be24f8 (diff)
launch_here: be more compatible with git < 1.5.x
People living in the stone age (e.g. those stuck using Debian stable) still have git 1.4.4.4, which doesn't support git log --pretty=format. So we parse the git log --pretty=raw format instead, which should be available even on such older systems. For the same reason, parse git diff-index --stat instead of git diff --shortstat.
Diffstat (limited to 'launch_here.rb')
-rwxr-xr-xlaunch_here.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/launch_here.rb b/launch_here.rb
index 7bc21c80..8877aadf 100755
--- a/launch_here.rb
+++ b/launch_here.rb
@@ -16,14 +16,14 @@ begin
if File.exists? '.git'
begin
- git_out = `git log -1 --pretty=format:"%H%n%s%n%ct" | git name-rev --stdin`.split("\n")
- $version_timestamp = git_out.last.to_i
- subject = git_out[1].strip
+ git_out = `git log -1 --pretty=raw | git name-rev --stdin`.split("\n")
+ commit, branch_spec = git_out.first.scan(/^commit (\S+)(?: \((\S+)\))?$/).first
+ $version_timestamp = git_out[4].split[-2].to_i
+ subject = git_out[6].strip rescue ""
subject[77..-1] = "..." if subject.length > 80
- commit, branch_spec = git_out.first.scan(/^(\S+)(?: \((\S+)\))?$/).first
rev = "revision #{commit[0,7]}"
rev << " [#{subject}]" unless subject.empty?
- changes = `git diff --shortstat HEAD`.split(", ").first
+ changes = `git diff-index --stat HEAD`.split("\n").last.split(", ").first rescue nil
rev << ", #{changes.strip}" if changes
if branch_spec
tag, branch, offset = branch_spec.scan(/^(?:(tag)s\/)?(\S+?)(?:^0)?(?:~(\d+))?$/).first