Skip to content

Commit

Permalink
chore: Release 3.4.0 [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
semantic-release-bot committed Feb 15, 2021
1 parent 3f20459 commit db6e259
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# Changelog

## [3.4.0](https://github.com/amannn/action-semantic-pull-request/compare/v3.3.0...v3.4.0) (2021-02-15)


### Features

* 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))

## [3.3.0](https://github.com/amannn/action-semantic-pull-request/compare/v3.2.6...v3.3.0) (2021-02-10)


Expand Down
38 changes: 36 additions & 2 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33299,7 +33299,8 @@ module.exports = async function run() {
requireScope,
wip,
subjectPattern,
subjectPatternError
subjectPatternError,
validateSingleCommit
} = parseConfig();

const contextPullRequest = github.context.payload.pull_request;
Expand Down Expand Up @@ -33335,6 +33336,31 @@ module.exports = async function run() {
subjectPattern,
subjectPatternError
});

if (validateSingleCommit) {
const {data: commits} = await client.pulls.listCommits({
owner,
repo,
pull_number: contextPullRequest.number,
per_page: 2
});

if (commits.length === 1) {
try {
await validatePrTitle(commits[0].commit.message, {
types,
scopes,
requireScope,
subjectPattern,
subjectPatternError
});
} catch (error) {
throw new Error(
`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.`
);
}
}
}
} catch (error) {
validationError = error;
}
Expand Down Expand Up @@ -33412,13 +33438,21 @@ module.exports = function parseConfig() {
wip = ConfigParser.parseBoolean(process.env.INPUT_WIP);
}

let validateSingleCommit;
if (process.env.INPUT_VALIDATESINGLECOMMIT) {
validateSingleCommit = ConfigParser.parseBoolean(
process.env.INPUT_VALIDATESINGLECOMMIT
);
}

return {
types,
scopes,
requireScope,
wip,
subjectPattern,
subjectPatternError
subjectPatternError,
validateSingleCommit
};
};

Expand Down

0 comments on commit db6e259

Please sign in to comment.