Skip to content

Commit

Permalink
fix: check length of merge commit array
Browse files Browse the repository at this point in the history
I thought that an empty array would be falsy, but that's not the case.
So I have to check the length of the array instead.
  • Loading branch information
korthout committed Aug 15, 2023
1 parent 483eb25 commit 8ffa5c7
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions src/backport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,12 @@ export class Backport {
this.config.pwd,
);
console.log(
`Encountered ${mergeCommitShas?.length ?? "no"} merge commits`,
`Encountered ${mergeCommitShas.length ?? "no"} merge commits`,
);
if (mergeCommitShas && this.config.commits.merge_commits == "fail") {
if (
mergeCommitShas.length > 0 &&
this.config.commits.merge_commits == "fail"
) {
const message = dedent`Backport failed because this pull request contains merge commits. \
You can either backport this pull request manually, or configure the action to skip merge commits.`;
console.error(message);
Expand All @@ -106,7 +109,10 @@ export class Backport {
}

let commitShasToCherryPick = commitShas;
if (mergeCommitShas && this.config.commits.merge_commits == "skip") {
if (
mergeCommitShas.length > 0 &&
this.config.commits.merge_commits == "skip"
) {
console.log("Skipping merge commits: " + mergeCommitShas);
const nonMergeCommitShas = commitShas.filter(
(sha) => !mergeCommitShas.includes(sha),
Expand Down

0 comments on commit 8ffa5c7

Please sign in to comment.