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: cherry-pick multiple commits in the correct order #115

Merged
merged 1 commit into from
Apr 2, 2024

Conversation

earl-warren
Copy link
Contributor

Fixes: #114

Copy link
Contributor

github-actions bot commented Apr 1, 2024

Coverage report

St.
Category Percentage Covered / Total
🟢 Statements 90.84% 446/491
🟢 Branches 85.85% 176/205
🟢 Functions 88.33% 106/120
🟢 Lines 90.78% 433/477

Test suite run success

175 tests passing in 16 suites.

Report generated by 🧪jest coverage report action from e06c3a9

@earl-warren earl-warren force-pushed the wip-order branch 2 times, most recently from ccfcb8e to 6a3d20b Compare April 1, 2024 17:54
Copy link
Member

@lampajr lampajr left a comment

Choose a reason for hiding this comment

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

there's something I'm not sure about, in that with this fix (for github at least) the reverse is applied twice:

  1. when mapping the original pr https://github.com/kiegroup/git-backporting/pull/115/files#diff-6e3804f9a1581e5155295a17bbbc71343fa375a15bf5383dd4c4049a44be09cdR64
  2. when it has to scroll and cherry-pick the commits https://github.com/kiegroup/git-backporting/pull/115/files#diff-80854020f781d333495ba48208afccf09b44b58790aae94b10731f47b78e86ebR149

This means that at the end you are applying the commits in the same order as it was before 🤔

I need to check this a bit more

@lampajr
Copy link
Member

lampajr commented Apr 2, 2024

Ok I think we have two options here:

  1. Change the commits order during the original pull request fetch (i.e., during the mapping) and then change all the tests as you already did
  2. Change the order in which the commits are applied (i.e., in the runner) and then no other changes would be required

NOTE: option 1 would require a change in the gitlab client as well

@earl-warren
Copy link
Contributor Author

there's something I'm not sure about, in that with this fix (for github at least) the reverse is applied twice:

1. when mapping the original pr https://github.com/kiegroup/git-backporting/pull/115/files#diff-6e3804f9a1581e5155295a17bbbc71343fa375a15bf5383dd4c4049a44be09cdR64

2. when it has to scroll and cherry-pick the commits https://github.com/kiegroup/git-backporting/pull/115/files#diff-80854020f781d333495ba48208afccf09b44b58790aae94b10731f47b78e86ebR149

This means that at the end you are applying the commits in the same order as it was before 🤔

I need to check this a bit more

That's a leftover of a earlier attempt, my bad. And good catch.

@earl-warren
Copy link
Contributor Author

Change the order in which the commits are applied (i.e., in the runner) and then no other changes would be required

That sounds better. I'll go with that now that I better understand where's what.

@lampajr
Copy link
Member

lampajr commented Apr 2, 2024

Change the order in which the commits are applied (i.e., in the runner) and then no other changes would be required

That sounds better. I'll go with that now that I better understand where's what.

yeah I agree with you.

It could be useful to add something like this expect(GitCLIService.prototype.cherryPick).toHaveBeenLastCalledWith(cwd, "0404fb922ab75c3a8aecad5c97d9af388df04695", undefined, undefined) here

expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(2);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "0404fb922ab75c3a8aecad5c97d9af388df04695", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "11da4e38aa3e577ffde6d546f1c52e53b04d3151", undefined, undefined, undefined);

This way you can assure what is the last call of that method

@earl-warren
Copy link
Contributor Author

Change the order in which the commits are applied (i.e., in the runner) and then no other changes would be required

That sounds better. I'll go with that now that I better understand where's what.

yeah I agree with you.

It could be useful to add something like this expect(GitCLIService.prototype.cherryPick).toHaveBeenLastCalledWith(cwd, "0404fb922ab75c3a8aecad5c97d9af388df04695", undefined, undefined) here

expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(2);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "0404fb922ab75c3a8aecad5c97d9af388df04695", undefined, undefined, undefined);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "11da4e38aa3e577ffde6d546f1c52e53b04d3151", undefined, undefined, undefined);

This way you can assure what is the last call of that method

Thanks for the hint, exactly what I was looking for ❤️

@earl-warren
Copy link
Contributor Author

Should be better now.

Copy link
Member

@lampajr lampajr left a comment

Choose a reason for hiding this comment

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

Should be better now.

Indeed, sounds great! Merging this ❤️

@lampajr lampajr changed the title fix: return GitHub no-squash commits in order fix: cherry-pick multiple commits in the correct order Apr 2, 2024
@lampajr lampajr merged commit 6d9b9db into kiegroup:main Apr 2, 2024
6 checks passed
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.

no-squash: true cherry-picks commits in the wrong order
2 participants