Age | Commit message (Collapse) | Author |
|
I recently tried installing the program via Homebrew on a machine that
didn't have 'libgit2' installed. The Homebrew formula installs pre-built
binaries. Running the binaries gave me an error saying that the
'libgit2' dynamic library couldn't be found.
Change the build configuration to build a "static" binary. It still
links to system dylibs, but I've removed all links to Homebrew dylibs.
These were:
* libgit2
* openssl
Removed the 'openssl' link by adding the 'vendored-openssl' feature to
the 'git2' dependency.
In order to remove the 'libgit2' link, I had to do some more finagling.
Accomplished this by setting an empty `PKG_CONFIG_LIBDIR` when building.
While 'git2' doesn't have a Cargo feature to disable dynamic linking, we
can force static linking by preventing `pkg-config` from finding the
Homebrew-installed 'libgit2'. The 'libgit2-sys' crate's build script
first checks for the library using `pkg-config`, and builds it
statically if it doesn't exist:
https://github.com/rust-lang/git2-rs/blob/43d583fd8b50fad0cfe0bbc334059ce965b6f3fc/libgit2-sys/build.rs#L15-L17
With these changes, the above packages will now be statically linked
with the program's binaries.
Upgrade 'git2' to the latest version (0.13.11) since we're changing its
build configuration.
Before:
$ otool -L target/release/git-sug*
target/release/git-sugapply:
/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 57740.60.18)
/usr/local/opt/libgit2/lib/libgit2.1.0.dylib (compatibility version 1.0.0, current version 1.0.1)
/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.8)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2)
/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
target/release/git-sugapply.d: is not an object file
target/release/git-sugdiff:
/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 57740.60.18)
/usr/local/opt/libgit2/lib/libgit2.1.0.dylib (compatibility version 1.0.0, current version 1.0.1)
/usr/local/opt/openssl@1.1/lib/libssl.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/usr/local/opt/openssl@1.1/lib/libcrypto.1.1.dylib (compatibility version 1.1.0, current version 1.1.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.8)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2)
/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
target/release/git-sugdiff.d: is not an object file
After:
$ otool -L target/release/git-sug*
target/release/git-sugapply:
/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 57740.60.18)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1349.8.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.8)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2)
/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
target/release/git-sugapply.d: is not an object file
target/release/git-sugdiff:
/System/Library/Frameworks/Security.framework/Versions/A/Security (compatibility version 1.0.0, current version 57740.60.18)
/usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0)
/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1349.8.0)
/usr/lib/libz.1.dylib (compatibility version 1.0.0, current version 1.2.8)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1238.60.2)
/usr/lib/libresolv.9.dylib (compatibility version 1.0.0, current version 1.0.0)
target/release/git-sugdiff.d: is not an object file
|
|
|
|
Now that I'm using the name "git-suggestion" in a few places, and from a
user perspective, it's more Git-oriented than GitHub-oriented, I think
the crate should be renamed to reflect that.
|
|
|
|
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
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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
|