Skip to content

feat: Allow to customize temporary working branch created by Updatecli #5589

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

Merged
merged 8 commits into from
Jul 13, 2025

Conversation

olblak
Copy link
Member

@olblak olblak commented Jul 9, 2025

Fix #1399

Today temporary working branch looks like

updatecli_<the targeted branch>_<pipelineid>

This pullrequest allows to override the default separator from _ to whatever defined by the parameter workingbranchseparator
The prefix updatecli_ can also be replace by setting the parameter workingbranchprefix:

For example

  scms:
    default:
      kind: github
      spec:
        branch: "{{ .scm.branch }}"
        email: "{{ .scm.email }}"
        owner: "{{ .scm.owner }}"
        repository: "{{ .scm.repository }}"
        token: '{{ requiredEnv "GITHUB_TOKEN" }}'
        user: "{{ .scm.user }}"
        username: '{{ requiredEnv "GITHUB_ACTOR" }}'
        workingbranchprefix: "deps"
        workingbranchseparator: '/' 
      disabled: false

Test

Test manually

Additional Information

Checklist

  • I have updated the documentation via pull request in website repository.

Tradeoff

I see two risks here that are not Updatecli related.

  1. Reusing an existing branch not created by Updatecli and resetting its content
  2. Failing to create a branch. For example, Updatecli won't be able to create the branch deps/main/bumpversion if there is already a branch named deps which It's a git limitation

Potential improvement

@olblak olblak added enhancement New feature or request scm-github SCM of type GiHhub scm-git SCM of kind "Git" scm-gittea scm-gitlab scm-stash scm-bitbucket All things related to the bitbucket integration labels Jul 9, 2025
@olblak olblak requested a review from Copilot July 10, 2025 05:12
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds support for customizing the prefix and separator used when Updatecli creates temporary working branches. Key changes include:

  • Introduce workingBranchPrefix and workingBranchSeparator parameters in SCM plugin specs and propagate them through each provider implementation.
  • Update the branch sanitization logic to trim leading separators and adjust replacement behavior.
  • Add an example to the Venom integration test configuration showing how to set the new parameters.

Reviewed Changes

Copilot reviewed 14 out of 14 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
updatecli/updatecli.d/venom.yaml Example test updated with workingbranchprefix and workingbranchseparator
pkg/plugins/utils/gitgeneric/main.go Trim leading separators and adjust replacement array
pkg/plugins/scms/stash/scm.go Use strings.Join with custom prefix/separator in GetBranches
pkg/plugins/scms/stash/main.go Add WorkingBranchPrefix/Separator fields and initialization
pkg/plugins/scms/gitlab/scm.go Use strings.Join with custom prefix/separator in GetBranches
pkg/plugins/scms/gitlab/main.go Add WorkingBranchPrefix/Separator fields and initialization
pkg/plugins/scms/github/scm.go Use strings.Join with custom prefix/separator in GetBranches
pkg/plugins/scms/github/main.go Add WorkingBranchPrefix/Separator fields and initialization
pkg/plugins/scms/gitea/scm.go Use strings.Join with custom prefix/separator in GetBranches
pkg/plugins/scms/gitea/main.go Add WorkingBranchPrefix/Separator fields and initialization
pkg/plugins/scms/git/scm.go Use strings.Join with custom prefix/separator in GetBranches
pkg/plugins/scms/git/main.go Add WorkingBranchPrefix/Separator fields and initialization
pkg/plugins/scms/bitbucket/scm.go Use strings.Join with custom prefix/separator in GetBranches
pkg/plugins/scms/bitbucket/main.go Add WorkingBranchPrefix/Separator fields and initialization
Comments suppressed due to low confidence (3)

updatecli/updatecli.d/venom.yaml:38

  • [nitpick] The change to the version filter pattern (<1) in the Venom test appears unrelated to branch customization. Consider removing or documenting it separately to keep the test focused.
        pattern: "<1"

pkg/plugins/scms/bitbucket/main.go:193

  • Typo in variable name workingBranchhPrefix (extra 'h'). Rename to workingBranchPrefix for clarity and consistency.
	workingBranchhPrefix := "updatecli"

pkg/plugins/utils/gitgeneric/main.go:698

  • There are no unit tests covering custom separator trimming. Add tests for SanitizeBranchName, especially cases with leading slashes and varied separators.
	branch = strings.TrimPrefix(branch, "/")

@olblak olblak merged commit ca9e27f into updatecli:main Jul 13, 2025
6 checks passed
@olblak olblak deleted the issue/1399 branch July 13, 2025 06:25
@olblak olblak mentioned this pull request Jul 22, 2025
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request scm-bitbucket All things related to the bitbucket integration scm-git SCM of kind "Git" scm-github SCM of type GiHhub scm-gitlab scm-gittea scm-stash
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature Request: Allow configuration of commit branch
1 participant