From fd63548311453520eef6d20908ff6fc8454d11df Mon Sep 17 00:00:00 2001 From: Teddy Wing Date: Wed, 5 Aug 2020 01:41:28 +0200 Subject: Add README 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). --- README.md | 80 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 80 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..4d90d54 --- /dev/null +++ b/README.md @@ -0,0 +1,80 @@ +github-suggestion +================= + +Diffs and patches for GitHub pull request suggestions. Given a suggestion ID, +get a unified diff of the suggested change, or apply it directly to the working +copy in a Git repository. + + +## Examples + + $ git clone https://github.com/cli/cli.git + Cloning into 'cli'... + … + $ cd cli/ + $ git checkout 74a39f3 + Note: checking out '74a39f3'. + … + $ git sugpatch https://github.com/cli/cli/pull/1150#discussion_r438352211 + diff --git a/pkg/cmd/api/api.go b/pkg/cmd/api/api.go + index b4a8dbd..c081b50 100644 + --- a/pkg/cmd/api/api.go + +++ b/pkg/cmd/api/api.go + @@ -247,8 +247,7 @@ func readUserFile(fn string, stdin io.ReadCloser) ([]byte, error) { + if fn == "-" { + r = stdin + } else { + - var err error + - r, err = os.Open(fn) + + r, err := os.Open(fn) + if err != nil { + return nil, err + } + $ git status + HEAD detached at 74a39f3 + nothing to commit, working tree clean + $ git sugapply 438352211 + $ git status + HEAD detached at 74a39f3 + Changes not staged for commit: + (use "git add ..." to update what will be committed) + (use "git checkout -- ..." to discard changes in working directory) + + modified: pkg/cmd/api/api.go + + no changes added to commit (use "git add" and/or "git commit -a") + $ git diff + diff --git a/pkg/cmd/api/api.go b/pkg/cmd/api/api.go + index b4a8dbd..c081b50 100644 + --- a/pkg/cmd/api/api.go + +++ b/pkg/cmd/api/api.go + @@ -247,8 +247,7 @@ func readUserFile(fn string, stdin io.ReadCloser) ([]byte, error) { + if fn == "-" { + r = stdin + } else { + - var err error + - r, err = os.Open(fn) + + r, err := os.Open(fn) + if err != nil { + return nil, err + } + + +## Install +On Mac OS X, GitHub-Suggestion can be installed with Homebrew: + + $ brew install teddywing/formulae/github-suggestion + +To compile from source or install on other platforms: + + $ cargo install --git https://github.com/teddywing/github-suggestion.git --root /usr/local + + +## Uninstall + + $ cargo uninstall --root /usr/local github-suggestion + + +## License +Copyright © 2020 Teddy Wing. Licensed under the GNU GPLv3+ (see the included +COPYING file). -- cgit v1.2.3