[PATCH v2 24/44] ruby: request-pull: use get_merge_bases()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Felipe Contreras <felipe.contreras@xxxxxxxxx>
---

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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]