File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -621,6 +621,19 @@ def _clean_git_checkout(destination_path):
621621 print_line (b"vcs" , b"successfully cleaned git checkout!\n " )
622622
623623
624+ def shortref (ref : str ) -> str :
625+ """Normalize a git ref to its short form.
626+
627+ Returns the ref unchanged if it's already in short form.
628+ """
629+ # Strip common ref prefixes
630+ for prefix in ("refs/heads/" , "refs/tags/" ):
631+ if ref .startswith (prefix ):
632+ return ref [len (prefix ) :]
633+
634+ return ref
635+
636+
624637def git_checkout (
625638 destination_path : str ,
626639 head_repo : str ,
@@ -721,7 +734,7 @@ def git_checkout(
721734 ]
722735
723736 if head_ref :
724- args .extend (["-B" , head_ref ])
737+ args .extend (["-B" , shortref ( head_ref ) ])
725738
726739 # `git fetch` set `FETCH_HEAD` reference to the last commit of the desired branch
727740 args .append (head_rev if head_rev else "FETCH_HEAD" )
You can’t perform that action at this time.
0 commit comments