Skip to content

Commit

Permalink
Merge pull request #41 from rios0rios0/fix/project
Browse files Browse the repository at this point in the history
fix(project): fixed project processing and cloning logic
  • Loading branch information
rios0rios0 authored Jan 23, 2024
2 parents e3e5f29 + 79d8f0f commit 85a6c71
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 13 deletions.
3 changes: 1 addition & 2 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 9 additions & 9 deletions cmd/autobump/git.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down
9 changes: 7 additions & 2 deletions cmd/autobump/project.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down

0 comments on commit 85a6c71

Please sign in to comment.