Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 support updating all providers in versions helper #1936

Merged
merged 1 commit into from
Sep 26, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading