@@ -664,33 +664,22 @@ def git_checkout(
664664
665665 retry_required_command (b"vcs" , args , cwd = destination_path , extra_env = env )
666666
667- # If a ref was provided, it might be tag, so we need to make sure we fetch
668- # those. This is explicitly only done when base and head repo match,
669- # because it is the only scenario where tags could be present. (PRs, for
670- # example, always include an explicit rev.) Failure to do this could result
671- # in not having a tag, or worse: having an outdated version of one.
672- # `--force` is needed to be able to update an existing tag.
667+ # Fetch ref
668+ args = ["git" , "fetch" ]
673669 if ref and base_repo == head_repo :
674- args = [
675- "git" ,
676- "fetch" ,
677- "--tags" ,
678- "--force" ,
679- base_repo ,
680- ref ,
681- ]
682-
683- retry_required_command (b"vcs" , args , cwd = destination_path , extra_env = env )
670+ # If a ref was provided, it might be tag, so we need to make sure we fetch
671+ # those. This is explicitly only done when base and head repo match,
672+ # because it is the only scenario where tags could be present. (PRs, for
673+ # example, always include an explicit rev.) Failure to do this could result
674+ # in not having a tag, or worse: having an outdated version of one.
675+ # `--force` is needed to be able to update an existing tag.
676+ args .extend (["--tags" , "--force" ])
684677
685- # If a ref isn't provided, we fetch all refs from head_repo, which may be slow
686- args = [
687- "git" ,
688- "fetch" ,
689- "--no-tags" ,
690- head_repo ,
691- ref if ref else "+refs/heads/*:refs/remotes/work/*" ,
692- ]
678+ else :
679+ args .append ("--no-tags" )
693680
681+ # If a ref isn't provided, we fetch all refs from head_repo, which may be slow.
682+ args .extend ([head_repo , ref if ref else "+refs/heads/*:refs/remotes/work/*" ])
694683 retry_required_command (b"vcs" , args , cwd = destination_path , extra_env = env )
695684
696685 args = [
0 commit comments