Age | Commit message (Collapse) | Author |
|
Allow getting the program version from the command line.
|
|
|
|
We have multiple binaries in `src/bin/`, so this file is no longer
needed.
|
|
Light documentation for our various functions and types.
|
|
|
|
|
|
Since this check for suggestion arguments is in both binaries, we can
move it to the common preflight function.
Clean up other areas now that we moved the function.
|
|
Use the new logic from `git-sugpatch` to build a `Config` and run
`apply()` on all suggestion input arguments.
|
|
|
|
|
|
Print usage on `-h` and `--help`.
Store the usage brief on `Config` in order to be able to print it from
multiple places.
|
|
Add `Options` to `Config` to allow us to get a usage string from a
`Config` instance, which is where we create `Options`.
Needed to remove the `Debug` derive on `Config` in order to add the
field as `Options` doesn't implement `Debug`.
|
|
This was a test, before I worked out the API for this function.
|
|
|
|
Replace my test exit code with a real one.
|
|
|
|
|
|
Print the error and exit.
|
|
Turns out this didn't need to be public at all.
|
|
Split this out into a separate function because I want to reuse it in
`git-sugapply`.
|
|
Forgot to change this line when I set up the loop over suggestion
arguments. We want to parse the current argument instead of hard-coding
the first one.
|
|
|
|
Made this `pub` for one of the test tries in
38a871f28bad90e238021d8cc46b9fa926f9df75, but in the end it wasn't
necessary. Restore this to the prior visibility.
|
|
The source error's message doesn't include the name. Ensure we print the
name of the variable we're trying to get so that users know which one is
missing.
|
|
Ensure the source error is surfaced.
|
|
Remove unused code.
|
|
We want to allow not having a remote when URL arguments are given, but
require it when a suggestion ID argument is given (otherwise we wouldn't
have an owner-repo pair to make the GitHub request).
Had some trouble with the `OwnerRepo.o_r` value. It was being moved into
the closure, so tried a loop. There was a similar problem with the loop.
However, by returning, I was able to get a reference to the `Result`
instead of having it be moved.
|
|
Add `exitcode` to exit with an appropriate code.
Add the `gseprintln` macro to wrap `eprintln!()`, prefixing the output
with "error: ".
|
|
Add the ability to pass multiple suggestions to the binary. The diffs
will appear in the output one after another.
Also allow suggestions to be specified by their comment ID instead of
their full URL. This uses the Git repo's remote to determine the
owner-repo pair. When a URL argument is given, the owner-repo pair is
extracted from the URL.
It's now possible to call the binary like this:
$ git-sugpatch 459692838 \
> https://github.com/teddywing/suggestion-test/pull/1#discussion_r459691747
|
|
Store the suggestion references specified on the command line.
|
|
Remotes can be HTTP URLs or use SSH/SCP-style paths like:
git@github.com/teddywing/github-suggestion.git
We need to handle both regular URLs and the above style, which isn't
parseable by the 'url' crate.
Add a custom parsing function to get the owner and repo from this
format.
When trying to parse `OwnerRepo` from a string, first try to parse it as
a URL. If that fails with a `RelativeUrlWithoutBase` error, assume it's
the other style of reference.
|
|
|
|
Improve organisation.
|
|
We need the following values in order to build a `Client`:
* GitHub token
* Repo owner
* Repo name
Get the token from a command-line argument, or else the Git config, or
else an environment variable.
Get the repo identifiers from the repo's remote URL. Use the remote
specified as a command-line argument, otherwise get it from the Git
config, or else default to "origin".
TODO: Only try to get the owner-name pair from the remote if a comment
ID was given, not if a URL argument was passed.
|
|
|
|
Since this function returns an `OwnerRepo`, make it a method on the
struct.
|
|
Need to add other code to the library.
|
|
This will be used by the binaries.
|
|
Keep the binaries in the root crate, and add a new crate for the
`github-suggestion` library.
I want to add some library code to the CLI programs to extract common
functionality between the different binaries.
|
|
Going to use this for more cli-oriented code, so that the binaries can
share more logic.
|
|
This will allow us to accept suggestion IDs alone, without a full URL,
like the following:
$ git sugapply 459691747
# or
$ git sugapply --remote upstream 459691747
# or
$ git config github-suggestion.remote upstream
$ git sugapply 459691747
We do this by extracting the pair from the remote URL.
|
|
We need two segments in the path to parse the owner-repo combination.
|
|
Ended up not using this. Instead used 'git2' to generate the diff.
|
|
|
|
|
|
Didn't like the old name. Wanted to make the GitHub reference more
explicit. I remember it as "suggestion", since that's the name of the
GitHub feature, so "suggested" was confusing. The final "patch" seemed
redundant or unnecessary.
|
|
These weren't actual tests. I was using them to research different
implementation approaches.
|
|
Replace `unwrap`s with trys.
|
|
Remove the `unwrap` in this method and return a `Result`.
|
|
These methods are no longer used.
|