Created
January 20, 2019 14:42
-
-
Save wata727/b73255db967909fd6db7738812cab4d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
equire "rugged" | |
def diff_between_parent(commit) | |
return if commit.parents.empty? | |
parent = commit.parents.inject do |ret, item| | |
commit.diff(ret).size < commit.diff(item).size ? ret : item | |
end | |
commit.diff(parent).each_patch do |patch| | |
patch.each_hunk do |hunk| | |
adds = hunk.lines.select(&:addition?) | |
dels = hunk.lines.select(&:deletion?) | |
if adds.size == 1 && dels.size == 1 && patch.delta.new_file[:path].start_with?("app/controllers") | |
puts patch | |
puts | |
end | |
end | |
end | |
diff_between_parent(parent) | |
end | |
repo = Rugged::Repository.new(".") | |
diff_between_parent(repo.last_commit) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
equire