diff --git a/src/index.js b/src/index.js index cc821fd47..cf1590a51 100644 --- a/src/index.js +++ b/src/index.js @@ -58,7 +58,17 @@ module.exports = async function run() { per_page: 2 }); - if (commits.length === 1) { + // GitHub does not count merge commits when deciding whether to use + // the PR title or a commit message for the squash commit message. + const nonMergeCommits = commits.filter( + (commit) => !commit.message.startsWith('Merge branch') + ); + + // If there is only one (non merge) commit present, GitHub will use + // that commit rather than the PR title for the title of a squash + // commit. To make sure a semantic title is used for the squash + // commit, we need to validate the commit title. + if (nonMergeCommits.length === 1) { try { await validatePrTitle(commits[0].commit.message, { types,