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

Allow to recreate working branch based on their "base" branch #2018

Merged
merged 12 commits into from
Apr 3, 2024

Conversation

olblak
Copy link
Member

@olblak olblak commented Mar 29, 2024

Fix #1747

This pullrequest allows to detect if git working branch used by Updatecli diverged from its base one.
If it diverged then Updatecli can recreate the working branch and reapply pipelines.
If a branch is recreated then Updatecli execute a git push --force and refresh the pullrequest description

Please note that only GitHub plugin allows to modify a pullrequest body. Gitlab, Gitea, and stash requires additional work which need to be scheduled.

By default, Updatecli won't try to converge the working branch and the base branch. To enable it, we need to add the parameter force like in the following example

name: "Bump certmanager"
pipelineid: b728453682b0c54e91c5414e45b3f201f4c7d9a3a50c0167d589dc705885407c

scms:
  default: 
    kind: github
    spec:
      owner: olblak
      repository: k8s-lab
      username: '{{ requiredEnv "UPDATECLI_GITHUB_ACTOR" }}'
      token: '{{ requiredEnv "UPDATECLI_GITHUB_TOKEN" }}'
      branch: main
      user: olblakbot
      email: bot@olblak.com
      force: true

Test

It's hard to have automated test for this pullrequest so instead I am going with manual test.

Additional Information

Tradeoff

Potential improvement

Improve the Scm Gitlab, Gitea, Stash to allow customizing the pull request body. This will more than likely require a rewrite of those plugins as I currently rely on the go-scm library

olblak and others added 6 commits March 28, 2024 19:32
* Push operation should return a bool that indicate if a push --force
  allowed and needed
* Add mechanism to detect if the Updatelci working branch diverged from
  the based on

Signed-off-by: Olblak <me@olblak.com>
* Align the push function with the one from gitgeneric
* Checkout function allow to reset the branch if --force is set to true
* Fix a param inheritance issue gs.Submodules = childGHSpec.Submodules
* Add a boolean to indicate if a action need to reset the description

Signed-off-by: Olblak <me@olblak.com>
Signed-off-by: Olblak <me@olblak.com>
must be reset after git push --force

Signed-off-by: Olblak <me@olblak.com>
@olblak
Copy link
Member Author

olblak commented Mar 29, 2024

Here is a PR that I used to test the force push and pullrequet description update

olblak/k8s-lab#49

@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 core All things related to Updatecli core engine labels Mar 29, 2024
@olblak olblak added this to the 0.75.0 milestone Mar 29, 2024
@olblak olblak self-assigned this Mar 29, 2024
Signed-off-by: Olblak <me@olblak.com>
@olblak olblak removed this from the 0.75.0 milestone Mar 29, 2024
@olblak olblak merged commit ff6a84f into updatecli:main Apr 3, 2024
6 checks passed
@olblak olblak deleted the issue/1747 branch April 3, 2024 18:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
core All things related to Updatecli core engine enhancement New feature or request 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.

scm working branch diverged from target branch
1 participant