@@ -611,8 +611,8 @@ def git_checkout(
611611 base_repo : Optional [str ],
612612 base_ref : Optional [str ],
613613 base_rev : Optional [str ],
614- ref : Optional [str ],
615- commit : Optional [str ],
614+ head_ref : Optional [str ],
615+ head_rev : Optional [str ],
616616 ssh_key_file : Optional [Path ],
617617 ssh_known_hosts_file : Optional [Path ],
618618):
@@ -686,31 +686,31 @@ def git_checkout(
686686
687687 retry_required_command (b"vcs" , args , cwd = destination_path , extra_env = env )
688688
689- # If a ref was provided, it might be tag, so we need to make sure we fetch
689+ # If a head_ref was provided, it might be tag, so we need to make sure we fetch
690690 # those. This is explicitly only done when base and head repo match,
691691 # because it is the only scenario where tags could be present. (PRs, for
692692 # example, always include an explicit rev.) Failure to do this could result
693693 # in not having a tag, or worse: having an outdated version of one.
694694 # `--force` is needed to be able to update an existing tag.
695- if ref and base_repo == head_repo :
695+ if head_ref and base_repo == head_repo :
696696 args = [
697697 "git" ,
698698 "fetch" ,
699699 "--tags" ,
700700 "--force" ,
701701 base_repo ,
702- ref ,
702+ head_ref ,
703703 ]
704704
705705 retry_required_command (b"vcs" , args , cwd = destination_path , extra_env = env )
706706
707- # If a ref isn't provided, we fetch all refs from head_repo, which may be slow
707+ # If a head_ref isn't provided, we fetch all refs from head_repo, which may be slow
708708 args = [
709709 "git" ,
710710 "fetch" ,
711711 "--no-tags" ,
712712 head_repo ,
713- ref if ref else "+refs/heads/*:refs/remotes/work/*" ,
713+ head_ref if head_ref else "+refs/heads/*:refs/remotes/work/*" ,
714714 ]
715715
716716 retry_required_command (b"vcs" , args , cwd = destination_path , extra_env = env )
@@ -721,11 +721,11 @@ def git_checkout(
721721 "-f" ,
722722 ]
723723
724- if ref :
725- args .extend (["-B" , ref ])
724+ if head_ref :
725+ args .extend (["-B" , head_ref ])
726726
727727 # `git fetch` set `FETCH_HEAD` reference to the last commit of the desired branch
728- args .append (commit if commit else "FETCH_HEAD" )
728+ args .append (head_rev if head_rev else "FETCH_HEAD" )
729729
730730 run_required_command (b"vcs" , args , cwd = destination_path )
731731
@@ -912,8 +912,8 @@ def collect_vcs_options(args, project, name):
912912 base_ref = os .environ .get (f"{ env_prefix } _BASE_REF" )
913913 base_rev = os .environ .get (f"{ env_prefix } _BASE_REV" )
914914 head_repo = os .environ .get (f"{ env_prefix } _HEAD_REPOSITORY" )
915- revision = os .environ .get (f"{ env_prefix } _HEAD_REV " )
916- ref = os .environ .get (f"{ env_prefix } _HEAD_REF " )
915+ head_ref = os .environ .get (f"{ env_prefix } _HEAD_REF " )
916+ head_rev = os .environ .get (f"{ env_prefix } _HEAD_REV " )
917917 pip_requirements = os .environ .get (f"{ env_prefix } _PIP_REQUIREMENTS" )
918918 private_key_secret = os .environ .get (f"{ env_prefix } _SSH_SECRET_NAME" )
919919
@@ -945,8 +945,8 @@ def collect_vcs_options(args, project, name):
945945 "base-ref" : base_ref ,
946946 "base-rev" : base_rev ,
947947 "head-repo" : head_repo ,
948- "revision " : revision ,
949- "ref " : ref ,
948+ "head-ref " : head_ref ,
949+ "head-rev " : head_rev ,
950950 "repo-type" : repo_type ,
951951 "ssh-secret-name" : private_key_secret ,
952952 "pip-requirements" : pip_requirements ,
@@ -955,13 +955,13 @@ def collect_vcs_options(args, project, name):
955955
956956def vcs_checkout_from_args (options ):
957957 if not options ["checkout" ]:
958- if options ["ref" ] and not options ["revision " ]:
958+ if options ["head- ref" ] and not options ["head-rev " ]:
959959 print ("task should be defined in terms of non-symbolic revision" )
960960 sys .exit (1 )
961961 return
962962
963- revision = options ["revision " ]
964- ref = options ["ref " ]
963+ head_ref = options ["head-ref " ]
964+ head_rev = options ["head-rev " ]
965965 ssh_key_file = None
966966 ssh_known_hosts_file = None
967967 ssh_dir = None
@@ -979,13 +979,14 @@ def vcs_checkout_from_args(options):
979979 ssh_known_hosts_file = ssh_dir .joinpath ("known_hosts" )
980980 ssh_known_hosts_file .write_bytes (GITHUB_SSH_FINGERPRINT )
981981
982- if options [ "repo-type" ] == "git" :
983- if not revision and not ref :
984- raise RuntimeError (
985- "Git requires that either a ref, a revision, or both are provided"
986- )
982+ if not head_rev and not head_ref :
983+ raise RuntimeError (
984+ f" { options [ 'repo-type' ]. capitalize () } requires that either a "
985+ " ref, a revision, or both are provided"
986+ )
987987
988- if not ref :
988+ if options ["repo-type" ] == "git" :
989+ if not head_ref :
989990 print ("Providing a ref will improve the performance of this checkout" )
990991
991992 revision = git_checkout (
@@ -994,25 +995,20 @@ def vcs_checkout_from_args(options):
994995 options ["base-repo" ],
995996 options ["base-ref" ],
996997 options ["base-rev" ],
997- ref ,
998- revision ,
998+ head_ref ,
999+ head_rev ,
9991000 ssh_key_file ,
10001001 ssh_known_hosts_file ,
10011002 )
10021003 elif options ["repo-type" ] == "hg" :
1003- if not revision and not ref :
1004- raise RuntimeError (
1005- "Hg requires that at least one of a ref or revision is provided"
1006- )
1007-
10081004 revision = hg_checkout (
10091005 options ["checkout" ],
10101006 options ["head-repo" ],
10111007 options ["base-repo" ],
10121008 options ["store-path" ],
10131009 options ["sparse-profile" ],
1014- ref ,
1015- revision ,
1010+ head_ref ,
1011+ head_rev ,
10161012 )
10171013 else :
10181014 raise RuntimeError ('Type of VCS must be either "git" or "hg"' )
0 commit comments