Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Single commit validation does not factor in merge commits [#108] #130

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,19 @@ 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.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, {
await validatePrTitle(nonMergeCommits[0].commit.message, {
types,
scopes,
requireScope,
Expand Down