File tree Expand file tree Collapse file tree 1 file changed +26
-1
lines changed
Expand file tree Collapse file tree 1 file changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -768,9 +768,34 @@ def _commit_sha(self, commit_obj):
768768 return commit_obj
769769 elif isinstance (commit_obj , basestring ):
770770 # Can't use self[commit_obj] to avoid infinite recursion
771- commit_obj = self .repo [commit_obj ]
771+ commit_obj = self .repo [self . dwim_reference ( commit_obj ) ]
772772 return commit_obj .id
773773
774+ def dwim_reference (self , ref ):
775+ """Dwim resolves a short reference to a full reference
776+ """
777+
778+ # Formats of refs we want to try in order
779+ formats = [
780+ "%s" ,
781+ "refs/%s" ,
782+ "refs/tags/%s" ,
783+ "refs/heads/%s" ,
784+ "refs/remotes/%s" ,
785+ "refs/remotes/%s/HEAD" ,
786+ ]
787+
788+ for f in formats :
789+ try :
790+ fullref = f % ref
791+ if not fullref in self .repo :
792+ continue
793+ return fullref
794+ except :
795+ continue
796+
797+ raise Exception ("Could not resolve ref" )
798+
774799 def blob_data (self , sha ):
775800 """Return a blobs content for a given SHA
776801 """
You can’t perform that action at this time.
0 commit comments