diff --git a/lib/createInlinePluginCreator.js b/lib/createInlinePluginCreator.js index 3fb950f..f7c89b3 100644 --- a/lib/createInlinePluginCreator.js +++ b/lib/createInlinePluginCreator.js @@ -126,7 +126,8 @@ function createInlinePluginCreator(packages, multiContext) { */ const analyzeCommits = async (pluginOptions, context) => { // Filter commits by directory. - commits = await getCommitsFiltered(cwd, dir, context.lastRelease.gitHead); + commits = await getCommitsFiltered(cwd, dir, context.lastRelease.gitHead, context.branch.name); + // context.logger.log("filtered commits", JSON.stringify(commits, null, 2)); // Set context.commits so analyzeCommits does correct analysis. context.commits = commits; diff --git a/lib/getCommitsFiltered.js b/lib/getCommitsFiltered.js index cd7579a..1ed61be 100644 --- a/lib/getCommitsFiltered.js +++ b/lib/getCommitsFiltered.js @@ -14,9 +14,10 @@ const cleanPath = require("./cleanPath"); * @param {string} cwd Absolute path of the working directory the Git repo is in. * @param {string} dir Path to the target directory to filter by. Either absolute, or relative to cwd param. * @param {string|void} lastHead The SHA of the previous release + * @param {string|void} branch first-parent to determine which merges went into master * @return {Promise>} The list of commits on the branch `branch` since the last release. */ -async function getCommitsFiltered(cwd, dir, lastHead = undefined) { +async function getCommitsFiltered(cwd, dir, lastHead = undefined, branch = "master") { // Clean paths and make sure directories exist. check(cwd, "cwd: directory"); check(dir, "dir: path"); @@ -43,7 +44,7 @@ async function getCommitsFiltered(cwd, dir, lastHead = undefined) { // Use git-log-parser to get the commits. const relpath = relative(root, dir); const stream = gitLogParser.parse( - { _: [lastHead ? `${lastHead}..HEAD` : "HEAD", "--", relpath] }, + { _: ["--first-parent", branch, lastHead ? `${lastHead}..HEAD` : "HEAD", "--", relpath] }, { cwd, env: process.env } ); const commits = await getStream.array(stream);