Method: Oxidized::Git#get_diff
- Defined in:
- lib/oxidized/output/git.rb
#get_diff(node, group, oid1, oid2) ⇒ Object
give a hash with the patch of a diff between 2 revision and the stats (added and deleted lines)
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 |
# File 'lib/oxidized/output/git.rb', line 113 def get_diff node, group, oid1, oid2 begin diff_commits = nil repo, _ = yield_repo_and_path(node, group) repo = Rugged::Repository.new repo commit = repo.lookup(oid1) if oid2 commit_old = repo.lookup(oid2) diff = repo.diff(commit_old, commit) diff.each do |patch| if /#{node.name}\s+/.match(patch.to_s.lines.first) diff_commits = {:patch => patch.to_s, :stat => patch.stat} break end end else stat = commit.parents[0].diff(commit).stat stat = [stat[1],stat[2]] patch = commit.parents[0].diff(commit).patch diff_commits = {:patch => patch, :stat => stat} end diff_commits rescue 'no diffs' end end |