lib/git/whence.rb in git-whence-0.2.0 vs lib/git/whence.rb in git-whence-0.2.1
- old
+ new
@@ -14,18 +14,21 @@
commit = expand(commit)
if is_merge?(commit)
warn "Commit is a merge"
- finished_with_commit(commit, options)
+ show_commit(commit, options)
+ 1
else
merge = find_merge(commit)
if merge
- finished_with_commit(merge, options)
+ show_commit(merge, options)
+ 0
else
warn "Unable to find merge"
- options[:open] ? finished_with_commit(commit, options) : 1
+ show_commit(commit, options) if options[:open]
+ 1
end
end
end
private
@@ -36,21 +39,20 @@
def is_merge?(commit)
sh("git cat-file -p #{commit}").split("\n")[1..2].grep(/parent /).size > 1
end
- def finished_with_commit(merge, options)
+ def show_commit(merge, options)
info = sh("git show -s --oneline #{merge}").strip
if options[:open]
if pr = info[/Merge pull request #(\d+) from /, 1]
exec "open", "https://github.com/#{origin}/pull/#{pr}"
else
warn "Unable to find PR number in #{info}"
exec "open", "https://github.com/#{origin}/commit/#{merge}"
end
else
puts info
- 0
end
end
# https://github.com/foo/bar or git@github.com:foo/bar.git -> foo/bar
def origin