Git Product home page Git Product logo

Comments (15)

yardenshoham avatar yardenshoham commented on July 17, 2024

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)

from gitea-backporter.

silverwind avatar silverwind commented on July 17, 2024

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"
}

from gitea-backporter.

silverwind avatar silverwind commented on July 17, 2024

go-gitea/gitea#27501 was also clean cherry-pick which I backported with this bash script now.

from gitea-backporter.

silverwind avatar silverwind commented on July 17, 2024

Contributed the script in go-gitea/gitea#27519.

from gitea-backporter.

yardenshoham avatar yardenshoham commented on July 17, 2024

How it backports

export const cherryPickPr = async (
commitHash: string,
prNumber: number,
giteaMajorMinorVersion: string,
): Promise<boolean> => {
// fetch the upstream main branch
await cmd.run("git", {
cwd: "gitea",
args: ["fetch", "upstream", "main"],
});
// fetch the upstream release branch
await cmd.run("git", {
cwd: "gitea",
args: ["fetch", "upstream", `release/v${giteaMajorMinorVersion}`],
});
// create the backport branch from the upstream release branch
await cmd.run("git", {
cwd: "gitea",
args: [
"checkout",
`upstream/release/v${giteaMajorMinorVersion}`,
"-b",
getPrBranchName(prNumber, giteaMajorMinorVersion),
],
});
// cherry-pick the PR
const cherryPickStatus = await cmd.run("git", {
cwd: "gitea",
args: ["cherry-pick", commitHash],
});
if (!cherryPickStatus.success) {
await cmd.run("git", {
cwd: "gitea",
args: ["cherry-pick", "--abort"],
});
return false;
}
// push the branch to the fork
await cmd.run("git", {
cwd: "gitea",
args: ["push", "origin", getPrBranchName(prNumber, giteaMajorMinorVersion)],
});
return true;
};

from gitea-backporter.

silverwind avatar silverwind commented on July 17, 2024

Why does the log not show any error?

from gitea-backporter.

silverwind avatar silverwind commented on July 17, 2024

Maybe this if branch should log or throw the error?

if (!cherryPickStatus.success) {
await cmd.run("git", {
cwd: "gitea",
args: ["cherry-pick", "--abort"],
});
return false;
}

I would make it throw an error on any command failure, much better than returning false and not knowing why it failed.

from gitea-backporter.

silverwind avatar silverwind commented on July 17, 2024

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: go-gitea/gitea#27520 will make that script much less error-prone.

from gitea-backporter.

silverwind avatar silverwind commented on July 17, 2024

After go-gitea/gitea#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.

from gitea-backporter.

silverwind avatar silverwind commented on July 17, 2024

go-gitea/gitea#27752 likely another case of a 1-line change not being backported.

from gitea-backporter.

silverwind avatar silverwind commented on July 17, 2024

Another case: go-gitea/gitea#29106 (comment)

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.

from gitea-backporter.

yardenshoham avatar yardenshoham commented on July 17, 2024

Sure, send a PR, I will review it

from gitea-backporter.

silverwind avatar silverwind commented on July 17, 2024

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.

from gitea-backporter.

silverwind avatar silverwind commented on July 17, 2024

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.

from gitea-backporter.

yardenshoham avatar yardenshoham commented on July 17, 2024

Sure, send a PR, I will review it

from gitea-backporter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.