Skip to content

Commit 2170a3e

Browse files
committed
Don't delete branch twice
1 parent e9c1834 commit 2170a3e

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

internal/cmd/root.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ func (a App) Command() *cobra.Command {
2323
}
2424
cmd.SetOut(os.Stdout)
2525
cmd.SetErr(os.Stderr)
26+
cmd.PersistentPreRun = func(cmd *cobra.Command, args []string) {
27+
cmd.SilenceUsage = true
28+
}
2629
opts := &cli.Options{}
2730
subs := []subcommand{
2831
sync{opts},

internal/cmd/sync.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ type sync struct {
1515

1616
func (s sync) command() *cobra.Command {
1717
cmd := &cobra.Command{
18-
Use: "sync",
18+
Use: "sync [project-dir]",
1919
Short: "Synchronize to the upstream releases",
2020
ValidArgs: []string{"REPOSITORY"},
21-
Args: cobra.OnlyValidArgs,
21+
Args: cobra.MaximumNArgs(1),
2222
RunE: s.run,
2323
}
2424
return cmd
@@ -35,16 +35,16 @@ func (s sync) project(args []string) func() config.Project {
3535
if err != nil {
3636
wd = "/"
3737
}
38+
if len(args) > 0 {
39+
wd = args[0]
40+
}
3841
if !path.IsAbs(configPath) {
3942
configPath = path.Join(wd, configPath)
4043
}
4144
project := config.Project{
4245
ConfigPath: configPath,
4346
Path: wd,
4447
}
45-
if len(args) > 0 {
46-
project.Path = args[0]
47-
}
4848
return project
4949
}
5050
}

pkg/sync/create_pr.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ func (c createPR) open() error {
101101
cl := github.NewClient(args...)
102102
cl.ProjectDir = c.Path
103103
buff, err := cl.Execute(c.Context)
104-
defer c.Println("Github client:", buff)
104+
defer c.Println("Github client:", string(buff))
105105
return errors.Wrap(err, ErrSyncFailed)
106106
}
107107

pkg/sync/resync_releases.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,6 @@ func (r resyncRelease) run() error {
8181
r.generateImages(r.rel),
8282
r.commitChanges(r.ImagesGenerated, changesDetected),
8383
func() (err error) {
84-
defer func() {
85-
err = errors.Join(err, r.deleteBranch(syncBranch))
86-
}()
8784
if !changes {
8885
return nil
8986
}

0 commit comments

Comments
 (0)