From 3defc79a28b255337a90444c19ab86aa28a37826 Mon Sep 17 00:00:00 2001 From: Patrick Mowrer Date: Tue, 12 Dec 2017 13:34:38 -0500 Subject: [PATCH 1/2] fix(get-last-release): don't crash if last release isn't found --- src/get-last-release.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/get-last-release.js b/src/get-last-release.js index bea8b9e..ba30497 100644 --- a/src/get-last-release.js +++ b/src/get-last-release.js @@ -15,7 +15,7 @@ module.exports = async (pluginConfig, options) => { * 2. We can use `semantic-release`'s fallback strategy, searching for a matching git tag, * but we must update the git tag format to be compatible with the monorepo workflow. **/ - if (!result.gitHead) { + if (result && !result.gitHead) { return { ...result, ...await getVersionHead(null, await gitTag(result.version)) From 2eed4301a395bea13ccb14046cf6c5c6e5977edb Mon Sep 17 00:00:00 2001 From: Patrick Mowrer Date: Tue, 12 Dec 2017 13:37:17 -0500 Subject: [PATCH 2/2] fix: commit files path filter should match beginning of paths MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Using `Array.includes` allowed the package path to match against any part of a commit file’s path, resulting in false positives. --- package.json | 1 + src/with-package-commits.js | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 6f3293e..0fff4d1 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "semantic-release": "^11.0.0" }, "dependencies": { + "debug": "^3.1.0", "execa": "^0.8.0", "pkg-up": "^2.0.0", "ramda": "^0.25.0", diff --git a/src/with-package-commits.js b/src/with-package-commits.js index ff9d077..6bf94c6 100644 --- a/src/with-package-commits.js +++ b/src/with-package-commits.js @@ -1,3 +1,4 @@ +const debug = require('debug')('semantic-release:commit-analyzer'); const pkgUp = require('pkg-up'); const { getCommitFiles, getGitRoot } = require('./git-utils'); const overrideOption = require('./override-option'); @@ -17,10 +18,19 @@ const withFiles = async commits => { const withPackageCommits = async commits => { const packagePath = await getPackagePath(); + debug('Filter commits by package path: "%s"', packagePath); const commitsWithFiles = await withFiles(commits); return commitsWithFiles.filter( - ({ files }) => files.some(path => path.includes(packagePath)) + ({ files, subject }) => { + const matchingPath = files.find(path => path.indexOf(packagePath) === 0); + + if (matchingPath) { + debug('Including commit "%s" because it modified package file "%s".', subject, matchingPath); + } + + return !!matchingPath; + } ); };