From 6b3e7e76312a2772be728c1fb9735170facbd163 Mon Sep 17 00:00:00 2001 From: dannylongeuay Date: Wed, 1 May 2024 14:24:03 -0700 Subject: [PATCH 1/2] feat(*): :sparkles: add log order configuration option --- README.md | 28 ++++++++++++++++++++++++++++ go.mod | 2 +- go.sum | 4 ++-- pkg/provider/gitlab.go | 1 + 4 files changed, 32 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index a451d67..99297b3 100644 --- a/README.md +++ b/README.md @@ -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) diff --git a/go.mod b/go.mod index 6193601..5e35aa8 100644 --- a/go.mod +++ b/go.mod @@ -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 diff --git a/go.sum b/go.sum index d724882..caeaabd 100644 --- a/go.sum +++ b/go.sum @@ -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= diff --git a/pkg/provider/gitlab.go b/pkg/provider/gitlab.go index e422abf..841deaa 100644 --- a/pkg/provider/gitlab.go +++ b/pkg/provider/gitlab.go @@ -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()) From 4fcc6253473bada4ddb53b226f8cf39d0428956a Mon Sep 17 00:00:00 2001 From: dannylongeuay Date: Wed, 1 May 2024 14:26:17 -0700 Subject: [PATCH 2/2] docs(README): :pencil: style requirements --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 99297b3..a280e81 100644 --- a/README.md +++ b/README.md @@ -20,9 +20,9 @@ The GitLab provider for [go-semantic-release](https://github.com/go-semantic-rel ### 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) +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