From 1b1034442cce1363af48cf48694aa16a5ab45dac Mon Sep 17 00:00:00 2001 From: Katrina Verey Date: Wed, 25 Aug 2021 13:38:52 -0700 Subject: [PATCH] Enable real release after dry run without manual cleanup --- cmd/gorepomod/internal/git/runner.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmd/gorepomod/internal/git/runner.go b/cmd/gorepomod/internal/git/runner.go index c30a8a852..60ff9ea2b 100644 --- a/cmd/gorepomod/internal/git/runner.go +++ b/cmd/gorepomod/internal/git/runner.go @@ -278,12 +278,13 @@ func (gr *Runner) CheckoutReleaseBranch( return nil } gr.comment("creating branch") - // The branch doesn't exist. Create it. - out, err := gr.run(noHarmDone, "checkout", "-b", branch) + // The branch doesn't exist remotely. Create or reset it locally. + out, err := gr.run(noHarmDone, "checkout", "-B", branch) if err != nil { return err } - if !strings.Contains(out, "Switched to a new branch ") { + // Expected strings: "Switched to a new branch" or "Switched to and reset branch" + if !strings.Contains(out, "Switched to") { return fmt.Errorf("unexpected branch creation output: %q", out) } return nil