Skip to content

Commit

Permalink
🐛 support updating all providers in versions helper (#1936)
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
arlimus authored Sep 26, 2023
1 parent 20a3904 commit d4081a7
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions providers-sdk/v1/util/version/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"os/exec"
"path/filepath"
"regexp"
"strconv"
"strings"
"time"

Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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{
Expand Down

0 comments on commit d4081a7

Please sign in to comment.