-
Notifications
You must be signed in to change notification settings - Fork 356
Declare the merge base as base for code scanning comparisons #858
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -291,7 +291,8 @@ export function buildPayload( | |
checkoutURI: string, | ||
environment: string | undefined, | ||
toolNames: string[], | ||
gitHubVersion: util.GitHubVersion | ||
gitHubVersion: util.GitHubVersion, | ||
mergeBaseCommitOid: string | undefined | ||
) { | ||
if (util.isActions()) { | ||
const payloadObj = { | ||
|
@@ -314,15 +315,28 @@ export function buildPayload( | |
gitHubVersion.type !== util.GitHubVariant.GHES || | ||
semver.satisfies(gitHubVersion.version, `>=3.1`) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we need to change the satisfies here? Will GHES < 3.4 accept the new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is no new parameter on the dotcom side. This is only about computing a better value for the existing parameter |
||
) { | ||
if ( | ||
process.env.GITHUB_EVENT_NAME === "pull_request" && | ||
process.env.GITHUB_EVENT_PATH | ||
) { | ||
const githubEvent = JSON.parse( | ||
fs.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8") | ||
); | ||
payloadObj.base_ref = `refs/heads/${githubEvent.pull_request.base.ref}`; | ||
payloadObj.base_sha = githubEvent.pull_request.base.sha; | ||
if (process.env.GITHUB_EVENT_NAME === "pull_request") { | ||
if ( | ||
commitOid === util.getRequiredEnvParam("GITHUB_SHA") && | ||
mergeBaseCommitOid | ||
) { | ||
// We're uploading results for the merge commit | ||
// and were able to determine the merge base. | ||
// So we use that as the most accurate base. | ||
payloadObj.base_ref = `refs/heads/${util.getRequiredEnvParam( | ||
"GITHUB_BASE_REF" | ||
)}`; | ||
payloadObj.base_sha = mergeBaseCommitOid; | ||
} else if (process.env.GITHUB_EVENT_PATH) { | ||
// Either we're not uploading results for the merge commit | ||
// or we could not determine the merge base. | ||
// Using the PR base is the only option here | ||
const githubEvent = JSON.parse( | ||
fs.readFileSync(process.env.GITHUB_EVENT_PATH, "utf8") | ||
); | ||
payloadObj.base_ref = `refs/heads/${githubEvent.pull_request.base.ref}`; | ||
payloadObj.base_sha = githubEvent.pull_request.base.sha; | ||
} | ||
} | ||
} | ||
return payloadObj; | ||
|
@@ -389,7 +403,8 @@ async function uploadFiles( | |
checkoutURI, | ||
environment, | ||
toolNames, | ||
gitHubVersion | ||
gitHubVersion, | ||
await actionsUtil.determineMergeBaseCommitOid() | ||
); | ||
|
||
// Log some useful debug info about the info | ||
|
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.
Nice trick to get the merge base.