Skip to content

Commit 4147f0b

Browse files
committed
Add override for code scanning analysis of default branch
1 parent 04f256d commit 4147f0b

6 files changed

Lines changed: 16 additions & 2 deletions

File tree

lib/actions-util.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/actions-util.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/actions-util.test.js

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lib/actions-util.test.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/actions-util.test.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,10 @@ test("isAnalyzingDefaultBranch()", async (t) => {
227227
);
228228
process.env["GITHUB_EVENT_PATH"] = envFile;
229229

230+
process.env["CODE_SCANNING_IS_ANALYZING_DEFAULT_BRANCH"] = "true";
231+
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), true);
232+
233+
process.env["CODE_SCANNING_IS_ANALYZING_DEFAULT_BRANCH"] = "false";
230234
process.env["GITHUB_REF"] = "main";
231235
process.env["GITHUB_SHA"] = "1234";
232236
t.deepEqual(await actionsutil.isAnalyzingDefaultBranch(), true);

src/actions-util.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -630,6 +630,10 @@ function removeRefsHeadsPrefix(ref: string): string {
630630
// Is the version of the repository we are currently analyzing from the default branch,
631631
// or alternatively from another branch or a pull request.
632632
export async function isAnalyzingDefaultBranch(): Promise<boolean> {
633+
if (process.env.CODE_SCANNING_IS_ANALYZING_DEFAULT_BRANCH === "true") {
634+
return true;
635+
}
636+
633637
// Get the current ref and trim and refs/heads/ prefix
634638
let currentRef = await getRef();
635639
currentRef = removeRefsHeadsPrefix(currentRef);

0 commit comments

Comments
 (0)