Skip to content

Commit

Permalink
Test implementation 2
Browse files Browse the repository at this point in the history
  • Loading branch information
julianpoy committed Oct 26, 2021
1 parent 64af21f commit fd32dab
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/lint-pr-title-preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,6 @@ jobs:
- uses: ./
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
validateSingleCommit: true

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

0 comments on commit fd32dab

Please sign in to comment.