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

fix: abort conflicting cherry-pick before starting new one #146

Merged
merged 1 commit into from
Oct 28, 2024

Conversation

lampajr
Copy link
Member

@lampajr lampajr commented Oct 28, 2024

Thank you for submitting this pull request

fixes #144

Description

When the process should backport the same change to multiple target branches, before checking out the next target branch:

  1. Checks whether the current local repository contains any conflict
  2. If yes, it means a previous cherry-pick failed, therefore it aborts the cherry-pick with cherry-pick --abort
  3. Checkout the new target branch

How Has This Been Tested?

Manually tested running:

node dist/cli/index.js -pr https://github.com/lampajr/backporting-example/pull/63 --no-squash -tb "prod,develop" -d -f /tmp/bp --strategy "ort" --strategy-option "find-renames"

The develop backport should work, the prod one shouldn't, here the output:

[WARN ] Trying to backport an open pull request
[DEBUG] [prod] Cloning repo..
[INFO ] [prod] Cloning repository https://github.com/lampajr/backporting-example.git to /tmp/bp
[DEBUG] [prod] Creating local branch..
[INFO ] [prod] Creating branch bp-prod-0404fb9-11da4e3
[DEBUG] [prod] Fetching pull request remote..
[INFO ] [prod] Fetching origin pull/63/head:pr/63
[DEBUG] [prod] Cherry picking commits..
[INFO ] [prod] Cherry picking 0404fb922ab75c3a8aecad5c97d9af388df04695
[DEBUG] [prod] Cherry picking command git cherry-pick,-m,1,--strategy=ort,--strategy-option=find-renames,0404fb922ab75c3a8aecad5c97d9af388df04695
[INFO ] [prod] Cherry picking 11da4e38aa3e577ffde6d546f1c52e53b04d3151
[DEBUG] [prod] Cherry picking command git cherry-pick,-m,1,--strategy=ort,--strategy-option=find-renames,11da4e38aa3e577ffde6d546f1c52e53b04d3151
[ERROR] [prod] Something went wrong backporting to prod: Error: Error: Auto-merging file2.txt
CONFLICT (content): Merge conflict in file2.txt
error: could not apply 11da4e3... Update file2.txt
hint: After resolving the conflicts, mark them with
hint: "git add/rm <pathspec>", then run
hint: "git cherry-pick --continue".
hint: You can instead skip this commit with "git cherry-pick --skip".
hint: To abort and get back to the state before "git cherry-pick",
hint: run "git cherry-pick --abort".
hint: Disable this message with "git config advice.mergeConflict false"

Showing git diff:
diff --cc file2.txt
index 93e9c13,bf04643..0000000
--- a/file2.txt
+++ b/file2.txt
@@@ -2,5 -2,4 +2,9 @@@ feature2: update
  test2: updated
  feature2: updated x 2
  feature1: updated
++<<<<<<< HEAD
 +force conflict
 +force conflict x2
++=======
+ multiple commit change
++>>>>>>> 11da4e3 (Update file2.txt)

[DEBUG] [develop] Cloning repo..
[INFO ] [develop] Cloning repository https://github.com/lampajr/backporting-example.git to /tmp/bp
[INFO ] [develop] Folder /tmp/bp already exist. Won't clone
[DEBUG] [develop] Found conflicts in branch bp-prod-0404fb9-11da4e3
[WARN ] [develop] Found previously failed cherry-pick, aborting it
[INFO ] [develop] Checking out branch develop
[DEBUG] [develop] Creating local branch..
[INFO ] [develop] Creating branch bp-develop-0404fb9-11da4e3
[DEBUG] [develop] Fetching pull request remote..
[INFO ] [develop] Fetching origin pull/63/head:pr/63
[DEBUG] [develop] Cherry picking commits..
[INFO ] [develop] Cherry picking 0404fb922ab75c3a8aecad5c97d9af388df04695
[DEBUG] [develop] Cherry picking command git cherry-pick,-m,1,--strategy=ort,--strategy-option=find-renames,0404fb922ab75c3a8aecad5c97d9af388df04695
[INFO ] [develop] Cherry picking 11da4e38aa3e577ffde6d546f1c52e53b04d3151
[DEBUG] [develop] Cherry picking command git cherry-pick,-m,1,--strategy=ort,--strategy-option=find-renames,11da4e38aa3e577ffde6d546f1c52e53b04d3151
[WARN ] [develop] Pull request creation and remote push skipped
[INFO ] [develop] {
  "owner": "lampajr",
  "repo": "backporting-example",
  "head": "bp-develop-0404fb9-11da4e3",
  "base": "develop",
  "title": "[develop] Update file1.txt",
  "body": "**Backport:** https://github.com/lampajr/backporting-example/pull/63\r\n\r\nThis PR aims to reset a file",
  "reviewers": [
    "lampajr"
  ],
  "assignees": [],
  "labels": [],
  "comments": []
}

As you can see, the first one (against prod) failed but the second one (against develop) succeeded as expected.

Checklist

  • Tests added if applicable.
  • Documentation updated if applicable.

Merge criteria:

  • The commits and have meaningful messages; the author will squash them after approval or will ask to merge with squash.
  • Testing instructions have been added in the PR body (for PRs involving changes that are not immediately obvious).
  • The developer has manually tested the changes and verified that the changes work

Note: dist/cli/index.js and dist/gha/index.js are automatically generated by git hooks and gh workflows.

First time here?

This project follows git conventional commits pattern, therefore the commits should have the following format:

<type>(<optional scope>): <subject>
empty separator line
<optional body>
empty separator line
<optional footer>

Where the type must be one of [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test]

NOTE: if you are still in a work in progress branch and you want to push your changes remotely, consider adding --no-verify for both commit and push, e.g., git push origin <feat-branch> --no-verify - this could become useful to push changes where there are still tests failures. Once the pull request is ready, please amend the commit and force-push it to keep following the adopted git commit standard.

How to prepare for a new release?

There is no need to manually update package.json version and CHANGELOG.md information. This process has been automated in Prepare Release Github workflow.

Therefore whenever enough changes are merged into the main branch, one of the maintainers will trigger this workflow that will automatically update version and changelog based on the commits on the git tree.

More details can be found in package release section of the README.

Copy link
Contributor

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements
89.17% (-0.55% 🔻)
502/563
🟢 Branches
85.33% (-0.77% 🔻)
192/225
🟢 Functions
87.5% (+0.1% 🔼)
112/128
🟢 Lines
89.01% (-0.56% 🔻)
486/546
Show files with reduced coverage 🔻
St.
File Statements Branches Functions Lines
🟡 git/git-cli.ts
62.96% (-1.48% 🔻)
29.41% (-3.92% 🔻)
81.82% (+1.82% 🔼)
62.96% (-1.48% 🔻)

Test suite run success

217 tests passing in 18 suites.

Report generated by 🧪jest coverage report action from 19d66c5

@lampajr
Copy link
Member Author

lampajr commented Oct 28, 2024

fyi @earl-warren

Copy link
Contributor

@earl-warren earl-warren left a comment

Choose a reason for hiding this comment

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

Excellent minimal manual test 👍

@lampajr lampajr merged commit 3deee59 into kiegroup:main Oct 28, 2024
6 checks passed
@lampajr lampajr deleted the concurrent_backports branch October 28, 2024 10:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

a failed backport my taint other backports
2 participants