Open silverwind opened 9 months ago
Logs:
2023-10-08T03:13:30.426 app[148ed433fe9d08] ams [info] Synced PR #27503
2023-10-08T03:13:35.518 app[148ed433fe9d08] ams [info] Set commit status in "Fix mermaid flowchart margin issue" (#27503)
2023-10-08T03:20:16.010 app[148ed433fe9d08] ams [info] Parsing #27503
2023-10-08T03:20:16.125 app[148ed433fe9d08] ams [info] Locked issue #25798
2023-10-08T03:20:16.389 app[148ed433fe9d08] ams [info] Set milestone 1.22 for PR #27503
2023-10-08T03:20:16.575 app[148ed433fe9d08] ams [info] Cherry-picking #27503
2023-10-08T03:20:17.338 app[148ed433fe9d08] ams [info] Added comment to #27503
2023-10-08T03:20:18.328 app[148ed433fe9d08] ams [info] Parsing #27503
2023-10-08T03:20:18.760 app[148ed433fe9d08] ams [info] Cherry-picking #27503
2023-10-08T03:20:19.645 app[148ed433fe9d08] ams [info] Added comment to #27503
2023-10-08T03:20:28.105 app[148ed433fe9d08] ams [info] Removed reviewed/wait-merge from "Fix mermaid flowchart margin issue" (#27503)
Is it using ./contrib/backport
? When I try that, it fails:
$ go run ./contrib/backport --version v1.21 --no-push 27503
* Backporting 27503 to origin/release/v1.21 as backport-27503-v1.21
* `git fetch origin main`
* `git fetch origin release/v1.21`
* Current branch is main
* Branch backport-27503-v1.21 already exists. Checking it out...
* Attempting git cherry-pick 08efeb5cdc22d21b5ef12cc540727594a22062d1
git cherry-pick 08efeb5cdc22d21b5ef12cc540727594a22062d1 failed:
On branch backport-27503-v1.21
Your branch and 'origin/release/v1.21' have diverged,
and have 137 and 73 different commits each, respectively.
You are currently cherry-picking commit 08efeb5cdc.
(all conflicts fixed: run "git cherry-pick --continue")
(use "git cherry-pick --skip" to skip this patch)
(use "git cherry-pick --abort" to cancel the cherry-pick operation)
nothing to commit (use -u to show untracked files)
Unable to backport: git cherry-pick 08efeb5cdc22d21b5ef12cc540727594a22062d1 failed: exit status 1
I've now made a simple bash script that works, but it also does not amend either:
backport() {
if [ $# -eq 0 ]; then; echo "backport PR VER"; return 1; fi
PR="$1"
VER="$2"
git checkout "release/v$VER"
git reset --hard "origin/release/v$VER"
git branch -D "backport-$PR-$VER"
git checkout -b "backport-$PR-$VER"
HASH="$(curl -sH "X-GitHub-Api-Version: 2022-11-28" "https://api.github.com/repos/go-gitea/gitea/pulls/$PR" | jq -r .merge_commit_sha)"
git cherry-pick "$HASH"
}
https://github.com/go-gitea/gitea/pull/27501 was also clean cherry-pick which I backported with this bash script now.
Contributed the script in https://github.com/go-gitea/gitea/pull/27519.
Why does the log not show any error?
Maybe this if
branch should log or throw the error?
I would make it throw an error on any command failure, much better than returning false
and not knowing why it failed.
Overall I think the bot should make use of https://github.com/go-gitea/gitea/tree/main/contrib/backport, so that the backporting mechanism can be tested locally in the repo as well. Likely that script needs a few adjustments as mention in the PR.
Edit: https://github.com/go-gitea/gitea/pull/27520 will make that script much less error-prone.
After https://github.com/go-gitea/gitea/pull/27520, we could make the backporter use this script to cherry-pick. Imho, is is much better to having something that can be ran and debugged locally and we will only have one way to apply backports instead of two.
https://github.com/go-gitea/gitea/pull/27752 likely another case of a 1-line change not being backported.
Another case: https://github.com/go-gitea/gitea/pull/29106#issuecomment-1935299040
This is what I did locally and it worked fine:
git checkout release/v1.21
git reset --hard origin/release/v1.21
git checkout -b backport-29106-29111
git cherry-pick 9c39f85
git cherry-pick c7a21cb
git push silverwind backport-29106-29111
Maybe we could add some debug info in a <details>
block in the bot comment to show what it did and where it failed to get to the root of this problem.
Sure, send a PR, I will review it
I think the bot currently can not successfully do any backport onto release/v1.21
. I assume once we cut release/v1.22
it will be able to again for unknown reason. I think I've seen this pattern already in the last two releases. At some point in the target branch history, it just can't do it anymore.
So I think I will write a new backport script in bash, commit it to repo and we let the bot use it. Much easier to debug than running the commands individually through deno and we show the exact output from the script as well in the bot message when it fails.
Likely also remove ./contrib/backport
as no one is really using it and it has several shortcomings.
Sure, send a PR, I will review it
https://github.com/go-gitea/gitea/pull/27503 is a clean cherry-pick against both 1.21 and 1.20, but the bot failed for unknown reasons. Here's how I do it, maybe the bot tries it differently?