public
Rubygem
Description: Ruby/Git is a Ruby library that can be used to create, read and manipulate Git repositories by wrapping system calls to the git binary.
Homepage: http://jointheconversation.org/rubygit/
Clone URL: git://github.com/schacon/ruby-git.git
added grep and author searching to logs
schacon (author)
Tue May 27 12:36:07 -0700 2008
commit  bceadeb7d377b6ba36de4f5de5a5f5034f89bee6
tree    05b4e3ccfd0e6c2f4b0cae8f118d12eca1f38f54
parent  743ac297402ce8713d1c58db42c8a0540cb026a8
...
68
69
70
 
 
71
72
73
...
80
81
82
 
 
83
84
85
...
68
69
70
71
72
73
74
75
...
82
83
84
85
86
87
88
89
0
@@ -68,6 +68,8 @@ module Git
0
       arr_opts << "-#{opts[:count]}" if opts[:count]
0
       arr_opts << "--since=\"#{opts[:since]}\"" if opts[:since].is_a? String
0
       arr_opts << "--until=\"#{opts[:until]}\"" if opts[:until].is_a? String
0
+ arr_opts << "--grep=\"#{opts[:grep]}\"" if opts[:grep].is_a? String
0
+ arr_opts << "--author=\"#{opts[:author]}\"" if opts[:author].is_a? String
0
       arr_opts << "#{opts[:between][0].to_s}..#{opts[:between][1].to_s}" if (opts[:between] && opts[:between].size == 2)
0
       arr_opts << opts[:object] if opts[:object].is_a? String
0
       arr_opts << '-- ' + opts[:path_limiter] if opts[:path_limiter].is_a? String
0
@@ -80,6 +82,8 @@ module Git
0
       arr_opts << "-#{opts[:count]}" if opts[:count]
0
       arr_opts << "--since=\"#{opts[:since]}\"" if opts[:since].is_a? String
0
       arr_opts << "--until=\"#{opts[:until]}\"" if opts[:until].is_a? String
0
+ arr_opts << "--grep=\"#{opts[:grep]}\"" if opts[:grep].is_a? String
0
+ arr_opts << "--author=\"#{opts[:author]}\"" if opts[:author].is_a? String
0
       arr_opts << "#{opts[:between][0].to_s}..#{opts[:between][1].to_s}" if (opts[:between] && opts[:between].size == 2)
0
       arr_opts << opts[:object] if opts[:object].is_a? String
0
       arr_opts << '-- ' + opts[:path_limiter] if opts[:path_limiter].is_a? String
...
27
28
29
 
 
 
 
 
 
 
 
 
 
 
 
30
31
32
...
92
93
94
95
 
 
 
96
97
98
...
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
...
104
105
106
 
107
108
109
110
111
112
0
@@ -27,6 +27,18 @@ module Git
0
       @object = objectish
0
       return self
0
     end
0
+
0
+ def author(regex)
0
+ dirty_log
0
+ @author = regex
0
+ return self
0
+ end
0
+
0
+ def grep(regex)
0
+ dirty_log
0
+ @grep = regex
0
+ return self
0
+ end
0
     
0
     def path(path)
0
       dirty_log
0
@@ -92,7 +104,9 @@ module Git
0
       # actually run the 'git log' command
0
       def run_log
0
         log = @base.lib.full_log_commits(:count => @count, :object => @object,
0
- :path_limiter => @path, :since => @since, :until => @until, :between => @between)
0
+ :path_limiter => @path, :since => @since,
0
+ :author => @author, :grep => @grep,
0
+ :until => @until, :between => @between)
0
         @commits = log.map { |c| Git::Object::Commit.new(@base, c['sha'], c) }
0
       end
0
       
...
32
33
34
 
 
 
 
 
 
 
 
 
 
 
 
35
36
37
...
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
0
@@ -32,6 +32,18 @@ class TestLog < Test::Unit::TestCase
0
     assert_equal(30, l.size)
0
   end
0
   
0
+ def test_get_log_grep
0
+ l = @git.log.grep("search")
0
+ assert_equal(2, l.size)
0
+ end
0
+
0
+ def test_get_log_author
0
+ l = @git.log(5).author("chacon")
0
+ assert_equal(5, l.size)
0
+ l = @git.log(5).author("lazySusan")
0
+ assert_equal(0, l.size)
0
+ end
0
+
0
   def test_get_log_since_file
0
     l = @git.log.object('example.txt')
0
     assert_equal(30, l.size)

Comments

    No one has commented yet.