Skip to content

Commit 4e4c5d9

Browse files
authored
🎁 Generate images on resync (#51)
* Generate images on re-sync * Generate images regardless of upstream changes to resync
1 parent 4dc042a commit 4e4c5d9

File tree

2 files changed

+27
-4
lines changed

2 files changed

+27
-4
lines changed

pkg/sync/operation.go

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func (o Operation) switchToMain() error {
4242
)
4343
}
4444

45-
func (o Operation) commitChanges(message string) step {
45+
func (o Operation) commitChanges(message string, onCommit ...step) step {
4646
return func() error {
4747
o.Println("- Committing changes:", message)
4848
commit, err := o.CommitChanges(message)
@@ -57,7 +57,14 @@ func (o Operation) commitChanges(message string) step {
5757
if err == nil {
5858
o.Printf("-- Statistics:\n%s\n", stats)
5959
}
60-
return errors.Wrap(err, ErrSyncFailed)
60+
err = errors.Wrap(err, ErrSyncFailed)
61+
for _, st := range onCommit {
62+
if serr := st(); serr != nil {
63+
err = errors.Join(err, serr)
64+
break
65+
}
66+
}
67+
return err
6168
}
6269
}
6370

pkg/sync/resync_releases.go

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,29 @@ func (r resyncRelease) run() error {
6767
Name: "upstream",
6868
URL: r.Upstream,
6969
}
70+
changes := false
71+
changesDetected := func() error {
72+
changes = true
73+
return nil
74+
}
7075
return runSteps([]step{
7176
r.checkoutAs(downstreamRemote, downstreamBranch, syncBranch),
7277
r.mergeUpstream(upstreamBranch, syncBranch, []step{
7378
r.checkoutAs(upstreamRemote, upstreamBranch, syncBranch),
74-
r.pushBranch(syncBranch),
75-
r.createSyncReleasePR(downstreamBranch, upstreamBranch, syncBranch),
79+
changesDetected,
7680
}),
81+
r.checkoutAs(upstreamRemote, upstreamBranch, syncBranch),
82+
r.generateImages(r.rel),
83+
r.commitChanges(r.ImagesGenerated, changesDetected),
84+
func() error {
85+
if !changes {
86+
return nil
87+
}
88+
return multiStep{
89+
r.pushBranch(syncBranch),
90+
r.createSyncReleasePR(downstreamBranch, upstreamBranch, syncBranch),
91+
}.runSteps()
92+
},
7793
})
7894
}
7995

0 commit comments

Comments
 (0)