Skip to content

Commit

Permalink
Support autoMerge commit filter without scope
Browse files Browse the repository at this point in the history
  • Loading branch information
dgellow committed Sep 21, 2023
1 parent 636dbf5 commit 8413de9
Show file tree
Hide file tree
Showing 2 changed files with 586 additions and 13 deletions.
19 changes: 9 additions & 10 deletions src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ export type AutoMergeOption = {
/**
* Only auto merge if all conventional commits of the PR match the filter
*/
conventionalCommitFilter?: {type: string; scope: string}[];
conventionalCommitFilter?: {type: string; scope?: string}[];
/**
* Only auto merge if the version bump match the filter
*/
Expand Down Expand Up @@ -1586,33 +1586,32 @@ export class Manifest {
if (pullRequest.conventionalCommits.length === 0) {
return false;
}
const commitSet = new Set(
pullRequest.conventionalCommits.map(
commit => `${commit.type}:${commit.scope}`
)
);
const filterSet = new Set(
conventionalCommitFilter!.map(
filter => `${filter.type}:${filter.scope}`
filter => `${filter.type}:${filter.scope ? filter.scope : '*'}`
)
);
for (const n of commitSet) {
if (!filterSet.has(n)) {
for (const commit of pullRequest.conventionalCommits) {
if (
!filterSet.has(`${commit.type}:${commit.scope}`) &&
!filterSet.has(`${commit.type}:*`)
) {
return false;
}
}
return true;
};

const selected =
conventionalCommitFilter?.length && conventionalCommitFilter.length
conventionalCommitFilter?.length && versionBumpFilter?.length
? applyConventionalCommitFilter() && applyVersionBumpFilter()
: conventionalCommitFilter?.length
? applyConventionalCommitFilter()
: versionBumpFilter?.length
? applyVersionBumpFilter()
: // no filter provided
false;

return selected ? this.autoMerge : undefined;
}
}
Expand Down
Loading

0 comments on commit 8413de9

Please sign in to comment.