summaryrefslogtreecommitdiffstats
path: root/lib/git/diff.rb
diff options
context:
space:
mode:
authorscott Chacon <schacon@agadorsparticus.corp.reactrix.com>2007-11-09 13:11:22 -0800
committerscott Chacon <schacon@agadorsparticus.corp.reactrix.com>2007-11-09 13:11:22 -0800
commit9d59d2965184964ab6662282ef5f9ceac2c58552 (patch)
treef8dd8bf4004eb9403f9ffe2b5c5c708ef877895a /lib/git/diff.rb
parentab20a674e50268b6c541949c746d77b16a26d15c (diff)
downloadthird_party-ruby-git-9d59d2965184964ab6662282ef5f9ceac2c58552.tar.gz
third_party-ruby-git-9d59d2965184964ab6662282ef5f9ceac2c58552.tar.xz
third_party-ruby-git-9d59d2965184964ab6662282ef5f9ceac2c58552.zip
added branches, more log stuff, better tests, changed the log api a bit
added tests for Git::Lib, started Git::Diff development
Diffstat (limited to 'lib/git/diff.rb')
-rw-r--r--lib/git/diff.rb37
1 files changed, 37 insertions, 0 deletions
diff --git a/lib/git/diff.rb b/lib/git/diff.rb
new file mode 100644
index 0000000..3686edb
--- /dev/null
+++ b/lib/git/diff.rb
@@ -0,0 +1,37 @@
+module Git
+
+ # object that holds the last X commits on given branch
+ class Diff
+ include Enumerable
+
+ @base = nil
+ @from = nil
+ @to = nil
+
+ @full_diff = nil
+
+ def initialize(base, from = nil, to = nil)
+ dirty_log
+ @base = base
+ @from = from
+ @to = to
+ end
+
+ def
+ # enumerable methods
+
+ def each
+ cache_diff
+ @full_diff.each do |file|
+ yield file
+ end
+ end
+
+ private
+
+ def cache_diff
+ if !@full_diff
+ @full_diff = @base.lib.diff_files(@from, @to)
+ end
+ end
+end \ No newline at end of file