GitHub Sale: sign up for any paid plan this week and pay nothing until January 1, 2009!  [ hide ]

public
Fork of mojombo/grit
Clone URL: git://github.com/defunkt/grit.git
add tag support
mojombo (author)
Sun Feb 10 18:49:09 -0800 2008
commit  7a8d32cb18a0ba2ff8bf86cadacc3fd2816da219
tree    c419308ba70d36105336ddde1070209e516df853
parent  80238dccfb24b5dee8f6d6c99fc8d272486e0946
...
14
15
16
 
17
18
19
...
14
15
16
17
18
19
20
0
@@ -14,6 +14,7 @@ require 'grit/lazy'
0
 require 'grit/errors'
0
 require 'grit/git'
0
 require 'grit/head'
0
+require 'grit/tag'
0
 require 'grit/commit'
0
 require 'grit/tree'
0
 require 'grit/blob'
...
35
36
37
38
 
39
40
41
...
35
36
37
 
38
39
40
41
0
@@ -35,7 +35,7 @@ module Grit
0
       
0
       output = repo.git.for_each_ref(actual_options, "refs/heads")
0
                  
0
- Head.list_from_string(repo, output)
0
+ self.list_from_string(repo, output)
0
     end
0
     
0
     # Parse out head information into an array of baked head objects
...
57
58
59
60
 
61
62
63
...
57
58
59
 
60
61
62
63
0
@@ -57,7 +57,7 @@ module Grit
0
     #
0
     # Returns Grit::Tag[] (baked)
0
     def tags
0
-
0
+ Tag.find_all(self)
0
     end
0
     
0
     # An array of Commit objects representing the history of a given ref/commit
...
8
9
10
11
 
12
13
14
15
16
17
 
18
19
20
21
 
22
23
24
 
25
26
27
28
 
29
30
 
31
32
33
 
34
35
36
37
 
38
39
 
40
41
42
 
43
44
45
 
46
47
48
 
49
50
 
51
52
53
54
55
56
57
 
58
59
60
...
64
65
66
67
 
68
69
 
70
71
72
...
8
9
10
 
11
12
13
14
15
16
 
17
18
19
20
 
21
22
23
 
24
25
26
27
 
28
29
 
30
31
32
 
33
34
35
36
 
37
38
 
39
40
41
 
42
43
44
 
45
46
47
 
48
49
 
50
51
52
53
54
55
56
 
57
58
59
60
...
64
65
66
 
67
68
 
69
70
71
72
0
@@ -8,53 +8,53 @@ module Grit
0
     # +name+ is the name of the head
0
     # +commit+ is the Commit that the head points to
0
     #
0
- # Returns Grit::Head (baked)
0
+ # Returns Grit::Tag (baked)
0
     def initialize(name, commit)
0
       @name = name
0
       @commit = commit
0
     end
0
     
0
- # Find all Heads
0
+ # Find all Tags
0
     # +repo+ is the Repo
0
     # +options+ is a Hash of options
0
     #
0
- # Returns Grit::Head[] (baked)
0
+ # Returns Grit::Tag[] (baked)
0
     def self.find_all(repo, options = {})
0
       default_options = {:sort => "committerdate",
0
- :format => "'%(refname)%00%(objectname)'"}
0
+ :format => "%(refname)%00%(objectname)"}
0
                          
0
       actual_options = default_options.merge(options)
0
       
0
- output = repo.git.for_each_ref(actual_options, "refs/heads")
0
+ output = repo.git.for_each_ref(actual_options, "refs/tags")
0
                  
0
- Head.list_from_string(repo, output)
0
+ self.list_from_string(repo, output)
0
     end
0
     
0
- # Parse out head information into an array of baked head objects
0
+ # Parse out tag information into an array of baked Tag objects
0
     # +repo+ is the Repo
0
     # +text+ is the text output from the git command
0
     #
0
- # Returns Grit::Head[] (baked)
0
+ # Returns Grit::Tag[] (baked)
0
     def self.list_from_string(repo, text)
0
- heads = []
0
+ tags = []
0
       
0
       text.split("\n").each do |line|
0
- heads << self.from_string(repo, line)
0
+ tags << self.from_string(repo, line)
0
       end
0
       
0
- heads
0
+ tags
0
     end
0
     
0
- # Create a new Head instance from the given string.
0
+ # Create a new Tag instance from the given string.
0
     # +repo+ is the Repo
0
- # +line+ is the formatted head information
0
+ # +line+ is the formatted tag information
0
     #
0
     # Format
0
     # name: [a-zA-Z_/]+
0
     # <null byte>
0
     # id: [0-9A-Fa-f]{40}
0
     #
0
- # Returns Grit::Head (baked)
0
+ # Returns Grit::Tag (baked)
0
     def self.from_string(repo, line)
0
       full_name, id = line.split("\0")
0
       name = full_name.split("/").last
0
@@ -64,8 +64,8 @@ module Grit
0
     
0
     # Pretty object inspection
0
     def inspect
0
- %Q{#<Grit::Head "#{@name}">}
0
+ %Q{#<Grit::Tag "#{@name}">}
0
     end
0
- end # Head
0
+ end # Tag
0
   
0
 end # Grit
0
\ No newline at end of file

Comments

    No one has commented yet.