Age | Commit message (Collapse) | Author |
|
An executable to apply a suggested change to the appropriate file in the
repo.
Add a new `SuggestionUrl` type that allows us to extract the necessary
data to fetch a suggestion comment from the GitHub API using a GitHub
pull request comment URL.
|
|
Replace common code with a call to `Suggestion.apply_to()`.
|
|
I didn't feel like writing a test for `Suggestion.apply()`, which writes
files, so decided to write a different version that used the original
file and a writer.
Changed the `Suggestion.suggestion()` function to not prepend "+" to
suggestion lines so we can use the function to extract the suggested
lines unmodified from the comment. Kept the old version around as
`suggestion_patch()` because we may need it to generate patches.
Copied the code from `Suggestion.apply()`, except write the changes to
`writer` instead of the file at `Suggestion.path`.
|
|
Add the new fields from `Suggestion`.
|
|
The name "suggestion" sounds like the suggested diff change, when really
this field will be deserialised with the whole GitHub comment, including
adjacent text as well as the suggestion.
|
|
Haven't tested this yet.
To keep the original file's metadata, try writing the changes to the
original instead of the temporary file. First copy the original to a new
file that we can reference after truncating the original, then write the
change onto the original.
|
|
Not working yet, but the idea is to get the file referenced by the
suggestion and apply the suggested change directly to it.
Here, we read the original file, and write its contents to the new file,
replacing the lines modified by the suggestion with the suggested
change.
Currently doesn't work because you can't pass file instances to
`fs::rename`, only paths.
I'd like to try a slightly different system so I can keep the original
file's creation date. With the current system, it would be overwritten
by the new temporary file created to store the change.
|
|
|
|
Work out the code required to get a file blob's contents from a Git
repository using the 'git2' crate.
We'll be using this to get the original file for patching.
|
|
Will test patching a file using the generated suggestion patch.
|
|
Testing out 'unidiff' to build the patch. Trying to see if it will
adjust the line numbers automatically when the patch is modified.
Doesn't look like it. Seems like it has a nice interface, though.
Still having trouble applying the patch due to complaints of patch
format errors.
|
|
Update the regex matcher to allow both LF line endings and CRLF.
|
|
Describe the source of the test data.
|
|
Still working on it, but have an initial draft working. There's no file
name in the diff hunk, so I'm assuming I'm going to have to add one
later.
Build a patch from the diff hunk and suggestion comment.
1. Remove `-` lines
2. Change `+` lines to ` `
3. Change last line to `-`
4. Append suggestion to the diff with a `+` prefix
|
|
Split the `Suggestion` struct into a new `Client` struct for the GitHub
request, and `Suggestion` for the required response data.
|
|
Add a `Suggestion` struct to represent a GitHub PR suggestion comment.
Use the 'github-rs' library to fetch a given comment from the site by
its ID.
Converted the 'github-rs' error into a string because its
`github_rs::client::Error` type is private, so I can't define an error
variant source with that type.
|
|
Initialised with:
$ cargo init --bin
|