From 5f027145febda83ddea1c6f97d2934459b5f9ca3 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Fri, 22 Sep 2023 18:18:55 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=8C=88=20nicer=20commit=20titles=20for=20?= =?UTF-8?q?version=20bumps?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Dominik Richter --- providers-sdk/v1/util/version/version.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/providers-sdk/v1/util/version/version.go b/providers-sdk/v1/util/version/version.go index c64623ceb7..e566ed198c 100644 --- a/providers-sdk/v1/util/version/version.go +++ b/providers-sdk/v1/util/version/version.go @@ -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) { @@ -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 { @@ -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()) @@ -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)