@@ -999,16 +999,15 @@ func TestIsSyntheticRef(t *testing.T) {
999999 }
10001000}
10011001
1002- func TestEnvVarsToConfig_BaseRefNormalization (t * testing.T ) {
1003- // scrub
1004- keys := []string {"GITHUB_ACTOR" , "GITHUB_SHA" , "BASE_REF" , "TEMP_BRANCH_PREFIX" , "TRANSLATIONS_PATH" , "BASE_LANG" , "FLAT_NAMING" , "ALWAYS_PULL_BASE" , "FORCE_PUSH" }
1005- for _ , k := range keys {
1002+ func TestEnvVarsToConfig_HeadRefNormalization (t * testing.T ) {
1003+ scrub := []string {"GITHUB_ACTOR" , "GITHUB_SHA" , "BASE_REF" , "HEAD_REF" , "TEMP_BRANCH_PREFIX" , "TRANSLATIONS_PATH" , "BASE_LANG" , "FLAT_NAMING" , "ALWAYS_PULL_BASE" , "FORCE_PUSH" , "FILE_FORMAT" }
1004+ for _ , k := range scrub {
10061005 t .Setenv (k , "" )
10071006 }
1008-
10091007 t .Setenv ("GITHUB_ACTOR" , "actor" )
10101008 t .Setenv ("GITHUB_SHA" , "abcdef" )
1011- t .Setenv ("BASE_REF" , "refs/heads/release/2025-10" )
1009+ t .Setenv ("BASE_REF" , "main" )
1010+ t .Setenv ("HEAD_REF" , "refs/heads/feature/foo" )
10121011 t .Setenv ("TEMP_BRANCH_PREFIX" , "lok" )
10131012 t .Setenv ("TRANSLATIONS_PATH" , "messages" )
10141013 t .Setenv ("FILE_FORMAT" , "json" )
@@ -1021,8 +1020,8 @@ func TestEnvVarsToConfig_BaseRefNormalization(t *testing.T) {
10211020 if err != nil {
10221021 t .Fatalf ("unexpected err: %v" , err )
10231022 }
1024- if cfg .BaseRef != "release/2025-10 " {
1025- t .Fatalf ("want release/2025-10 , got %s" , cfg .BaseRef )
1023+ if cfg .HeadRef != "feature/foo " {
1024+ t .Fatalf ("want feature/foo , got %s" , cfg .HeadRef )
10261025 }
10271026}
10281027
@@ -1049,6 +1048,36 @@ func TestEnvVarsToConfig_NoExtsFails(t *testing.T) {
10491048 }
10501049}
10511050
1051+ func TestIsSyntheticRef_PullAlias (t * testing.T ) {
1052+ if ! isSyntheticRef ("pull/99/merge" ) {
1053+ t .Errorf ("expected synthetic" )
1054+ }
1055+ }
1056+
1057+ func TestCheckoutBranch_FetchesCorrectRefspec (t * testing.T ) {
1058+ fetched := ""
1059+ runner := & MockCommandRunner {
1060+ CaptureFunc : func (name string , args ... string ) (string , error ) {
1061+ if name == "git" && args [0 ] == "fetch" {
1062+ fetched = strings .Join (args , " " )
1063+ }
1064+ return "" , nil
1065+ },
1066+ RunFunc : func (name string , args ... string ) error {
1067+ if name == "git" && len (args ) == 4 && args [0 ] == "checkout" && args [1 ] == "-B" && args [2 ] == "new_branch" && args [3 ] == "origin/main" {
1068+ return nil
1069+ }
1070+ return fmt .Errorf ("unexpected: %v" , args )
1071+ },
1072+ }
1073+ if err := checkoutBranch ("new_branch" , "main" , "" , runner ); err != nil {
1074+ t .Fatal (err )
1075+ }
1076+ if ! strings .Contains (fetched , "+refs/heads/main:refs/remotes/origin/main" ) {
1077+ t .Errorf ("unexpected fetch refspec: %q" , fetched )
1078+ }
1079+ }
1080+
10521081// containsSubstring checks if a string contains a substring
10531082func containsSubstring (s , substr string ) bool {
10541083 return strings .Contains (s , substr )
0 commit comments