Skip to content

Commit

Permalink
fix(collect-updates): Improve logging, making ignored globs explicit
Browse files Browse the repository at this point in the history
  • Loading branch information
evocateur committed Feb 5, 2019
1 parent a293541 commit 42e4a5c
Showing 1 changed file with 21 additions and 7 deletions.
28 changes: 21 additions & 7 deletions utils/collect-updates/lib/make-diff-predicate.js
Expand Up @@ -9,15 +9,27 @@ const slash = require("slash");
module.exports = makeDiffPredicate;

function makeDiffPredicate(committish, execOpts, ignorePatterns = []) {
const ignoreFilters = new Set(ignorePatterns.map(p => minimatch.filter(`!${p}`, { matchBase: true })));
const ignoreFilters = new Set(
ignorePatterns.map(p =>
minimatch.filter(`!${p}`, {
matchBase: true,
})
)
);

if (ignoreFilters.size) {
log.info("ignoring diff in paths matching", ignorePatterns);
}

return function hasDiffSinceThatIsntIgnored(node) {
const diff = diffSinceIn(committish, node.location, execOpts);

if (diff === "") {
log.silly("", "no diff found in %s", node.name);
return false;
}

log.silly("found diff in", diff);
let changedFiles = diff.split("\n");

if (ignoreFilters.size) {
Expand All @@ -26,6 +38,12 @@ function makeDiffPredicate(committish, execOpts, ignorePatterns = []) {
}
}

if (changedFiles.length) {
log.verbose("filtered diff", changedFiles);
} else {
log.verbose("", "no diff found in %s (after filtering)", node.name);
}

return changedFiles.length > 0;
};
}
Expand All @@ -39,10 +57,6 @@ function diffSinceIn(committish, location, opts) {
args.push("--", formattedLocation);
}

log.silly("diffSinceIn", committish, formattedLocation);

const diff = childProcess.execSync("git", args, opts);
log.silly("diff", diff);

return diff;
log.silly("checking diff", formattedLocation);
return childProcess.execSync("git", args, opts);
}

0 comments on commit 42e4a5c

Please sign in to comment.