diff --git a/.editorconfig b/.editorconfig index 5cfefce..36d86fc 100644 --- a/.editorconfig +++ b/.editorconfig @@ -1,9 +1,8 @@ root = true -[*] +[*.go] charset = utf-8 end_of_line = lf -indent_size = 2 indent_style = tab insert_final_newline = true trim_trailing_whitespace = true diff --git a/CHANGELOG.md b/CHANGELOG.md index 3a69373..e1b547e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -21,6 +21,10 @@ Exceptions are acceptable depending on the circumstances (critical bug fixes tha - exit with error code when batch processing fails - automatically try all authentication methods for Git cloning and pushing +### Fixed + +- fixed incorrect logic in the project processing phase that causes the program to quit early + ## [2.9.1] - 2024-01-18 ### Fixed diff --git a/cmd/autobump/git.go b/cmd/autobump/git.go index 729b7dc..a27ec4c 100644 --- a/cmd/autobump/git.go +++ b/cmd/autobump/git.go @@ -182,15 +182,6 @@ func getAuthMethods( }) } - // CI job token - if globalConfig.GitLabCIJobToken != "" { - log.Infof("Using GitLab CI job token to authenticate") - authMethods = append(authMethods, &http.BasicAuth{ - Username: "gitlab-ci-token", - Password: globalConfig.GitLabCIJobToken, - }) - } - // GitLab personal access token if globalConfig.GitLabAccessToken != "" { log.Infof("Using GitLab access token to authenticate") @@ -199,6 +190,15 @@ func getAuthMethods( Password: globalConfig.GitLabAccessToken, }) } + + // CI job token + if globalConfig.GitLabCIJobToken != "" { + log.Infof("Using GitLab CI job token to authenticate") + authMethods = append(authMethods, &http.BasicAuth{ + Username: "gitlab-ci-token", + Password: globalConfig.GitLabCIJobToken, + }) + } break case "AzureDevOps": log.Infof("Using Azure DevOps access token to authenticate") diff --git a/cmd/autobump/project.go b/cmd/autobump/project.go index 5e1e865..595eb22 100644 --- a/cmd/autobump/project.go +++ b/cmd/autobump/project.go @@ -125,6 +125,7 @@ func processRepo(globalConfig *GlobalConfig, projectConfig *ProjectConfig) error } // try each authentication method + clonedSuccessfully := false for _, auth := range authMethods { cloneOptions.Auth = auth _, err = git.PlainClone(tmpDir, false, cloneOptions) @@ -133,11 +134,15 @@ func processRepo(globalConfig *GlobalConfig, projectConfig *ProjectConfig) error if err == nil { log.Infof("Successfully cloned %s", projectConfig.Path) projectConfig.Path = tmpDir - return nil + clonedSuccessfully = true + break } } - return err + // if all authentication methods failed, return the last error + if !clonedSuccessfully { + return err + } } projectPath := projectConfig.Path