Skip to content

Commit

Permalink
fix(gh130): apply commits in the correct order on github (#131)
Browse files Browse the repository at this point in the history
  • Loading branch information
lampajr authored Jul 16, 2024
1 parent da6431b commit cb3473d
Show file tree
Hide file tree
Showing 8 changed files with 3,562 additions and 11 deletions.
10 changes: 9 additions & 1 deletion dist/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1619,7 +1619,15 @@ class Runner {
}
// 7. apply all changes to the new branch
this.logger.debug("Cherry picking commits..");
for (const sha of originalPR.commits.reverse()) {
// Commits might be ordered in different ways based on the git service, e.g., considering top to bottom
// GITHUB --> oldest to newest
// CODEBERG --> newest to oldest
// GITLAB --> newest to oldest
if (git.gitClientType === git_types_1.GitClientType.CODEBERG || git.gitClientType === git_types_1.GitClientType.GITLAB) {
// reverse the order as we always need to process from older to newest
originalPR.commits.reverse();
}
for (const sha of originalPR.commits) {
await git.gitCli.cherryPick(configs.folder, sha, configs.mergeStrategy, configs.mergeStrategyOption, configs.cherryPickOptions);
}
if (!configs.dryRun) {
Expand Down
10 changes: 9 additions & 1 deletion dist/gha/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -1584,7 +1584,15 @@ class Runner {
}
// 7. apply all changes to the new branch
this.logger.debug("Cherry picking commits..");
for (const sha of originalPR.commits.reverse()) {
// Commits might be ordered in different ways based on the git service, e.g., considering top to bottom
// GITHUB --> oldest to newest
// CODEBERG --> newest to oldest
// GITLAB --> newest to oldest
if (git.gitClientType === git_types_1.GitClientType.CODEBERG || git.gitClientType === git_types_1.GitClientType.GITLAB) {
// reverse the order as we always need to process from older to newest
originalPR.commits.reverse();
}
for (const sha of originalPR.commits) {
await git.gitCli.cherryPick(configs.folder, sha, configs.mergeStrategy, configs.mergeStrategyOption, configs.cherryPickOptions);
}
if (!configs.dryRun) {
Expand Down
10 changes: 9 additions & 1 deletion src/service/runner/runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,15 @@ export default class Runner {

// 7. apply all changes to the new branch
this.logger.debug("Cherry picking commits..");
for (const sha of originalPR.commits.reverse()!) {
// Commits might be ordered in different ways based on the git service, e.g., considering top to bottom
// GITHUB --> oldest to newest
// CODEBERG --> newest to oldest
// GITLAB --> newest to oldest
if (git.gitClientType === GitClientType.CODEBERG || git.gitClientType === GitClientType.GITLAB) {
// reverse the order as we always need to process from older to newest
originalPR.commits.reverse();
}
for (const sha of originalPR.commits) {
await git.gitCli.cherryPick(configs.folder, sha, configs.mergeStrategy, configs.mergeStrategyOption, configs.cherryPickOptions);
}

Expand Down
Loading

0 comments on commit cb3473d

Please sign in to comment.