@@ -33338,16 +33338,37 @@ module.exports = async function run() {
3333833338 });
3333933339
3334033340 if (validateSingleCommit) {
33341- const {data: commits} = await client.pulls.listCommits({
33342- owner,
33343- repo,
33344- pull_number: contextPullRequest.number,
33345- per_page: 2
33346- });
33341+ const commits = [];
33342+ let nonMergeCommits = [];
33343+
33344+ for await (const response of client.paginate.iterator(
33345+ client.pulls.listCommits,
33346+ {
33347+ owner,
33348+ repo,
33349+ pull_number: contextPullRequest.number
33350+ }
33351+ )) {
33352+ commits.push(...response.data);
33353+
33354+ // GitHub does not count merge commits when deciding whether to use
33355+ // the PR title or a commit message for the squash commit message.
33356+ nonMergeCommits = commits.filter(
33357+ (commit) => !commit.commit.message.startsWith('Merge branch')
33358+ );
33359+
33360+ // We only need two non-merge commits to know that the PR
33361+ // title won't be used.
33362+ if (nonMergeCommits.length >= 2) break;
33363+ }
3334733364
33348- if (commits.length === 1) {
33365+ // If there is only one (non merge) commit present, GitHub will use
33366+ // that commit rather than the PR title for the title of a squash
33367+ // commit. To make sure a semantic title is used for the squash
33368+ // commit, we need to validate the commit title.
33369+ if (nonMergeCommits.length === 1) {
3334933370 try {
33350- await validatePrTitle(commits [0].commit.message, {
33371+ await validatePrTitle(nonMergeCommits [0].commit.message, {
3335133372 types,
3335233373 scopes,
3335333374 requireScope,
0 commit comments