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

feat(*): ✨ add log order configuration option #8

Merged
Show file tree
Hide file tree
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
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,38 @@
# :fox_face: provider-gitlab

[![CI](https://github.com/go-semantic-release/provider-gitlab/workflows/CI/badge.svg?branch=master)](https://github.com/go-semantic-release/provider-gitlab/actions?query=workflow%3ACI+branch%3Amaster)
[![Go Report Card](https://goreportcard.com/badge/github.com/go-semantic-release/provider-gitlab)](https://goreportcard.com/report/github.com/go-semantic-release/provider-gitlab)
[![PkgGoDev](https://pkg.go.dev/badge/github.com/go-semantic-release/provider-gitlab)](https://pkg.go.dev/github.com/go-semantic-release/provider-gitlab)

The GitLab provider for [go-semantic-release](https://github.com/go-semantic-release/semantic-release).

### Configuration

| Name | Default Value | Description |
| :----------------: | :--------------------------: | :---------------------------------------------------------------------: |
| gitlab_baseurl | CI_SERVER_URL | The base URL of the GitLab instance, including protocol and port. |
| gitlab_branch | CI_COMMIT_BRANCH | The commit branch name. |
| gitlab_projectid | CI_PROJECT_ID | The ID of the current project. |
| token | GITLAB_TOKEN -> CI_JOB_TOKEN | A token to authenticate with certain API endpoints. |
| git_path | CI_PROJECT_DIR | The full path the repository is cloned to, and where the job runs from. |
| strip_v_tag_prefix | false | Boolean to remove the `v` prefix from the tag. |
| log_order | dfs | The log order traversal algorithm. |

### Log Order Options

Requirements:
- `CI_JOB_TOKEN` must be used. [GitLab CI/CD job token](https://docs.gitlab.com/ee/ci/jobs/ci_job_token.html)
- `GIT_STRATEGY` must be set to `clone` or `fetch`. [Git strategy doc](https://docs.gitlab.com/ee/ci/runners/configure_runners.html#git-strategy)

log_order=dfs (Default) - Ordering by depth-first search in pre-order

log_order=dfs_post - Ordering by depth-first search in post-order (useful to traverse
history in chronological order)

log_order=bfs - Ordering by breadth-first search

log_order=ctime - Ordering by committer time (more compatible with `git log`)

## Licence

The [MIT License (MIT)](http://opensource.org/licenses/MIT)
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ go 1.22

require (
github.com/Masterminds/semver/v3 v3.2.1
github.com/go-semantic-release/provider-git v1.9.0
github.com/go-semantic-release/provider-git v1.12.0
github.com/go-semantic-release/semantic-release/v2 v2.30.0
github.com/stretchr/testify v1.8.4
github.com/xanzy/go-gitlab v0.97.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399 h1:eMj
github.com/go-git/go-git-fixtures/v4 v4.3.2-0.20231010084843-55a94097c399/go.mod h1:1OCfN199q1Jm3HZlxleg+Dw/mwps2Wbk9frAWm+4FII=
github.com/go-git/go-git/v5 v5.11.0 h1:XIZc1p+8YzypNr34itUfSvYJcv+eYdTnTvOZ2vD3cA4=
github.com/go-git/go-git/v5 v5.11.0/go.mod h1:6GFcX2P3NM7FPBfpePbpLd21XxsgdAt+lKqXmCUiUCY=
github.com/go-semantic-release/provider-git v1.9.0 h1:hWXYjKOgYAdzbBGlyxw5vWmQTguzV9aJUIOsTNeQKec=
github.com/go-semantic-release/provider-git v1.9.0/go.mod h1:FZDlaBWelBiNHq41yxdwxZRbyNURl4QJC6mPW/aetFo=
github.com/go-semantic-release/provider-git v1.12.0 h1:aqW1veKkZCSRdW74IuU2FQGksztFbEnqUDpTC5dTx1g=
github.com/go-semantic-release/provider-git v1.12.0/go.mod h1:xAmqmQTKrykaEGU8JqQfhojFwRz+2rZLqKT9jhjuCiI=
github.com/go-semantic-release/semantic-release/v2 v2.30.0 h1:k3CAF5vbUS7SL3sFs0vQpqaS/HqkP6NucG8C5b/k41U=
github.com/go-semantic-release/semantic-release/v2 v2.30.0/go.mod h1:UxEB9QiOEFFJKFTFim/eFfR7inU1uyJSxGzrcaKhXC0=
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
Expand Down
1 change: 1 addition & 0 deletions pkg/provider/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ func (repo *GitLabRepository) Init(config map[string]string) error {
err := repo.localRepo.Init(map[string]string{
"remote_name": "origin",
"git_path": os.Getenv("CI_PROJECT_DIR"),
"log_order": config["log_order"],
})
if err != nil {
return errors.New("failed to initialize local git repository: " + err.Error())
Expand Down
Loading