This adds an optimization and simplification for getting the diff of a PR. Previously, triagebot would fetch the /compare endpoint three times for every PR (for auto-assignment, auto-labels, and mentions). This changes it so that it only fetches it once, and caches the result in the PullRequestDetails.
This also changes it so that the diff gets parsed early on, instead of having every caller parse it. This should help make it a little more structured. Thus, diff() returns a Vec<FileDiff>, where each element is a single file.
A walkthrough to help reviewing this PR:
Added a FileDiff type to represent a diff to a single file.
PullRequestDetails adds a OnceCell to cache the PR diff.
Issue.diff() now returns a parsed result (instead of just a string), and caches the result.
files_changed was changed to parse_diff to return a structured format.
All the callers of Issue.diff() were updated to use the new format.
The assign.rs input handler was changed to fetch the diff in handle_input instead of parse_input, due to not being able to pass a reference (and it wasn't important which function it was called in).
Auto-assignment was doing its own diff parsing which is no longer necessary.
This adds an optimization and simplification for getting the diff of a PR. Previously, triagebot would fetch the
/compare
endpoint three times for every PR (for auto-assignment, auto-labels, and mentions). This changes it so that it only fetches it once, and caches the result in thePullRequestDetails
.This also changes it so that the diff gets parsed early on, instead of having every caller parse it. This should help make it a little more structured. Thus,
diff()
returns aVec<FileDiff>
, where each element is a single file.A walkthrough to help reviewing this PR:
FileDiff
type to represent a diff to a single file.PullRequestDetails
adds aOnceCell
to cache the PR diff.Issue.diff()
now returns a parsed result (instead of just a string), and caches the result.files_changed
was changed toparse_diff
to return a structured format.Issue.diff()
were updated to use the new format.assign.rs
input handler was changed to fetch the diff inhandle_input
instead ofparse_input
, due to not being able to pass a reference (and it wasn't important which function it was called in).