-
Notifications
You must be signed in to change notification settings - Fork 18
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
refactor(review-pr): refactor to use hunks instead of Patch + new file content #132
Conversation
Codecov Report
@@ Coverage Diff @@
## master #132 +/- ##
==========================================
- Coverage 88.17% 86.34% -1.84%
==========================================
Files 25 22 -3
Lines 2384 2145 -239
Branches 180 150 -30
==========================================
- Hits 2102 1852 -250
- Misses 281 292 +11
Partials 1 1
Continue to review full report at Codecov.
|
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 looks really good to me, great to see us delete 1000 lines.
return {validFileLines, invalidFiles: filesMissingPatch}; | ||
} catch (err) { | ||
): Promise<Map<string, Hunk[]>> { | ||
const files = ( |
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.
If you use octokit's iterator API, you can do something along the lines of:
for await () {}
And avoid pagination concerns if there are more than 100 files.
`File ${file.filename} may have a patch that is too large to display patch object.` | ||
); | ||
} else { | ||
const hunks = parseHunks(_DIFF_HEADER + file.patch); |
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.
it seems like this new logic is biting you, with regards to windows line endings.
In test you might want to add a helper that just standardizes on \n
.
sha: 'a1d470fa4d7b04450715e3e02d240a34517cd988', | ||
filename: 'Readme.md', | ||
status: 'modified', | ||
additions: 4, |
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.
is there any value in pulling this into a fixture? maybe not worth it if we're only going to have one smoke test, but if we're going to add a few payloads like this over time, perhaps we could collect them in a folder.
This looks like an platform bug in the upstream parse-diff library.
This is a rather large refactor:
newContent
field toHunk