Skip to content

Commit 4feeedb

Browse files
chore: Release 3.4.5 [skip ci]
1 parent 5265383 commit 4feeedb

File tree

2 files changed

+36
-8
lines changed

2 files changed

+36
-8
lines changed

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
# Changelog
22

3+
### [3.4.5](https://github.com/amannn/action-semantic-pull-request/compare/v3.4.4...v3.4.5) (2021-10-28)
4+
5+
6+
### Bug Fixes
7+
8+
* Consider merge commits for single commit validation ([#131](https://github.com/amannn/action-semantic-pull-request/issues/131)) ([5265383](https://github.com/amannn/action-semantic-pull-request/commit/526538350f2e4eaaac841e586a197de6b019af1f)), closes [#108](https://github.com/amannn/action-semantic-pull-request/issues/108)
9+
310
### [3.4.4](https://github.com/amannn/action-semantic-pull-request/compare/v3.4.3...v3.4.4) (2021-10-26)
411

512

dist/index.js

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)