aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2020-09-20Increase version v0.2.0 -> v0.2.1HEADv0.2.1masterTeddy Wing
2020-09-20Build a static binaryTeddy Wing
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
2020-08-30Update TODOTeddy Wing
2020-08-30Increase version v0.1.0 -> v0.2.0v0.2.0Teddy Wing
2020-08-30git-suggestion-cli: Rename crate to `git-suggestion`Teddy Wing
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.
2020-08-30doc/git-sugdiff.1: Add a note about Git diff option supportTeddy Wing
Not sure if I should be emphasising this more.
2020-08-30diff_options: Add doc commentsTeddy Wing
2020-08-30diff_options: Sort and uniq `FLAGS`Teddy Wing
Make the list easier to scan by ordering it alphabetically. Also, I noticed there were two `-p` flags listed, so ran the flags through `uniq`.
2020-08-30diff_options::parse(): Rename `found_args` to `diff_args`Teddy Wing
Now that I added `program_args`, reading this back over I realised `found_args` didn't convey enough information about what it contains.
2020-08-30diff_options: Merge `FLAGS` and `OPTIONS`Teddy Wing
Didn't look closely enough in d9b8838a5d99e643a751d042047644cfa4a9a032, but we now have the exact same handling for key-value options and flags.
2020-08-30diff_options: Merge `ARG_OPTIONS` and `OPT_OPTIONS`Teddy Wing
Now that I've confirmed that Git's key value options require an '=' to specify the value, we can drop the distinction between options that require and argument and those that optionally take an argument. Also remove the code that interprets an argument that doesn't start with '-' as the value of the preceding option.
2020-08-30diff_options: Clean up codeTeddy Wing
Remove old process code and comments.
2020-08-29git-sugdiff: Fix output by waiting for child processTeddy Wing
I thought I'd resolved this problem by adding the `--no-pager` flag in 76079daf1e2175d02c9c584e47a21650fce30bb6, but it turns out that didn't fix it. When running the command, I'd get the following output, with the shell prompt preceding the start of the diff, and the command hanging without exiting to a new prompt line until a new interaction: $ ./target/debug/git-sugdiff 459692838 $ diff --git a/src/server.rs b/44ff3b520321467a9220965d13f997690ff3fda7 index d9eee95..44ff3b5 100644 --- a/src/server.rs +++ b/44ff3b520321467a9220965d13f997690ff3fda7 @@ -73,7 +73,7 @@ impl Server { internal_server_error(&mut raw_request.stdout()) }, Error::ConduitResponse { .. } => { error!("Error [-getting-]{+from+} response: {}", e); internal_server_error(&mut raw_request.stdout()) }, Turns out I need to wait for the command to exit in order to properly execute the external command.
2020-08-29diff_options: Remove non-equals argument value handlingTeddy Wing
Tested out diff arguments with Git, and it turns out that arguments in the following form: $ git diff --word-diff color are not allowed. This error results: fatal: ambiguous argument 'color': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' Thus, option all arguments require the equals character to specify the value of those arguments. We can make the logic much simpler by eliminating handling of space-separated argument values altogether. This fixes the problem of suggestion positional arguments being misinterpreted as `OPT_OPTIONS` argument values.
2020-08-29git-sugdiff: Use `diff_options.parse()` to extract diff optionsTeddy Wing
Config::get(): Change `args` type so we can pass both a `Vec<String>` and `Vec<&String>`. diff_options.parse(): * Split diff arguments and program arguments by returning a tuple. * Exit the args loop once we've parsed an argument. * Update test * Add a non-working test for suggestion arguments. An `OPT_OPTIONS` argument could be followed by an argument that's not the value of the `OPT_OPTIONS` option. Currently, that arg will always be parsed as the value. We need to handle this case.
2020-08-26Add `diff_options` to parse Git diff optionsTeddy Wing
In order to accept Git diff options on the command line, we need a way to extract these from args. Add a function to parse diff options. These were sourced from: https://github.com/git/git/blob/675a4aaf3b226c0089108221b96559e0baae5de9/Documentation/diff-options.txt The function loops through the input arguments and extracts all diff options and their values. Still needs some work to integrate it into `git-sugdiff`, but it currently works as advertised.
2020-08-24Update TODOTeddy Wing
2020-08-23git-sugdiff: Replace `unwrap`s with proper error handlingTeddy Wing
2020-08-23Update TODOTeddy Wing
2020-08-23Rename `git-sugpatch` to `git-sugdiff`Teddy Wing
The word "patch" reminds me more of the `patch` Unix command, which is what `git-sugapply` does. Since this command outputs diffs, it makes more sense to call it `sugdiff`. That also brings these closer to the native Git commands, `git-diff` and `git-apply`. I had chosen "patch" originally because the command generated a unified diff that could be used as a patch file to apply to the repo.
2020-08-23git-sugdiff: Remove TODOTeddy Wing
This works now, thanks to 3c6f337e26964077d1ce629fa17d16e4484b877f.
2020-08-23Suggestion: Add doc comments for the recent blob changesTeddy Wing
2020-08-23Suggestion: Rename `diff_command()` to `blob()`Teddy Wing
This function is no longer calling the `git diff` command, so this name doesn't make sense.
2020-08-23git-sugdiff: Add `--no-pager` to `git diff` commandTeddy Wing
The diff command wasn't exiting after outputting the diff. Add the `--no-pager` argument to ensure that the pager doesn't activate. This also seems to cause the command to exit once all the output is printed. We don't want the pager because we need to call `git diff` for each suggestion. If an early diff took up more than a page and activated the pager, that would block the next diffs from appearing. We want them all to appear at once.
2020-08-23Revert "Suggestion.diff_command: Diff an index instead of a file"Teddy Wing
This reverts commit 588cd526fd78b3a0e0ec1dfb9fc194ca385de902. Since each suggestion has its own associated commit, we can't compare a tree and a single commit. We'll probably have to invoke `git diff` once for each suggestion.
2020-08-23Suggestion.diff_command: Diff an index instead of a fileTeddy Wing
This will enable us to use the `git diff` command with more than one suggestion at the same time. We compare the commit of the suggestion with the new index's tree. And as I write this, I'm realising that we can't diff multiple suggestions using the same commit because each suggestion has its own commit. Need to work out a different way to do this.
2020-08-22Suggestion.diff_command: Return the right side version blobTeddy Wing
Don't run the `git diff` command in this function, instead return the new blob created for the right hand side of the comparison. This will facilitate showing the diffs of multiple suggestions at once. Maybe. I haven't tried the command yet. Actually, looking at the man page, it doesn't say we can include more than one blob pair, so I might need to put all of the suggestion changes into a single blob and compare the original commit with that.
2020-08-22Execute `git diff` to output diffsTeddy Wing
I want to enable colour diff output. At first, I thought about doing this by getting the diff colours from the Git config, then outputting the ANSI escape codes manually with the text. However, I then thought it would be nice to enable other diff features like `--word-diff`, and it would be too much trouble to re-implement that manually, and then I'd have to take word diff colouring into account. Decided that the optimal way to get both colours and extra diff features like word diffing would be to use `git diff` directly under the hood. We shell out to `git diff`, and give it the original file as a base, and a new blob object that we create in the repository on the right side. This allows us to compare the file using a command in the following format: $ git diff <BASE>:src/server.rs <TEMPORARY_HASH> Ostensibly, the temporary blob object I create for the right side version should be freed automatically by `git2`. Add a new `sugdiff` command to output diffs. This will replace `sugpatch`. Since we're working with diffs, I think a name with "diff" sounds more logical. The previous version, "patch" sounds too much like what "apply" does, because of the Unix `patch` command.
2020-08-22Update TODOTeddy Wing
2020-08-06Increase version v0.0.1 -> v0.1.0v0.1.0Teddy Wing
2020-08-06Remove `github-suggestion/Cargo.lock`Teddy Wing
This is subsumed into `Cargo.lock` and doesn't do anything any more.
2020-08-06TODO: Explain `git-sugcommit`Teddy Wing
Probably not going to do this one as it's not always possible to get the commenter's name and email address, and even then it might not be the same as what they use in the repo.
2020-08-06Makefile: Package `dist/` into a bundled archive for releaseTeddy Wing
2020-08-06Makefile: Remove unused list of productsTeddy Wing
This was replaced by `RELEASE_PRODUCTS` so that I could make `DIST_PRODUCTS` based on `PRODUCTS`.
2020-08-06Makefile: Put distribution binaries in `dist/bin/`Teddy Wing
2020-08-06Makefile: Put distribution man pages in `dist/share/man/man1/`Teddy Wing
2020-08-06Makefile: Copy release products to `dist/`Teddy Wing
Add recipes to build release targets and copy the binaries and man pages into the `dist/` folder. We'll use this to package a release archive.
2020-08-06README: Update install/uninstall commandsTeddy Wing
Got an error: error: failed to open: /usr/local/.crates.toml when I tried the command with the `--root /usr/local` argument, so decided to remove it. Need to use the root crate name in the `cargo uninstall` command.
2020-08-06Rename the project `git-suggestion`Teddy Wing
Since this is a Git command, this makes more sense to me.
2020-08-05Add READMETeddy Wing
Found a suggestion on the `gh` GitHub CLI project page from 'mislav' (https://github.com/mislav) and 'probablycorey' (https://github.com/probablycorey) to use as an example. Haven't tested the install/uninstall instructions yet (copied these from another one of my projects).
2020-08-05OwnerRepo: Remove ".git" suffix from HTTPS URLsTeddy Wing
I hadn't tested with HTTPS remote URLs, so assumed the code I copied from `github_suggestion::url` would work. It worked for suggestion comment URLs, but it doesn't work for remote URLs because the latter end in ".git". Remove this suffix to fix the bug.
2020-08-05client::Error::Deserialize: Include source error messageTeddy Wing
Forgot to include this so we didn't get extra information about the cause of the error.
2020-08-04Add license (GNU GPLv3+)Teddy Wing
2020-08-04Update TODOTeddy Wing
2020-08-04Add man page for `git-sugapply`Teddy Wing
Copied from `git-sugpatch.1`, since the general elements are basically the same. Modified to describe the specifics of the `git-sugapply` command.
2020-08-04doc/git-sugpatch.1: Add values to command line optionsTeddy Wing
Make it clear that these options require argument values.
2020-08-04doc/git-sugpatch.1: Use the same ID in the URL and ID examplesTeddy Wing
To make it clear which ID needs to be used when using the short form.
2020-08-04doc/git-sugpatch.1: Clarify precedence of configuration optionsTeddy Wing
2020-08-04Add man page for `git-sugpatch`Teddy Wing
2020-08-03Update TODOTeddy Wing