public
Fork of mojombo/grit
Description: Grit is a Ruby library for extracting information from a git repository in an object oriented manner.
Homepage: http://grit.rubyforge.org/
Clone URL: git://github.com/dustin/grit.git
Search Repo:
Added a method for getting the current branch.
dustin (author)
Tue Apr 01 10:52:03 -0700 2008
commit  420eac97a826bfac8724b6b0eef35c20922124b7
tree    e20cd1de2a022aef9ddae66e3f8dd8184f156c0f
parent  d6016bc9fa3950ad18e3028f9d2d26f831061a62
...
37
38
39
40
 
 
 
 
 
 
 
 
 
 
 
 
 
41
42
43
...
37
38
39
 
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
0
@@ -37,7 +37,19 @@
0
                  
0
       self.list_from_string(repo, output)
0
     end
0
-
0
+
0
+ # Get the HEAD revision of the repo.
0
+ # +repo+ is the Repo
0
+ # +options+ is a Hash of options
0
+ #
0
+ # Returns Grit::Head (baked)
0
+ def self.current(repo, options = {})
0
+ head = File.open(File.join(repo.path, 'HEAD')).read.chomp
0
+ if /ref: refs\/heads\/(.*)/.match(head)
0
+ self.new($1, repo.git.rev_parse(options, 'HEAD'))
0
+ end
0
+ end
0
+
0
     # Parse out head information into an array of baked head objects
0
     # +repo+ is the Repo
0
     # +text+ is the text output from the git command
...
52
53
54
55
 
 
 
 
 
 
 
 
56
57
58
...
52
53
54
 
55
56
57
58
59
60
61
62
63
64
65
0
@@ -52,7 +52,14 @@
0
     end
0
     
0
     alias_method :branches, :heads
0
-
0
+
0
+ # Object reprsenting the current repo head.
0
+ #
0
+ # Returns Grit::Head (baked)
0
+ def head
0
+ Head.current(self)
0
+ end
0
+
0
     # An array of Tag objects that are available in this repo
0
     #
0
     # Returns Grit::Tag[] (baked)

Comments

    No one has commented yet.