Detect PR branches for Default Setup

This commit is contained in:
Chuan-kai Lin 2025-03-21 07:52:02 -07:00
parent 3e5446c3d2
commit d109dd5d33

View file

@ -270,6 +270,19 @@ function getPullRequestBranches(): PullRequestBranches | undefined {
head: pullRequest.head.label,
};
}
// PR analysis under Default Setup does not have the pull_request context,
// but it should set CODE_SCANNING_REF and CODE_SCANNING_BASE_BRANCH.
const codeScanningRef = process.env.CODE_SCANNING_REF;
const codeScanningBaseBranch = process.env.CODE_SCANNING_BASE_BRANCH;
if (codeScanningRef && codeScanningBaseBranch) {
return {
base: codeScanningBaseBranch,
// PR analysis under Default Setup analyzes the PR head commit instead of
// the merge commit, so we can use the provided ref directly.
head: codeScanningRef,
};
}
return undefined;
}