-
Notifications
You must be signed in to change notification settings - Fork 355
Support diff-informed queries under Default Setup #2817
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 extends the diff-informed queries functionality to work under the Default Setup by introducing a new branch interface and updating diff-related functions.
- Introduces a new interface (PullRequestBranches) and helper function (getPullRequestBranches) to consistently extract branch information.
- Refactors several functions in both the src and lib directories to use the new branch structure.
- Simplifies diff-informed query setup in analyze-action files by removing redundant pull_request checks.
Reviewed Changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated no comments.
File | Description |
---|---|
src/analyze.ts | Updated to use PullRequestBranches; refactored diff range retrieval. |
lib/analyze.js | Updated to use PullRequestBranches; refactored diff range retrieval. |
src/analyze-action.ts | Removed direct pull_request usage, now relying on unified branch info. |
lib/analyze-action.js | Removed direct pull_request usage, now relying on unified branch info. |
Comments suppressed due to low confidence (2)
src/analyze.ts:257
- Ensure that the new branch handling logic in getPullRequestBranches is adequately tested for both scenarios: when the pull_request context is available and when falling back to the CODE_SCANNING_REF and CODE_SCANNING_BASE_BRANCH environment variables.
interface PullRequestBranches {
lib/analyze.js:162
- Ensure that the new getPullRequestBranches implementation covers both the pull_request context and the Default Setup environment variable fallback case in the unit tests.
function getPullRequestBranches() {
Tip: Copilot code review supports C#, Go, Java, JavaScript, Markdown, Python, Ruby and TypeScript, with more languages coming soon. 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.
Some minor comments, thank you for your work here.
// 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, | ||
}; |
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.
Can we get a (debug?) log message here that the environment variables weren't set in the else
branch?
I'm thinking this might make it easier to identify where it goes wrong in the future, for either ourselves or an end user.
What are your thoughts on this one?
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.
I added two info log statements:
- One to indicate that we are not performing diff-informed analysis because we are not analyzing a PR
- One to indicate that we are analyzing a PR, and what refs are being used for diff range calculation
@@ -254,6 +254,25 @@ async function finalizeDatabaseCreation( | |||
}; | |||
} | |||
|
|||
interface PullRequestBranches { |
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.
Thank you for this refactoring. I always appreciate bundling information into its own semantic bundle.
Would it be possible to get some documentation above the interface as to what it's supposed to signify? I think it's clear from the context, but it might make future mantainer's life better.
I think some of that documentation could be sourced from the previous @param
documentation in the getPullRequestEditedDiffRanges
function.
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.
I thought about it and decided that additional documentation would not have provided much value.
The interface is basically what the definition says: a record for storing the base and head branches of a pull request. Repeating the same thing in English does not seem to be all that useful.
Previous @param
documentation for getPullRequestEditedDiffRanges()
contains some useful information, and I have already incorporated them into code comments in getPullRequestBranches()
. That documentation does not quite fit at the PullRequestBranches
level, because the pull_request
context is now only one of two possible sources for obtaining branch information. (When we set the head branch using CODE_SCANNING_REF
, we are relying on the Default Setup workflow to set the environment variable correctly, without requiring the variable to use a head ref.)
All that is explained in getPullRequestBranches()
, next to the code that creates PullRequestBranches
values. I think that is a better place for that explanation because it is easier to keep the code comments up-to-date if the code needs to be changed in the future.
35e42c3
to
9c674ba
Compare
This PR extends the diff-informed queries functionality to also work under the Default Setup.
Merge / deployment checklist