Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions internal/cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ func (a App) Command() *cobra.Command {
}
cmd.SetOut(os.Stdout)
cmd.SetErr(os.Stderr)
cmd.PersistentPreRun = func(cmd *cobra.Command, _ []string) {
cmd.SilenceUsage = true
}
opts := &cli.Options{}
subs := []subcommand{
sync{opts},
Expand Down
10 changes: 5 additions & 5 deletions internal/cmd/sync.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ type sync struct {

func (s sync) command() *cobra.Command {
cmd := &cobra.Command{
Use: "sync",
Use: "sync [project-dir]",
Short: "Synchronize to the upstream releases",
ValidArgs: []string{"REPOSITORY"},
Args: cobra.OnlyValidArgs,
Args: cobra.MaximumNArgs(1),
RunE: s.run,
}
return cmd
Expand All @@ -35,16 +35,16 @@ func (s sync) project(args []string) func() config.Project {
if err != nil {
wd = "/"
}
if len(args) > 0 {
wd = args[0]
}
if !path.IsAbs(configPath) {
configPath = path.Join(wd, configPath)
}
project := config.Project{
ConfigPath: configPath,
Path: wd,
}
if len(args) > 0 {
project.Path = args[0]
}
return project
}
}
2 changes: 1 addition & 1 deletion pkg/sync/create_pr.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (c createPR) open() error {
cl := github.NewClient(args...)
cl.ProjectDir = c.Path
buff, err := cl.Execute(c.Context)
defer c.Println("Github client:", buff)
defer c.Println("Github client:", string(buff))
Comment thread
cardil marked this conversation as resolved.
return errors.Wrap(err, ErrSyncFailed)
}

Expand Down
10 changes: 6 additions & 4 deletions pkg/sync/mirror_release.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,16 @@ func (r createNewRelease) checkoutAsNewRelease(upstreamBranch, downstreamBranch

type push struct {
state.State
branch string
branch string
skipDelete bool
}

func (p push) steps() []step {
return []step{
p.push,
p.delete,
st := []step{p.push}
if !p.skipDelete {
st = append(st, p.delete)
}
return st
}

func (p push) push() error {
Expand Down
2 changes: 1 addition & 1 deletion pkg/sync/resync_releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ func (r resyncRelease) run() error {
return nil
}
err = multiStep{
r.pushBranch(syncBranch),
r.pushBranch(syncBranch, skipDeleteOnPush),
r.createSyncReleasePR(downstreamBranch, upstreamBranch, syncBranch),
}.runSteps()
return
Expand Down
11 changes: 10 additions & 1 deletion pkg/sync/sync_release_next.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@ func (o Operation) syncReleaseNext() error {
})
}

func (o Operation) pushBranch(branch string) step {
type pushOpt func(*push)

func skipDeleteOnPush(p *push) {
p.skipDelete = true
}

func (o Operation) pushBranch(branch string, opts ...pushOpt) step {
return func() error {
p := push{
State: o.State,
branch: branch,
}
for _, opt := range opts {
opt(&p)
}
return runSteps(p.steps())
}
}
Expand Down
Loading