fix(gh130): apply commits in the correct order on github (#131)

This commit is contained in:
Andrea Lamparelli 2024-07-16 17:49:23 +02:00 committed by GitHub
parent da6431b114
commit cb3473d7c9
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 3562 additions and 11 deletions

10
dist/cli/index.js vendored
View file

@ -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) {