File tree 1 file changed +13
-2
lines changed
1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package repo
2
2
3
3
import (
4
4
"context"
5
+ "errors"
5
6
"fmt"
6
7
"log"
7
8
"os"
@@ -66,11 +67,21 @@ func (c *Content) UpdateLicense(repoName string, cfg *config.Config) error {
66
67
log .Printf ("Error loading config for %s: %v\n " , repoName , err )
67
68
}
68
69
70
+ headRef , err := r .Head ()
71
+ if err != nil {
72
+ return fmt .Errorf ("error getting head ref for %s: %w" , repoName , err )
73
+ }
74
+ headRefName := headRef .Name ()
75
+ if ! headRefName .IsBranch () {
76
+ return errors .New ("HEAD ref is not a branch" )
77
+ }
78
+ defaultBranch := headRefName .Short ()
79
+
69
80
// If we are targeting a different branch with PRs, then our base also needs to start from that branch
70
- if repoConfig .PrTargetBranch != nil {
81
+ if repoConfig .PrTargetBranch != nil && * repoConfig . PrTargetBranch != defaultBranch {
71
82
err = c .checkoutBranch (r , w , * repoConfig .PrTargetBranch )
72
83
if err != nil {
73
- return err
84
+ return fmt . Errorf ( "error checking out branch %s: %w" , * repoConfig . PrTargetBranch , err )
74
85
}
75
86
}
76
87
You can’t perform that action at this time.
0 commit comments