8000 getFileDiffsWithBasehead(): use CODE_SCANNING_REPOSITORY if present by cklin · Pull Request #2830 · github/codeql-action · GitHub
[go: up one dir, main page]

Skip to content

getFileDiffsWithBasehead(): use CODE_SCANNING_REPOSITORY if present #2830

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Mar 27, 2025

Conversation

cklin
Copy link
Contributor
@cklin cklin commented Mar 26, 2025

This PR updates getFileDiffsWithBasehead() so that it uses CODE_SCANNING_REPOSITORY if present, which makes it possible to override the repository that contains the commits being analized.

The PR also introduces a getRepositoryNwo() helper function that reduces code duplication across the codebase.

Merge / deployment checklist

  • Confirm this change is backwards compatible with existing workflows.
  • Confirm the readme has been updated if necessary.
  • Confirm the changelog has been updated if necessary.

@cklin cklin marked this pull request as ready for review March 26, 2025 17:58
@Copilot Copilot AI review requested due to automatic review settings March 26, 2025 17:58
@cklin cklin requested a review from a team as a code owner March 26, 2025 17:58
Copy link
Contributor
@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR updates the repository name resolution in various modules to allow an override via the CODE_SCANNING_REPOSITORY environment variable, making the functions more flexible in determining the repository context for code scanning operations.

  • Replace all usages of parseRepositoryNwo with getRepositoryNwo (or getRepositoryNwoFromEnv) to support the new override.
  • Update functions across core modules (src, lib folders) to use the new repository resolution functions.

Reviewed Changes

Copilot reviewed 33 out of 33 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/status-report.ts Updated repository info retrieval using getRepositoryNwo
src/repository.ts Introduced getRepositoryNwo and getRepositoryNwoFromEnv functions
src/init-action*.ts Replaced parseRepositoryNwo with getRepositoryNwo
src/autobuild.ts Similar repository resolution update
src/api-client.ts Updated repository usage in API requests
src/analyze*.ts Updated getFileDiffsWithBasehead to consider CODE_SCANNING_REPOSITORY
lib/* Consistent update of repository function calls throughout
Comments suppressed due to low confidence (1)

src/analyze.ts:393

  • It appears there is no test coverage for the conditional logic in getRepositoryNwoFromEnv (i.e. when CODE_SCANNING_REPOSITORY is set versus when it is not). Consider adding tests to ensure both scenarios are properly handled.
const repositoryNwo = getRepositoryNwoFromEnv("CODE_SCANNING_REPOSITORY", "GITHUB_REPOSITORY");

Tip: Copilot only keeps its highest confidence comments to reduce noise and keep you focused. Learn more

angelapwen
angelapwen previously approved these changes Mar 27, 2025
Copy link
Contributor
@angelapwen angelapwen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense!! Just a small comment about documentation 😸

@@ -390,7 +390,10 @@ async function getFileDiffsWithBasehead(
branches: PullRequestBranches,
logger: Logger,
): Promise<FileDiff[] | undefined> {
const repositoryNwo = getRepositoryNwo();
const repositoryNwo = getRepositoryNwoFromEnv(
"CODE_SCANNING_REPOSITORY",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps a small code comment here indicating that CODE_SCANNING_REPOSITORY is intended to override GITHUB_REPOSITORY would be useful for other maintainers!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the suggestion! I added the comment.

@cklin cklin merged commit 9bd18b4 into main Mar 27, 2025
270 checks passed
@cklin cklin deleted the cklin/code-scanning-repo branch March 27, 2025 17:25
@github-actions github-actions bot mentioned this pull request Apr 7, 2025
8 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0