From: Felipe Contreras Date: Sat, 28 Sep 2013 22:03:49 GMT Subject: [PATCH v2 24/44] ruby: request-pull: use get_merge_bases() Message-ID: <1380405849-13000-25-git-send-email-felipe.contreras@gmail.com> In-Reply-To: <1380405849-13000-1-git-send-email-felipe.contreras@gmail.com> Signed-off-by: Felipe Contreras --- Notes: Now headrev and baserev become Git::Commit objects, fortunately 'puts("#{commit}")' or 'printf("%s\n", commit) convert the commit to a String (commit.to_s()), which is the hex sha1, so the rest of the script doesn't need to be changed. git-request-pull.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/git-request-pull.rb b/git-request-pull.rb index 9267147..be4947d 100755 --- a/git-request-pull.rb +++ b/git-request-pull.rb @@ -98,13 +98,15 @@ die "Not a valid revision: #{base}" unless baserev headrev = get_sha1("#{head}^0") die "Not a valid revision: #{head}" unless headrev -baserev = sha1_to_hex(baserev) -headrev = sha1_to_hex(headrev) +baserev = Git::Commit.get(baserev) +headrev = Git::Commit.get(headrev) -merge_base = `git merge-base #{baserev} #{headrev}`.chomp -die "No commits in common between #{base} and #{head}" unless $?.success? +merge_bases = get_merge_bases([baserev, headrev], 0); +die "No commits in common between #{base} and #{head}" unless merge_bases -ref = get_ref(url, headref != "HEAD" ? headref : nil, headrev, tag_name) +merge_base = sha1_to_hex(merge_bases.first.sha1) + +ref = get_ref(url, headref != "HEAD" ? headref : nil, headrev.to_s, tag_name) url = `git ls-remote --get-url "#{url}"`.chomp begin -- 1.8.4-fc