-
Notifications
You must be signed in to change notification settings - Fork 3
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
Bug-fix: attempting to update review comment from issue branch, path mismatch #48
base: main
Are you sure you want to change the base?
Conversation
the changes in |
bug-fix: comment link and path mismatch
@@ -105,7 +105,7 @@ async function run(): Promise<void> { | |||
for (const comment of actionIssueComments) { | |||
if (comment.body !== undefined && isPresent(comment.body)) { | |||
info(`Comment ${comment.id} represents a Coverity issue which is no longer present, updating comment to reflect resolution.`) | |||
updateExistingReviewComment(comment.id, createNoLongerPresentMessage(comment.body)) | |||
updateExistingIssueComment(comment.id, createNoLongerPresentMessage(comment.body)) |
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.
main bug causing http error, attempting to call update review under issue branch
@@ -128,7 +128,7 @@ async function run(): Promise<void> { | |||
} | |||
|
|||
function isInDiff(issue: IssueOccurrence, diffMap: DiffMap): boolean { | |||
const diffHunks = diffMap.get(issue.mainEventFilePathname) | |||
const diffHunks = diffMap.get(relativizePath(issue.mainEventFilePathname)) |
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.
this also needs to be normalized otherwise they won't match
function zTable(input: string) { | ||
let table = new Array<number>(input.length).fill(0) | ||
for (let i = 1; i < input.length; i++) { | ||
for (let j = 0; j < input.length - i; j ++) { | ||
if (input.charAt(j) != input.charAt(i + j)) continue | ||
table[i]++ | ||
} | ||
} | ||
return table | ||
} |
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.
this can be optimized by terminating early but not really necessary since path are tiny
// this should give `diff --git a/path b/path` | ||
// to get the file itself, we can use longest string match on `path b/path` | ||
// since we definitely know paths are equal, path must be the longest string | ||
path = line.substring("diff --git a/".length) | ||
path = path.substring(0, Math.max(...zTable(path))) |
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.
basically doing a naive longest string match with prefix here to find the path without splitting
let length = (process.env.GITHUB_WORKSPACE ?? "undefined").length | ||
// if workspace is /__w, replace as /home/runner/work | ||
if (path.startsWith("/__w")) { | ||
path = "/home/runner/work" + path.substring("/__w".length) |
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.
json outputs
"mainEventFilePathname" : "/__w/starling-core/starling-core/public_types/src/external_functions.cc",
with /__w
prefix, due to running in docker.
this doesn't fix general case but patches at the moment.
this needs to be raised as issue #49
There seems to be a call to update a review comment under the issue comment branch which leads to issue #47
This also patches path mismatches where coverity results json outputs
This PR has been packaged and tested.