[macruby-changes] [771] MacRuby/trunk/Rakefile

source_changes at macosforge.org source_changes at macosforge.org
Wed Dec 24 07:21:12 PST 2008


Revision: 771
          http://trac.macosforge.org/projects/ruby/changeset/771
Author:   eloy.de.enige at gmail.com
Date:     2008-12-24 07:21:11 -0800 (Wed, 24 Dec 2008)
Log Message:
-----------
Properly read the git revision if the head is detached. Patch by Vincent Isambart.

Modified Paths:
--------------
    MacRuby/trunk/Rakefile

Modified: MacRuby/trunk/Rakefile
===================================================================
--- MacRuby/trunk/Rakefile	2008-12-24 10:41:32 UTC (rev 770)
+++ MacRuby/trunk/Rakefile	2008-12-24 15:21:11 UTC (rev 771)
@@ -273,11 +273,19 @@
     current_revision = "svn revision #{md_revision[1]} from #{md_url[1]}" if md_revision and md_url
   end
   if not current_revision and File.exist?('.git/HEAD')
-    md_ref = /^ref: (.+)$/.match(File.read('.git/HEAD'))
+    commit_sha1 = nil
+    head = File.read('.git/HEAD').strip
+    md_ref = /^ref: (.+)$/.match(head)
     if md_ref
+      # if the HEAD file contains "ref: XXXX", it's the reference to a branch
+      # so we read the file indicating the last commit of the branch
       head_file = ".git/#{md_ref[1]}"
-      current_revision = "git commit #{File.read(head_file).strip}" if File.exist?(head_file)
+      commit_sha1 = File.read(head_file).strip if File.exist?(head_file)
+    else
+      # otherwise, it's a detached head so it should be the SHA1 of the last commit
+      commit_sha1 = head
     end
+    current_revision = "git commit #{commit_sha1}" if commit_sha1 and not commit_sha1.empty?
   end
   current_revision = 'unknown revision' unless current_revision
   
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20081224/28242405/attachment.html>


More information about the macruby-changes mailing list