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

Simplify contrib/backport #27520

Merged
merged 4 commits into from
Oct 9, 2023
Merged

Simplify contrib/backport #27520

merged 4 commits into from
Oct 9, 2023

Conversation

silverwind
Copy link
Member

@silverwind silverwind commented Oct 8, 2023

This script was trying to be too smart, make it more straightforward and less error-prone so that i could be used by the backport bot too ideally.

  • Always delete the backport branch so that script is idempotent in this regard
  • Remove the push functionality, it's best done by the user because only they know the remote name
  • Remove reading docs/config.yaml, it no longer exists
  • Remove version detection, version is now a required argument
  • Remove opening the pull request with xdg-open, xdg-open is not portable
  • Remove continue from failed cherry pick. It's best to reset manually in this case
  • Clean up the console logging

Example run:

$ go run ./contrib/backport --version v1.21 27503
* Backporting 27503 to origin/release/v1.21 as backport-27503-v1.21
* `git fetch origin main`
* `git fetch origin release/v1.21`
* `git branch -D backport-27503-v1.21`
* `git checkout -b backport-27503-v1.21 origin/release/v1.21`
* Attempting git cherry-pick 08efeb5cdc22d21b5ef12cc540727594a22062d1
* Amending commit to prepend `Backport #27503` to body
Backport done! You can now push it with `git push yourremote backport-27503-v1.21`

- Always delete the backport branch so that script is idempotent in this
  regard
- Remove the push functionality, it's best done by the user
- Remove reading docs/config.yaml, it no longer exists
- Remove version detection, version is now a required argument
- Clean up the console logging
@GiteaBot GiteaBot added the lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. label Oct 8, 2023
@pull-request-size pull-request-size bot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Oct 8, 2023
@silverwind silverwind added the skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. label Oct 8, 2023
contrib/backport/backport.go Outdated Show resolved Hide resolved
@GiteaBot GiteaBot added lgtm/need 1 This PR needs approval from one additional maintainer to be merged. and removed lgtm/need 2 This PR needs two approvals by maintainers to be considered for merging. labels Oct 8, 2023
@delvh delvh added the topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile label Oct 8, 2023
Copy link
Contributor

@wxiaoguang wxiaoguang left a comment

Choose a reason for hiding this comment

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

Good to keep things simple

@GiteaBot GiteaBot added lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. and removed lgtm/need 1 This PR needs approval from one additional maintainer to be merged. labels Oct 9, 2023
@lunny lunny added the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Oct 9, 2023
@lunny lunny enabled auto-merge (squash) October 9, 2023 05:42
@lunny lunny merged commit 79e8865 into go-gitea:main Oct 9, 2023
25 checks passed
@GiteaBot GiteaBot added this to the 1.22.0 milestone Oct 9, 2023
@GiteaBot GiteaBot removed the reviewed/wait-merge This pull request is part of the merge queue. It will be merged soon. label Oct 9, 2023
@zeripath
Copy link
Contributor

zeripath commented Oct 9, 2023

This will break the --continue functionality.

@delvh
Copy link
Member

delvh commented Oct 9, 2023

Yes, that parameter was removed.
What exactly did that do?

@silverwind silverwind deleted the backport-cleanup branch October 9, 2023 09:10
@silverwind
Copy link
Member Author

silverwind commented Oct 9, 2023

It did look for a aborted cherry-pick, but I think given that the script now deletes the backport branch every time, it likely will never encounter the situation again. I think it's good that this script becomes idempotent (it isn't so far because it stays on the backport branch after execution, but that's kind of a necessity because we now require the user to push).

Also, the command logging and error printing should be improved with a single shell execution wrapper function.

@silverwind
Copy link
Member Author

The goal is to get this script into a state where the backporter bot can use it, so we can replace most of this code.

@zeripath
Copy link
Contributor

zeripath commented Oct 9, 2023

It already was in a state that the backporter tool could use.

By removing the --continue option you've made it impossible to use the script to help create backports when there is a conflict.

--continue simply allowed you to fix the conflicts and then restart the process.

Instead of simply removing things you should have just read or improved the documentation explaining what it was doing.

@silverwind
Copy link
Member Author

I don't mind if you want to restore, but I thought this script should be idempotent and a --continue did not fit into the concept. The bot would only do clean checkouts and if there is a merge conflict, it has to be resolved manually in any case.

zjjhot added a commit to zjjhot/gitea that referenced this pull request Oct 10, 2023
* giteaofficial/main:
  Respect SSH.KeygenPath option when calculating ssh key fingerprints (go-gitea#27536)
  Remove max-width and add hide text overflow (go-gitea#27359)
  Fix `environment-to-ini` inherited key bug (go-gitea#27543)
  Improve docs about register/run as a service (go-gitea#27461)
  api: GetPullRequestCommits: return file list (go-gitea#27483)
  switch to using official AWS step in release nightly (go-gitea#27532)
  Improve file history UI and fix URL escaping bug (go-gitea#27531)
  Improve dropdown's behavior when there is a search input in menu (go-gitea#27526)
  Simplify `contrib/backport` (go-gitea#27520)
  Add docs section for sub-paths with the container registry (go-gitea#27505)
  Document our new labeling strategy (go-gitea#27523)
  [skip ci] Updated translations via Crowdin
  Restore warning commit status (go-gitea#27504)
  Update labeler to match new labeling system (go-gitea#27525)
  Apply to become a maintainer (go-gitea#27522)
  Remove unnecessary desc for openssh key cron task (go-gitea#27515)
  Tweak labeler config (go-gitea#27502)
  Add hover background to wiki list page (go-gitea#27507)
  [FIX] missing ctx in new_form (go-gitea#27514)
@zeripath
Copy link
Contributor

It cannot be idempotent. It was not intended to idempotent it was supposed to assist with performing backports especially when those backports failed.

@zeripath
Copy link
Contributor

Your simplification has now broken the specific help information that gitea-backport tells maintainers.

e.g. #27511 (comment)

It said how to use the script, if it wasn't clear you should have improved the message instead of simply destroying things.

@silverwind
Copy link
Member Author

silverwind commented Oct 10, 2023

Right, so let's restore --continue. We also need to adjust the message for --backport-branch which no longer has a default, I'd make that part of the argv, e.g. go run ./contrib/backport 1.21 27511 and include a line for the push.

zeripath added a commit to zeripath/gitea that referenced this pull request Oct 10, 2023
This reverts go-gitea#27520 commit 79e8865
which breaks `--continue` functionality.
lunny pushed a commit that referenced this pull request Oct 11, 2023
This reverts #27520 commit 79e8865
which breaks `--continue` functionality.
zjjhot added a commit to zjjhot/gitea that referenced this pull request Oct 12, 2023
* giteaofficial/main:
  [skip ci] Updated translations via Crowdin
  Keep filter when showing unfiltered results on explore page (go-gitea#27192)
  Don't show Link to TOTP if not set up (go-gitea#27585)
  Fix data-race bug when accessing task.LastRun (go-gitea#27584)
  Fix template bug (go-gitea#27581)
  Replace ajax with fetch, improve image diff (go-gitea#27267)
  Replace assert.Fail with assert.FailNow (go-gitea#27578)
  Fix the robots.txt path
  show manual cron run's last time (go-gitea#27544)
  fully replace drone with actions (go-gitea#27556)
  Revert "Simplify `contrib/backport` (go-gitea#27520)" (go-gitea#27566)
  Align ISSUE_TEMPLATE with the new label system (go-gitea#27573)
  Penultimate round of `db.DefaultContext` refactor (go-gitea#27414)
@go-gitea go-gitea locked as resolved and limited conversation to collaborators Jan 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
lgtm/done This PR has enough approvals to get merged. There are no important open reservations anymore. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. skip-changelog This PR is irrelevant for the (next) changelog, for example bug fixes for unreleased features. topic/build PR changes how Gitea is built, i.e. regarding Docker or the Makefile
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants