From 5b62b4a8842e1cdae1c454e7a4b9a999805a7565 Mon Sep 17 00:00:00 2001 From: Paul Wise Date: Mon, 6 Nov 2017 14:02:23 +0800 Subject: [PATCH] Add git-paste for sending patches to pastebin --- Commands.md | 25 +++++++++++++++++ bin/git-paste | 5 ++++ etc/git-extras-completion.zsh | 1 + man/git-paste.md | 51 +++++++++++++++++++++++++++++++++++ 4 files changed, 82 insertions(+) create mode 100755 bin/git-paste create mode 100644 man/git-paste.md diff --git a/Commands.md b/Commands.md index e7c2487..eb9b7c8 100644 --- a/Commands.md +++ b/Commands.md @@ -39,6 +39,7 @@ - [`git missing`](#git-missing) - [`git mr`](#git-mr) - [`git obliterate`](#git-obliterate) + - [`git paste`](#git-paste) - [`git pr`](#git-pr) - [`git psykorebase`](#git-psykorebase) - [`git pull-request`](#git-pull-request) @@ -1273,6 +1274,30 @@ Switched to branch 'mr/51' Just like [git pr](#git-pr), `git mr` accepts a `clean` argument to trash all `mr/` branches. Ensure current branch is not one. +## git paste + +Sends commits to a pastebin site using pastebinit. + +By default it sends the commits between your current branch +and the branch your current branch is based on (the upstream branch). + +``` bash +$ git paste +https://paste.debian.net/1234567/ +``` + +All options are passed to `git format-patch --stdout` +so you can also pass options understood by `git-rev-parse(1)` +in order to select a different set of commits. + +``` bash +$ git paste @^ +https://paste.debian.net/1234567/ +``` + +See the [pastebinit documentation](https://manpages.debian.org/pastebinit) +for information about how to chose a different pastebin site to the default. + ## git pr Checks out a pull request from GitHub diff --git a/bin/git-paste b/bin/git-paste new file mode 100755 index 0000000..1b1c5ce --- /dev/null +++ b/bin/git-paste @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +set -e +set -o pipefail +test $# -ne 0 || set -- '@{u}' +git format-patch --stdout "$@" | pastebinit -f diff diff --git a/etc/git-extras-completion.zsh b/etc/git-extras-completion.zsh index 672ded7..dd3c180 100644 --- a/etc/git-extras-completion.zsh +++ b/etc/git-extras-completion.zsh @@ -476,6 +476,7 @@ zstyle ':completion:*:*:git:*' user-commands $existing_user_commands \ missing:'show commits missing from another branch' \ mr:'checks out a merge request locally' \ obliterate:'rewrite past commits to remove some files' \ + paste:'send patches to pastebin sites' \ pr:'checks out a pull request locally' \ psykorebase:'rebase a branch with a merge commit' \ pull-request:'create pull request to GitHub project' \ diff --git a/man/git-paste.md b/man/git-paste.md new file mode 100644 index 0000000..76a37e6 --- /dev/null +++ b/man/git-paste.md @@ -0,0 +1,51 @@ +git-paste(1) -- Send patches to pastebin for chat conversations +=============================================================== + +## SYNOPSIS + +`git-paste` <git format-patch options> + +## DESCRIPTION + + Send patches to pastebin for chat conversations using pastebinit. + The syntax highlighting will be set to 'diff'. + +## OPTIONS + + <git format-patch options> + + All options are passed directly to `git format-patch`. + Given no arguments, `git-paste` passes `@{u}` to `git format-patch`. + +## CONFIGURATION + + The pastebinit software chooses the most appropriate pastebin site + for your operating system and the [pastebinit documentation](https://manpages.debian.org/pastebinit) + contains details of how to configure it to use a different site. + +## EXAMPLES + + Pastebin the patches between the current branch and its upstream: + + $ git paste + $ git paste @{u} + + Pastebin the latest commit: + + $ git paste -1 + + Pastebin the latest three commits: + + $ git paste -3 + +## AUTHOR + +Written by Paul Wise <> + +## REPORTING BUGS + +<> + +## SEE ALSO + +<>