comparing 2 commits in rugged

删除回忆录丶 提交于 2019-12-05 18:31:37

The way to compare two commits in git relies on a diffing process.

brianmario recently wrapped the diffing iterator feature of libgit2. Beware that this feature is not merged yet.

Below a high level example of its future usage.

r = Rugged::Repository.new('.')
diff = r.diff(commit1, commit2)

diff.deltas.each do |delta|
  # ...
  delta.hunks.each do |hunk|
    # ...
    hunk.lines.each do |line|
      # ...
    end
  end
end

See this pull request for more information about proposed diff implementation and usage.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!