From 2f6286930d5a8f246c83c4c83dd60ba5f1119f8e Mon Sep 17 00:00:00 2001 From: Giuseppe Bilotta Date: Fri, 30 Jan 2009 23:41:14 +0100 Subject: 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. --- launch_here.rb | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'launch_here.rb') 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 -- cgit v1.2.3