Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Redefine shouldPerformDiffInformedAnalysis()
This commit renames the original shouldPerformDiffInformedAnalysis(),
which returns `PullRequestBranches | undefined`, to
getDiffInformedAnalysisBranches(). It also adds a new
shouldPerformDiffInformedAnalysis() function that returns boolean.

Separating these two functions makes it clear what the intended uses and
return values should be for each.
  • Loading branch information
cklin committed Mar 28, 2025
commit e7f67e2e61e4475bb40229e4713953453decb56a
4 changes: 2 additions & 2 deletions src/analyze-action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { getCodeQL } from "./codeql";
import { Config, getConfig } from "./config-utils";
import { uploadDatabases } from "./database-upload";
import { uploadDependencyCaches } from "./dependency-caching";
import { shouldPerformDiffInformedAnalysis } from "./diff-informed-analysis-utils";
import { getDiffInformedAnalysisBranches } from "./diff-informed-analysis-utils";
import { EnvVar } from "./environment";
import { Features } from "./feature-flags";
import { Language } from "./languages";
Expand Down Expand Up @@ -270,7 +270,7 @@ async function run() {
logger,
);

const branches = await shouldPerformDiffInformedAnalysis(
const branches = await getDiffInformedAnalysisBranches(
codeql,
features,
logger,
Expand Down
16 changes: 15 additions & 1 deletion src/diff-informed-analysis-utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,26 @@ function getPullRequestBranches(): PullRequestBranches | undefined {

/**
* Check if the action should perform diff-informed analysis.
*/
export async function shouldPerformDiffInformedAnalysis(
codeql: CodeQL,
features: FeatureEnablement,
logger: Logger,
): Promise<boolean> {
return (
(await getDiffInformedAnalysisBranches(codeql, features, logger)) !==
undefined
);
}

/**
* Get the branches to use for diff-informed analysis.
*
* @returns If the action should perform diff-informed analysis, return
* the base and head branches that should be used to compute the diff ranges.
* Otherwise return `undefined`.
*/
export async function shouldPerformDiffInformedAnalysis(
export async function getDiffInformedAnalysisBranches(
codeql: CodeQL,
features: FeatureEnablement,
logger: Logger,
Expand Down