Skip to content

Commit e9c1834

Browse files
authored
🐞 Proper checkout of resync branch (#54)
* Proper checkout of resync branch * Golangci-lint fixes
1 parent 4e4c5d9 commit e9c1834

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

pkg/sync/resync_releases.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -74,21 +74,24 @@ func (r resyncRelease) run() error {
7474
}
7575
return runSteps([]step{
7676
r.checkoutAs(downstreamRemote, downstreamBranch, syncBranch),
77-
r.mergeUpstream(upstreamBranch, syncBranch, []step{
77+
r.mergeUpstream(upstreamBranch, []step{
7878
r.checkoutAs(upstreamRemote, upstreamBranch, syncBranch),
7979
changesDetected,
8080
}),
81-
r.checkoutAs(upstreamRemote, upstreamBranch, syncBranch),
8281
r.generateImages(r.rel),
8382
r.commitChanges(r.ImagesGenerated, changesDetected),
84-
func() error {
83+
func() (err error) {
84+
defer func() {
85+
err = errors.Join(err, r.deleteBranch(syncBranch))
86+
}()
8587
if !changes {
8688
return nil
8789
}
88-
return multiStep{
90+
err = multiStep{
8991
r.pushBranch(syncBranch),
9092
r.createSyncReleasePR(downstreamBranch, upstreamBranch, syncBranch),
9193
}.runSteps()
94+
return
9295
},
9396
})
9497
}
@@ -100,16 +103,13 @@ func (r resyncRelease) checkoutAs(remote git.Remote, targetBranch, branch string
100103
}
101104
}
102105

103-
func (r resyncRelease) mergeUpstream(upstreamBranch, syncBranch string, onChanges []step) step {
106+
func (r resyncRelease) mergeUpstream(upstreamBranch string, onChanges []step) step {
104107
upstream := git.Remote{
105108
Name: "upstream",
106109
URL: r.Upstream,
107110
}
108111
return func() error {
109112
err := r.Merge(&upstream, upstreamBranch)
110-
defer func() {
111-
_ = r.deleteBranch(syncBranch)
112-
}()
113113
if errors.Is(err, gitv5.NoErrAlreadyUpToDate) {
114114
r.Println("- no changes detected")
115115
return nil

0 commit comments

Comments
 (0)