Diff-informed analysis: fix empty PR handling
This commit is contained in:
parent
bd1d9ab4ed
commit
b361a91508
3 changed files with 18 additions and 1 deletions
8
lib/analyze.js
generated
8
lib/analyze.js
generated
|
|
@ -368,6 +368,14 @@ function writeDiffRangeDataExtensionPack(logger, ranges) {
|
||||||
if (ranges === undefined) {
|
if (ranges === undefined) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
if (ranges.length === 0) {
|
||||||
|
// An empty diff range means that there are no added or modified lines in
|
||||||
|
// the pull request. But the `restrictAlertsTo` extensible predicate
|
||||||
|
// interprets an empty data extension differently, as an indication that
|
||||||
|
// all alerts should be included. So we need to specifically set the diff
|
||||||
|
// range to a non-empty list that cannot match any alert location.
|
||||||
|
ranges = [{ path: "", startLine: 0, endLine: 0 }];
|
||||||
|
}
|
||||||
const diffRangeDir = path.join(actionsUtil.getTemporaryDirectory(), "pr-diff-range");
|
const diffRangeDir = path.join(actionsUtil.getTemporaryDirectory(), "pr-diff-range");
|
||||||
fs.mkdirSync(diffRangeDir);
|
fs.mkdirSync(diffRangeDir);
|
||||||
fs.writeFileSync(path.join(diffRangeDir, "qlpack.yml"), `
|
fs.writeFileSync(path.join(diffRangeDir, "qlpack.yml"), `
|
||||||
|
|
|
||||||
File diff suppressed because one or more lines are too long
|
|
@ -527,6 +527,15 @@ function writeDiffRangeDataExtensionPack(
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ranges.length === 0) {
|
||||||
|
// An empty diff range means that there are no added or modified lines in
|
||||||
|
// the pull request. But the `restrictAlertsTo` extensible predicate
|
||||||
|
// interprets an empty data extension differently, as an indication that
|
||||||
|
// all alerts should be included. So we need to specifically set the diff
|
||||||
|
// range to a non-empty list that cannot match any alert location.
|
||||||
|
ranges = [{ path: "", startLine: 0, endLine: 0 }];
|
||||||
|
}
|
||||||
|
|
||||||
const diffRangeDir = path.join(
|
const diffRangeDir = path.join(
|
||||||
actionsUtil.getTemporaryDirectory(),
|
actionsUtil.getTemporaryDirectory(),
|
||||||
"pr-diff-range",
|
"pr-diff-range",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue