Skip to content

Commit

Permalink
🌈 nicer commit titles for version bumps
Browse files Browse the repository at this point in the history
Signed-off-by: Dominik Richter <[email protected]>
  • Loading branch information
arlimus committed Sep 23, 2023
1 parent b63091c commit 5f02714
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions providers-sdk/v1/util/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,11 @@ type providerConf struct {
}

func (p providerConf) commitTitle() string {
return p.name + "-" + p.version
return "🎉 " + p.name + "-" + p.version
}

func (p providerConf) branchName() string {
return "version/" + p.name + "-" + p.version
}

func getConfig(providerPath string) (*providerConf, error) {
Expand Down Expand Up @@ -154,8 +158,7 @@ func tryUpdate(repoPath string, conf *providerConf) (bool, error) {
log.Info().Str("path", conf.path).Msg("updated config")

if doCommit {
branchName := "version/" + conf.commitTitle()
if err = commitChanges(branchName, conf); err != nil {
if err = commitChanges(conf); err != nil {
log.Error().Err(err).Msg("failed to commit changes")
}
} else {
Expand Down Expand Up @@ -207,7 +210,7 @@ func bumpVersion(version string) (string, error) {
return versions[selection], nil
}

func commitChanges(branchName string, conf *providerConf) error {
func commitChanges(conf *providerConf) error {
repo, err := git.PlainOpen(".")
if err != nil {
return errors.New("failed to open git: " + err.Error())
Expand All @@ -223,6 +226,7 @@ func commitChanges(branchName string, conf *providerConf) error {
return errors.New("failed to get git tree: " + err.Error())
}

branchName := conf.branchName()
branchRef := plumbing.NewBranchReferenceName(branchName)

// Note: The branch may be local and thus won't be found in repo.Branch(branchName)
Expand Down

0 comments on commit 5f02714

Please sign in to comment.