From 2ef71f3d585039e641e16a8392ef04c8a42fda79 Mon Sep 17 00:00:00 2001 From: Dominik Richter Date: Tue, 26 Sep 2023 01:14:54 -0700 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20support=20updating=20all=20provi?= =?UTF-8?q?ders=20in=20versions=20helper?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. super long branch names break git, shorten them 2. we still commit everything in the title, but this will move to the body next, as the title is getting out of hand 3. give progress indication for the "git add" step because go-git is surprisingly slow to process this Signed-off-by: Dominik Richter --- providers-sdk/v1/util/version/version.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/providers-sdk/v1/util/version/version.go b/providers-sdk/v1/util/version/version.go index 768717411b..0fce73c81b 100644 --- a/providers-sdk/v1/util/version/version.go +++ b/providers-sdk/v1/util/version/version.go @@ -11,6 +11,7 @@ import ( "os/exec" "path/filepath" "regexp" + "strconv" "strings" "time" @@ -108,7 +109,12 @@ func (confs updateConfs) commitTitle() string { } func (confs updateConfs) branchName() string { - return "version/" + strings.Join(confs.titles(), "+") + if len(confs) <= 5 { + return "version/" + strings.Join(confs.titles(), "+") + } + + now := time.Now() + return "versions/" + strconv.Itoa(len(confs)) + "-provider-updates-" + now.Format(time.DateOnly) } func getVersion(content string) string { @@ -291,15 +297,18 @@ func commitChanges(confs updateConfs) error { return errors.New("failed to git checkout+create " + branchName + ": " + err.Error()) } + fmt.Print("Adding providers to commit ") for i := range confs { _, err = worktree.Add(confs[i].path) if err != nil { return errors.New("failed to git add: " + err.Error()) } + fmt.Print(".") } + fmt.Println(" done") - body := "\n\nThis release was created by cnquery's provider versioning bot.\n" + - "You can find me under: `providers-sdk/v1/util/version`." + body := "\n\nThis release was created by cnquery's provider versioning bot.\n\n" + + "You can find me under: `providers-sdk/v1/util/version`.\n" commit, err := worktree.Commit(confs.commitTitle()+body, &git.CommitOptions{ Author: &object.Signature{