Skip to content

Commit

Permalink
fix: return GitHub no-squash commits in order (#115)
Browse files Browse the repository at this point in the history
Fixes: #114
  • Loading branch information
earl-warren authored Apr 2, 2024
1 parent fe6be83 commit 6d9b9db
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1469,7 +1469,7 @@ class Runner {
}
// 7. apply all changes to the new branch
this.logger.debug("Cherry picking commits..");
for (const sha of originalPR.commits) {
for (const sha of originalPR.commits.reverse()) {
await git.gitCli.cherryPick(configs.folder, sha, configs.mergeStrategy, configs.mergeStrategyOption, configs.cherryPickOptions);
}
if (!configs.dryRun) {
Expand Down
2 changes: 1 addition & 1 deletion dist/gha/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1436,7 +1436,7 @@ class Runner {
}
// 7. apply all changes to the new branch
this.logger.debug("Cherry picking commits..");
for (const sha of originalPR.commits) {
for (const sha of originalPR.commits.reverse()) {
await git.gitCli.cherryPick(configs.folder, sha, configs.mergeStrategy, configs.mergeStrategyOption, configs.cherryPickOptions);
}
if (!configs.dryRun) {
Expand Down
2 changes: 1 addition & 1 deletion src/service/runner/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export default class Runner {

// 7. apply all changes to the new branch
this.logger.debug("Cherry picking commits..");
for (const sha of originalPR.commits!) {
for (const sha of originalPR.commits.reverse()!) {
await git.gitCli.cherryPick(configs.folder, sha, configs.mergeStrategy, configs.mergeStrategyOption, configs.cherryPickOptions);
}

Expand Down
4 changes: 2 additions & 2 deletions test/service/runner/cli-github-runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -681,7 +681,7 @@ describe("cli runner", () => {
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);

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

expect(GitCLIService.prototype.push).toBeCalledTimes(1);
Expand Down Expand Up @@ -787,7 +787,7 @@ describe("cli runner", () => {
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);

expect(GitCLIService.prototype.cherryPick).toBeCalledTimes(2);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "0404fb922ab75c3a8aecad5c97d9af388df04695", "ort", "find-renames", undefined);
expect(GitCLIService.prototype.cherryPick).toHaveBeenLastCalledWith(cwd, "0404fb922ab75c3a8aecad5c97d9af388df04695", "ort", "find-renames", undefined);
expect(GitCLIService.prototype.cherryPick).toBeCalledWith(cwd, "11da4e38aa3e577ffde6d546f1c52e53b04d3151", "ort", "find-renames", undefined);

expect(GitCLIService.prototype.push).toBeCalledTimes(1);
Expand Down
2 changes: 1 addition & 1 deletion test/service/runner/gha-github-runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ describe("gha runner", () => {
expect(GitCLIService.prototype.fetch).toBeCalledTimes(0);

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

expect(GitCLIService.prototype.push).toBeCalledTimes(1);
Expand Down

0 comments on commit 6d9b9db

Please sign in to comment.