diff --git a/CHANGELOG.md b/CHANGELOG.md index 5bf0fe749..0a83361a3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [4.2.0](https://github.com/amannn/action-semantic-pull-request/compare/v4.1.0...v4.2.0) (2022-02-08) + + +### Features + +* Add opt-in validation that PR titles match a single commit ([#160](https://github.com/amannn/action-semantic-pull-request/issues/160)) ([c05e358](https://github.com/amannn/action-semantic-pull-request/commit/c05e3587cb7878ec080300180d31d61ba1cf01ea)) + ## [4.1.0](https://github.com/amannn/action-semantic-pull-request/compare/v4.0.1...v4.1.0) (2022-02-04) diff --git a/dist/index.js b/dist/index.js index c13fd8700..fccb7d9d3 100644 --- a/dist/index.js +++ b/dist/index.js @@ -35661,6 +35661,7 @@ module.exports = async function run() { subjectPattern, subjectPatternError, validateSingleCommit, + validateSingleCommitMatchesPrTitle, githubBaseUrl } = parseConfig(); @@ -35746,12 +35747,14 @@ module.exports = async function run() { ); } - const commitTitle = - nonMergeCommits[0].commit.message.split('\n')[0]; - if (commitTitle !== pullRequest.title) { - throw new Error( - `The pull request has only one (non-merge) commit and in this case Github will use it as the default commit message when merging. The pull request title doesn't match the commit though ("${pullRequest.title}" vs. "${commitTitle}"). Please update the pull request title accordingly to avoid surprises.` - ); + if (validateSingleCommitMatchesPrTitle) { + const commitTitle = + nonMergeCommits[0].commit.message.split('\n')[0]; + if (commitTitle !== pullRequest.title) { + throw new Error( + `The pull request has only one (non-merge) commit and in this case Github will use it as the default commit message when merging. The pull request title doesn't match the commit though ("${pullRequest.title}" vs. "${commitTitle}"). Please update the pull request title accordingly to avoid surprises.` + ); + } } } } @@ -35839,6 +35842,13 @@ module.exports = function parseConfig() { ); } + let validateSingleCommitMatchesPrTitle; + if (process.env.INPUT_VALIDATESINGLECOMMITMATCHESPRTITLE) { + validateSingleCommitMatchesPrTitle = ConfigParser.parseBoolean( + process.env.INPUT_VALIDATESINGLECOMMITMATCHESPRTITLE + ); + } + let githubBaseUrl; if (process.env.INPUT_GITHUBBASEURL) { githubBaseUrl = ConfigParser.parseString(process.env.INPUT_GITHUBBASEURL); @@ -35852,6 +35862,7 @@ module.exports = function parseConfig() { subjectPattern, subjectPatternError, validateSingleCommit, + validateSingleCommitMatchesPrTitle, githubBaseUrl }; };