comparing 2 commits in rugged
I didn’t find any documentation on getting the difference between 2 files in rugged.
I used the below code to commit a file using rugged
@repo=Rugged::Repository.new($reponame) @email@example.com('D:\Ruby\MyGitRepo\file1.txt','blob') puts @sha commit = @repo.lookup(@sha)
how can see the difference between the 2 commits of the same object in rugged?
- Rugged equivalent to 'git ls-tree'
- get the latest commit where a file changed
- Rugged - fetch, pull rebase possible?
- Merging two branches in Rugged
- rugged is installed but bundler fails to install
- Rugged and Grack: Finding commit before push
One Solution collect form web for “comparing 2 commits in rugged”
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.