Skip to content

Commit

Permalink
Unique branch name, brute force skip if contents already there (#25)
Browse files Browse the repository at this point in the history
  • Loading branch information
Rick Ducott authored Feb 27, 2019
1 parent c8c0ef7 commit 594125e
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docsutils/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import (
"github.com/solo-io/go-utils/errors"
"github.com/solo-io/go-utils/githubutils"
"github.com/solo-io/go-utils/logger"
"github.com/solo-io/go-utils/testutils"
"github.com/spf13/afero"
"os"
"os/exec"
"path/filepath"
"strings"
)

const (
Expand Down Expand Up @@ -65,7 +67,7 @@ func CreateDocsPR(owner, repo, product, project, tag string, paths ...string) er
return err
}

branch := repo + "-docs-" + tag
branch := repo + "-docs-" + tag + testutils.RandString(4)
err = gitCheckoutNewBranch(branch)
if err != nil {
return errors.Wrapf(err, "Error checking out branch")
Expand Down Expand Up @@ -142,6 +144,11 @@ func updateChangelogFile(fs afero.Fs, product, project, markdown, tag string) er
if err != nil {
return err
}
oldContents := string(bytes)
if strings.Contains(oldContents, newContents) {
// re-release, don't do anything
return nil
}
newContents = newContents + string(bytes)
}
return afero.WriteFile(fs, changelogFile, []byte(newContents), 0700)
Expand Down

0 comments on commit 594125e

Please sign in to comment.