Skip to content

Commit db6e259

Browse files
chore: Release 3.4.0 [skip ci]
1 parent 3f20459 commit db6e259

File tree

2 files changed

+43
-2
lines changed

2 files changed

+43
-2
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.0](https://github.com/amannn/action-semantic-pull-request/compare/v3.3.0...v3.4.0) (2021-02-15)
4+
5+
6+
### Features
7+
8+
* Add `validateSingleCommit` flag to validate the commit message if there's only a single commit in the PR (opt-in). This is intended to be used as a workaround for an issue with Github as in this case, the PR title won't be used as the default commit message when merging a PR. ([#87](https://github.com/amannn/action-semantic-pull-request/issues/87)) ([3f20459](https://github.com/amannn/action-semantic-pull-request/commit/3f20459aa1121f2f0093f06f565a95fe7c5cf402))
9+
310
## [3.3.0](https://github.com/amannn/action-semantic-pull-request/compare/v3.2.6...v3.3.0) (2021-02-10)
411

512

dist/index.js

Lines changed: 36 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33299,7 +33299,8 @@ module.exports = async function run() {
3329933299
requireScope,
3330033300
wip,
3330133301
subjectPattern,
33302-
subjectPatternError
33302+
subjectPatternError,
33303+
validateSingleCommit
3330333304
} = parseConfig();
3330433305

3330533306
const contextPullRequest = github.context.payload.pull_request;
@@ -33335,6 +33336,31 @@ module.exports = async function run() {
3333533336
subjectPattern,
3333633337
subjectPatternError
3333733338
});
33339+
33340+
if (validateSingleCommit) {
33341+
const {data: commits} = await client.pulls.listCommits({
33342+
owner,
33343+
repo,
33344+
pull_number: contextPullRequest.number,
33345+
per_page: 2
33346+
});
33347+
33348+
if (commits.length === 1) {
33349+
try {
33350+
await validatePrTitle(commits[0].commit.message, {
33351+
types,
33352+
scopes,
33353+
requireScope,
33354+
subjectPattern,
33355+
subjectPatternError
33356+
});
33357+
} catch (error) {
33358+
throw new Error(
33359+
`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.`
33360+
);
33361+
}
33362+
}
33363+
}
3333833364
} catch (error) {
3333933365
validationError = error;
3334033366
}
@@ -33412,13 +33438,21 @@ module.exports = function parseConfig() {
3341233438
wip = ConfigParser.parseBoolean(process.env.INPUT_WIP);
3341333439
}
3341433440

33441+
let validateSingleCommit;
33442+
if (process.env.INPUT_VALIDATESINGLECOMMIT) {
33443+
validateSingleCommit = ConfigParser.parseBoolean(
33444+
process.env.INPUT_VALIDATESINGLECOMMIT
33445+
);
33446+
}
33447+
3341533448
return {
3341633449
types,
3341733450
scopes,
3341833451
requireScope,
3341933452
wip,
3342033453
subjectPattern,
33421-
subjectPatternError
33454+
subjectPatternError,
33455+
validateSingleCommit
3342233456
};
3342333457
};
3342433458

0 commit comments

Comments
 (0)