Skip to content

Commit

Permalink
feat: Check if the PR title matches the commit title when single comm…
Browse files Browse the repository at this point in the history
…its are validated to avoid surprises (#158)
  • Loading branch information
kenji-miyake authored Feb 4, 2022
1 parent 63022d8 commit f1216e9
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ module.exports = async function run() {
`Pull request has only one commit and it's not semantic; this may lead to a non-semantic commit in the base branch (see https://github.community/t/how-to-change-the-default-squash-merge-commit-message/1155). Amend the commit message to match the pull request title, or add another commit.`
);
}

const commitTitle =
nonMergeCommits[0].commit.message.split('\n')[0];
if (commitTitle !== pullRequest.title) {
throw new Error(
`The pull request has only one (non-merge) commit and in this case Github will use it as the default commit message when merging. The pull request title doesn't match the commit though ("${pullRequest.title}" vs. "${commitTitle}"). Please update the pull request title accordingly to avoid surprises.`
);
}
}
}
} catch (error) {
Expand Down

0 comments on commit f1216e9

Please sign in to comment.