-
Notifications
You must be signed in to change notification settings - Fork 361
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
Conversation
There was a problem hiding this 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
There was a problem hiding this 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", |
There was a problem hiding this comment.
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!
There was a problem hiding this comment.
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.
3bd5ec3
to
0afd488
Compare
This PR updates
getFileDiffsWithBasehead()
so that it usesCODE_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