Skip to content

Instantly share code, notes, and snippets.

@rtomayko
Created May 31, 2011 05:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rtomayko/88bc774d0c97e6c955c0 to your computer and use it in GitHub Desktop.
Save rtomayko/88bc774d0c97e6c955c0 to your computer and use it in GitHub Desktop.
commit 348d593ffbf19c677adf8ceaf0590bbffa85c5fa
Author: Ryan Tomayko <rtomayko@gmail.com>
Date: Sat May 28 14:03:47 2011 -0700
don't be clever resolving comparison head refs
Some people use full SHA1s as branch names:
https://github.com/nickmartini/dongml
Assuming refs that are valid 40 char SHA1s identify commits falls
down in this case:
https://haystack.github.com:54000/needles/4de1614e28bd19326a00141c
I'm not sure why we were doing this in the first place. It may be
from when walker always made a round-trip to resolve refs. Now it
looks up the ref in its refs hash so it should be plenty fast.
diff --git a/lib/github/comparison.rb b/lib/github/comparison.rb
index 5b441c3..2ed546a 100644
--- a/lib/github/comparison.rb
+++ b/lib/github/comparison.rb
@@ -48,12 +48,7 @@ module GitHub
# SHA1 of the commit to use as the head of the comparison.
def head_sha
return @head_sha if defined?(@head_sha)
- @head_sha =
- if head_ref =~ /^[0-9a-f]{40}$/
- head_ref
- else
- head_walker.ref_to_sha(head_ref)
- end
+ @head_sha = head_walker.ref_to_sha(head_ref)
end
# Truthy when the head ref is a commit SHA1; falsey when the head ref is a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment