From cd328bfb612a9b1e55a919ff243daa0dde835cf3 Mon Sep 17 00:00:00 2001 From: Damien Tardy-Panis Date: Tue, 4 Oct 2016 20:59:38 +0200 Subject: [PATCH 01/13] stamp: add basic script --- bin/git-stamp | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100755 bin/git-stamp diff --git a/bin/git-stamp b/bin/git-stamp new file mode 100755 index 0000000..ebcf275 --- /dev/null +++ b/bin/git-stamp @@ -0,0 +1,66 @@ +#!/usr/bin/env bash + + +init_variables() { + COMMAND=${0#*-} + + unset ID +} + + +usage() { + cat << EOF +usage: git ${COMMAND} [] +EOF +} + + +error() { + if [[ -n "$1" ]]; then + local msg=$( echo "error: $1" | sed 's/\\n/\\n /g' ) + echo -e "${msg}" >&2 + fi + usage + exit 1 +} + + +stamp() { + local commit_msg=$( git log -1 --pretty=%B ) + + git commit --amend \ + --message "${commit_msg}" \ + --message "${ID}" +} + + +parse_options() { + while [[ "$#" -gt 0 ]]; do + case "$1" in + -h) + usage + exit 0 + ;; + *) + break + ;; + esac + done + + ID="$1" +} + + +validate_options() { + # ID should be set to non-empty string + if [[ -z "${ID}" ]]; then + error "missing stamp identifier" + fi +} + + +init_variables +parse_options "$@" +validate_options + +stamp \ No newline at end of file From 79629e6b6e0dd74d1ca8bb8c272a55a0793ba5aa Mon Sep 17 00:00:00 2001 From: Damien Tardy-Panis Date: Tue, 4 Oct 2016 21:02:42 +0200 Subject: [PATCH 02/13] stamp: add extra optional message parameter --- bin/git-stamp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/git-stamp b/bin/git-stamp index ebcf275..bda7fcf 100755 --- a/bin/git-stamp +++ b/bin/git-stamp @@ -5,12 +5,13 @@ init_variables() { COMMAND=${0#*-} unset ID + unset MSG } usage() { cat << EOF -usage: git ${COMMAND} [] +usage: git ${COMMAND} [] [] EOF } @@ -27,10 +28,12 @@ error() { stamp() { local commit_msg=$( git log -1 --pretty=%B ) + local stamp_msg + [[ -n "${MSG}" ]] && stamp_msg="${ID} ${MSG}" || stamp_msg="${ID}" git commit --amend \ --message "${commit_msg}" \ - --message "${ID}" + --message "${stamp_msg}" } @@ -48,6 +51,7 @@ parse_options() { done ID="$1" + MSG="$2" } From 3ffbe23fbec0d955dcf74535232c6cdb3972c45d Mon Sep 17 00:00:00 2001 From: Damien Tardy-Panis Date: Tue, 4 Oct 2016 21:04:01 +0200 Subject: [PATCH 03/13] stamp: display new full message as result --- bin/git-stamp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/bin/git-stamp b/bin/git-stamp index bda7fcf..4cfe08e 100755 --- a/bin/git-stamp +++ b/bin/git-stamp @@ -33,7 +33,11 @@ stamp() { git commit --amend \ --message "${commit_msg}" \ - --message "${stamp_msg}" + --message "${stamp_msg}" \ + > /dev/null + + # show result + git log -1 --pretty=full } From b105dd837a86aa9299132dd1cb400fc5a0926f1e Mon Sep 17 00:00:00 2001 From: Damien Tardy-Panis Date: Tue, 4 Oct 2016 21:20:27 +0200 Subject: [PATCH 04/13] stamp: add replace option replace all previous stamps with same identifier in commit message --- bin/git-stamp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/bin/git-stamp b/bin/git-stamp index 4cfe08e..6de567d 100755 --- a/bin/git-stamp +++ b/bin/git-stamp @@ -4,6 +4,7 @@ init_variables() { COMMAND=${0#*-} + REPLACE=false unset ID unset MSG } @@ -12,6 +13,9 @@ init_variables() { usage() { cat << EOF usage: git ${COMMAND} [] [] + +Options: + -r, --replace replace all previous stamps with same id EOF } @@ -31,6 +35,16 @@ stamp() { local stamp_msg [[ -n "${MSG}" ]] && stamp_msg="${ID} ${MSG}" || stamp_msg="${ID}" + if ${REPLACE}; then + # remove previous stamps with same ID from the commit message + commit_msg=$( + echo "${commit_msg}" \ + | grep --invert-match "^${ID}\b" \ + | cat --squeeze-blank + ) + fi + + # append the stamp to the commit message in a new paragraph git commit --amend \ --message "${commit_msg}" \ --message "${stamp_msg}" \ @@ -48,6 +62,10 @@ parse_options() { usage exit 0 ;; + --replace|-r) + REPLACE=true + shift + ;; *) break ;; From 13f15d53399b07f53b3b33356376cf96912284c6 Mon Sep 17 00:00:00 2001 From: Damien Tardy-Panis Date: Tue, 4 Oct 2016 22:02:42 +0200 Subject: [PATCH 05/13] stamp: add bash autocompletion --- etc/bash_completion.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/etc/bash_completion.sh b/etc/bash_completion.sh index ce404ca..a28d3f3 100644 --- a/etc/bash_completion.sh +++ b/etc/bash_completion.sh @@ -134,6 +134,10 @@ _git_scp(){ __git_complete_remote_or_refspec } +_git_stamp(){ + __gitcomp '--replace -r' +} + _git_rscp(){ __git_complete_remote_or_refspec } From 3b621f1052ccf10d80750b670f1c1975fde844bc Mon Sep 17 00:00:00 2001 From: Damien Tardy-Panis Date: Wed, 5 Oct 2016 21:59:31 +0200 Subject: [PATCH 06/13] stamp: add manual --- man/git-stamp.1 | 120 +++++++++++++++++++++++++++++++++ man/git-stamp.html | 161 +++++++++++++++++++++++++++++++++++++++++++++ man/git-stamp.md | 72 ++++++++++++++++++++ man/index.txt | 1 + 4 files changed, 354 insertions(+) create mode 100644 man/git-stamp.1 create mode 100644 man/git-stamp.html create mode 100644 man/git-stamp.md diff --git a/man/git-stamp.1 b/man/git-stamp.1 new file mode 100644 index 0000000..c36a45c --- /dev/null +++ b/man/git-stamp.1 @@ -0,0 +1,120 @@ +.\" generated with Ronn/v0.7.3 +.\" http://github.com/rtomayko/ronn/tree/0.7.3 +. +.TH "GIT\-STAMP" "1" "October 2016" "" "" +. +.SH "NAME" +\fBgit\-stamp\fR \- Stamp the last commit message +. +.SH "SYNOPSIS" +\fBgit stamp [] []\fR +. +.SH "DESCRIPTION" +Lets you amend the last commit with a stamp message\. +. +.P +The command appends a message with its identifier to the last commit message\. +. +.br +By default all stamps are appended as a new paragraph to the commit message\. +. +.br +You can change this behavior by using the \-\-replace flag\. +. +.br +With this flag, all the related stamps with the same identifier will be removed first before the new one gets appended\. +. +.SH "OPTIONS" +\-r, \-\-replace +. +.IP "" 4 +. +.nf + +Replace all previous stamps in the last commit message that have the same identifier +. +.fi +. +.IP "" 0 +. +.SH "EXAMPLES" +Commit message is +. +.IP "" 4 +. +.nf + +| Fix timezone bug +. +.fi +. +.IP "" 0 +. +.P +Reference the issues numbers from your bug tracker +. +.IP "" 4 +. +.nf + +$ git stamp Issue FOO\-123 +$ git stamp Issue "FOO\-456 #close" + +| Fix timezone bug +| +| Issue FOO\-123 +| +| Issue FOO\-456 #close +. +.fi +. +.IP "" 0 +. +.P +Link to its review page +. +.IP "" 4 +. +.nf + +$ git stamp Review https://reviews\.foo\.org/r/4567/ + +| Fix timezone bug +| +| Issue FOO\-123 +| +| Issue FOO\-456 #close +| +| Review https://reviews\.foo\.org/r/4567/ +. +.fi +. +.IP "" 0 +. +.P +Replace previous issues with a new one +. +.IP "" 4 +. +.nf + +$ git stamp \-\-replace Issue BAR\-123 + +| Fix timezone bug +| +| Review https://reviews\.foo\.org/r/4567/ +| +| Issue BAR\-123 +. +.fi +. +.IP "" 0 +. +.SH "AUTHOR" +Written by Damien Tardy\-Panis <\fIdamien@tardypad\.me\fR> +. +.SH "REPORTING BUGS" +<\fIhttp://github\.com/tj/git\-extras/issues\fR> +. +.SH "SEE ALSO" +<\fIhttps://github\.com/tj/git\-extras\fR> diff --git a/man/git-stamp.html b/man/git-stamp.html new file mode 100644 index 0000000..e2a4ae0 --- /dev/null +++ b/man/git-stamp.html @@ -0,0 +1,161 @@ + + + + + + git-stamp(1) - Stamp the last commit message + + + + +
+ + + +
    +
  1. git-stamp(1)
  2. +
  3. +
  4. git-stamp(1)
  5. +
+ +

NAME

+

+ git-stamp - Stamp the last commit message +

+ +

SYNOPSIS

+ +

git stamp [<options>] <id> [<message>]

+ +

DESCRIPTION

+ +

Lets you amend the last commit with a stamp message.

+ +

The command appends a message with its identifier to the last commit message.
+By default all stamps are appended as a new paragraph to the commit message.
+You can change this behavior by using the --replace flag.
+With this flag, all the related stamps with the same identifier will be removed first before the new one gets appended.

+ +

OPTIONS

+ +

-r, --replace

+ +
Replace all previous stamps in the last commit message that have the same identifier
+
+ +

EXAMPLES

+ +

Commit message is

+ +
| Fix timezone bug
+
+ +

Reference the issues numbers from your bug tracker

+ +
$ git stamp Issue FOO-123
+$ git stamp Issue "FOO-456 #close"
+
+| Fix timezone bug
+| 
+| Issue FOO-123
+| 
+| Issue FOO-456 #close
+
+ +

Link to its review page

+ +
$ git stamp Review https://reviews.foo.org/r/4567/
+
+| Fix timezone bug
+|
+| Issue FOO-123
+|
+| Issue FOO-456 #close
+| 
+| Review https://reviews.foo.org/r/4567/
+
+ +

Replace previous issues with a new one

+ +
$ git stamp --replace Issue BAR-123
+
+| Fix timezone bug
+|
+| Review https://reviews.foo.org/r/4567/
+|
+| Issue BAR-123
+
+ +

AUTHOR

+ +

Written by Damien Tardy-Panis <damien@tardypad.me>

+ +

REPORTING BUGS

+ +

<http://github.com/tj/git-extras/issues>

+ +

SEE ALSO

+ +

<https://github.com/tj/git-extras>

+ + +
    +
  1. +
  2. October 2016
  3. +
  4. git-stamp(1)
  5. +
+ +
+ + diff --git a/man/git-stamp.md b/man/git-stamp.md new file mode 100644 index 0000000..9a443f9 --- /dev/null +++ b/man/git-stamp.md @@ -0,0 +1,72 @@ +git-stamp(1) -- Stamp the last commit message +============================================= + +## SYNOPSIS + +`git stamp [] []` + +## DESCRIPTION + +Lets you amend the last commit with a stamp message. + +The command appends a message with its identifier to the last commit message. +By default all stamps are appended as a new paragraph to the commit message. +You can change this behavior by using the --replace flag. +With this flag, all the related stamps with the same identifier will be removed first before the new one gets appended. + +## OPTIONS + + -r, --replace + + Replace all previous stamps in the last commit message that have the same identifier + +## EXAMPLES + +Commit message is + + | Fix timezone bug + +Reference the issues numbers from your bug tracker + + $ git stamp Issue FOO-123 + $ git stamp Issue "FOO-456 #close" + + | Fix timezone bug + | + | Issue FOO-123 + | + | Issue FOO-456 #close + +Link to its review page + + $ git stamp Review https://reviews.foo.org/r/4567/ + + | Fix timezone bug + | + | Issue FOO-123 + | + | Issue FOO-456 #close + | + | Review https://reviews.foo.org/r/4567/ + +Replace previous issues with a new one + + $ git stamp --replace Issue BAR-123 + + | Fix timezone bug + | + | Review https://reviews.foo.org/r/4567/ + | + | Issue BAR-123 + +## AUTHOR + +Written by Damien Tardy-Panis <> + +## REPORTING BUGS + +<> + +## SEE ALSO + +<> diff --git a/man/index.txt b/man/index.txt index 304b50b..06b0363 100644 --- a/man/index.txt +++ b/man/index.txt @@ -51,6 +51,7 @@ git-show-merged-branches(1) git-show-merged-branches git-show-tree(1) git-show-tree git-show-unmerged-branches(1) git-show-unmerged-branches git-squash(1) git-squash +git-stamp(1) git-stamp git-summary(1) git-summary git-touch(1) git-touch git-undo(1) git-undo From 705bb32a7abf99d9756066f18c55491016999c9c Mon Sep 17 00:00:00 2001 From: Damien Tardy-Panis Date: Wed, 5 Oct 2016 22:02:00 +0200 Subject: [PATCH 07/13] stamp: add to Commands doc --- Commands.md | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/Commands.md b/Commands.md index 1ae01bb..44deb5d 100644 --- a/Commands.md +++ b/Commands.md @@ -56,6 +56,7 @@ - [`git show-merged-branches`](#git-show-merged-branches) - [`git show-tree`](#git-show-tree) - [`git show-unmerged-branches`](#git-show-unmerged-branches) + - [`git stamp`](#git-stamp) - [`git squash`](#git-squash) - [`git standup`](#git-standup) - [`git summary`](#git-summary) @@ -958,6 +959,57 @@ For example, running `git show-tree` will display: Be free to try it for yourself! + +## git stamp + +Stamp the last commit message + +Commit message is + +```bash +Fix timezone bug +``` + +Reference the issues numbers from your bug tracker + +```bash +$ git stamp Issue FOO-123 +$ git stamp Issue "FOO-456 #close" + +Fix timezone bug + +Issue FOO-123 + +Issue FOO-456 #close +``` + +Link to its review page + +```bash +$ git stamp Review https://reviews.foo.org/r/4567/ + +Fix timezone bug + +Issue FOO-123 + +Issue FOO-456 #close + +Review https://reviews.foo.org/r/4567/ +``` + +Replace previous issues with a new one + +```bash +$ git stamp --replace Issue BAR-123 + +Fix timezone bug + +Review https://reviews.foo.org/r/4567/ + +Issue BAR-123 +``` + + ## git standup Recall what you did or find what someone else did in a given range of time. From c9463bf6ef94b5833a9a195065e5d0fd7b32890a Mon Sep 17 00:00:00 2001 From: Damien Tardy-Panis Date: Wed, 5 Oct 2016 22:03:54 +0200 Subject: [PATCH 08/13] stamp: identifier is case insensitive for the replacement --- Commands.md | 7 ++++--- bin/git-stamp | 2 +- man/git-stamp.1 | 8 ++++++-- man/git-stamp.html | 18 ++++++++++-------- man/git-stamp.md | 10 ++++++---- 5 files changed, 27 insertions(+), 18 deletions(-) diff --git a/Commands.md b/Commands.md index 44deb5d..6e57189 100644 --- a/Commands.md +++ b/Commands.md @@ -997,16 +997,17 @@ Issue FOO-456 #close Review https://reviews.foo.org/r/4567/ ``` -Replace previous issues with a new one +Replace previous issues with a new one +(Note that the identifier is case insensitive) ```bash -$ git stamp --replace Issue BAR-123 +$ git stamp --replace issue BAR-123 Fix timezone bug Review https://reviews.foo.org/r/4567/ -Issue BAR-123 +issue BAR-123 ``` diff --git a/bin/git-stamp b/bin/git-stamp index 6de567d..0f48553 100755 --- a/bin/git-stamp +++ b/bin/git-stamp @@ -39,7 +39,7 @@ stamp() { # remove previous stamps with same ID from the commit message commit_msg=$( echo "${commit_msg}" \ - | grep --invert-match "^${ID}\b" \ + | grep --ignore-case --invert-match "^${ID}\b" \ | cat --squeeze-blank ) fi diff --git a/man/git-stamp.1 b/man/git-stamp.1 index c36a45c..ab723fb 100644 --- a/man/git-stamp.1 +++ b/man/git-stamp.1 @@ -32,6 +32,7 @@ With this flag, all the related stamps with the same identifier will be removed .nf Replace all previous stamps in the last commit message that have the same identifier +The identifier is case insensitive for this replacement . .fi . @@ -94,17 +95,20 @@ $ git stamp Review https://reviews\.foo\.org/r/4567/ .P Replace previous issues with a new one . +.br +(Note that the identifier is case insensitive) +. .IP "" 4 . .nf -$ git stamp \-\-replace Issue BAR\-123 +$ git stamp \-\-replace issue BAR\-123 | Fix timezone bug | | Review https://reviews\.foo\.org/r/4567/ | -| Issue BAR\-123 +| issue BAR\-123 . .fi . diff --git a/man/git-stamp.html b/man/git-stamp.html index e2a4ae0..501a9d4 100644 --- a/man/git-stamp.html +++ b/man/git-stamp.html @@ -91,7 +91,8 @@ With this flag, all the related stamps with the same identifier will be removed

-r, --replace

-
Replace all previous stamps in the last commit message that have the same identifier
+
Replace all previous stamps in the last commit message that have the same identifier  
+The identifier is case insensitive for this replacement
 

EXAMPLES

@@ -107,9 +108,9 @@ With this flag, all the related stamps with the same identifier will be removed $ git stamp Issue "FOO-456 #close" | Fix timezone bug -| +| | Issue FOO-123 -| +| | Issue FOO-456 #close
@@ -122,24 +123,25 @@ $ git stamp Issue "FOO-456 #close" | Issue FOO-123 | | Issue FOO-456 #close -| +| | Review https://reviews.foo.org/r/4567/ -

Replace previous issues with a new one

+

Replace previous issues with a new one
+(Note that the identifier is case insensitive)

-
$ git stamp --replace Issue BAR-123
+
$ git stamp --replace issue BAR-123
 
 | Fix timezone bug
 |
 | Review https://reviews.foo.org/r/4567/
 |
-| Issue BAR-123
+| issue BAR-123
 

AUTHOR

-

Written by Damien Tardy-Panis <damien@tardypad.me>

+

Written by Damien Tardy-Panis <damien@tardypad.me>

REPORTING BUGS

diff --git a/man/git-stamp.md b/man/git-stamp.md index 9a443f9..ada53fa 100644 --- a/man/git-stamp.md +++ b/man/git-stamp.md @@ -18,7 +18,8 @@ With this flag, all the related stamps with the same identifier will be removed -r, --replace - Replace all previous stamps in the last commit message that have the same identifier + Replace all previous stamps in the last commit message that have the same identifier + The identifier is case insensitive for this replacement ## EXAMPLES @@ -49,15 +50,16 @@ Link to its review page | | Review https://reviews.foo.org/r/4567/ -Replace previous issues with a new one +Replace previous issues with a new one +(Note that the identifier is case insensitive) - $ git stamp --replace Issue BAR-123 + $ git stamp --replace issue BAR-123 | Fix timezone bug | | Review https://reviews.foo.org/r/4567/ | - | Issue BAR-123 + | issue BAR-123 ## AUTHOR From 4aec48c85ceaf4eb2d8972bc2c34ed1e62386015 Mon Sep 17 00:00:00 2001 From: Damien Tardy-Panis Date: Wed, 5 Oct 2016 22:05:25 +0200 Subject: [PATCH 09/13] stamp: the message consists in all terms after the identifier no need to put quotes in case of spaces --- Commands.md | 2 +- bin/git-stamp | 4 ++-- man/git-stamp.1 | 4 ++-- man/git-stamp.html | 6 +++--- man/git-stamp.md | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Commands.md b/Commands.md index 6e57189..1eefefc 100644 --- a/Commands.md +++ b/Commands.md @@ -974,7 +974,7 @@ Reference the issues numbers from your bug tracker ```bash $ git stamp Issue FOO-123 -$ git stamp Issue "FOO-456 #close" +$ git stamp Issue FOO-456 \#close Fix timezone bug diff --git a/bin/git-stamp b/bin/git-stamp index 0f48553..1f0877c 100755 --- a/bin/git-stamp +++ b/bin/git-stamp @@ -12,7 +12,7 @@ init_variables() { usage() { cat << EOF -usage: git ${COMMAND} [] [] +usage: git ${COMMAND} [] [] Options: -r, --replace replace all previous stamps with same id @@ -73,7 +73,7 @@ parse_options() { done ID="$1" - MSG="$2" + MSG="${@:2}" } diff --git a/man/git-stamp.1 b/man/git-stamp.1 index ab723fb..207ed90 100644 --- a/man/git-stamp.1 +++ b/man/git-stamp.1 @@ -7,7 +7,7 @@ \fBgit\-stamp\fR \- Stamp the last commit message . .SH "SYNOPSIS" -\fBgit stamp [] []\fR +\fBgit stamp [] []\fR . .SH "DESCRIPTION" Lets you amend the last commit with a stamp message\. @@ -59,7 +59,7 @@ Reference the issues numbers from your bug tracker .nf $ git stamp Issue FOO\-123 -$ git stamp Issue "FOO\-456 #close" +$ git stamp Issue FOO\-456 \e#close | Fix timezone bug | diff --git a/man/git-stamp.html b/man/git-stamp.html index 501a9d4..776ee3d 100644 --- a/man/git-stamp.html +++ b/man/git-stamp.html @@ -76,7 +76,7 @@

SYNOPSIS

-

git stamp [<options>] <id> [<message>]

+

git stamp [<options>] <id> [<messages>]

DESCRIPTION

@@ -105,7 +105,7 @@ The identifier is case insensitive for this replacement

Reference the issues numbers from your bug tracker

$ git stamp Issue FOO-123
-$ git stamp Issue "FOO-456 #close"
+$ git stamp Issue FOO-456 \#close
 
 | Fix timezone bug
 |
@@ -141,7 +141,7 @@ $ git stamp Issue "FOO-456 #close"
 
 

AUTHOR

-

Written by Damien Tardy-Panis <damien@tardypad.me>

+

Written by Damien Tardy-Panis <damien@tardypad.me>

REPORTING BUGS

diff --git a/man/git-stamp.md b/man/git-stamp.md index ada53fa..d7d8975 100644 --- a/man/git-stamp.md +++ b/man/git-stamp.md @@ -3,7 +3,7 @@ git-stamp(1) -- Stamp the last commit message ## SYNOPSIS -`git stamp [] []` +`git stamp [] []` ## DESCRIPTION @@ -30,7 +30,7 @@ Commit message is Reference the issues numbers from your bug tracker $ git stamp Issue FOO-123 - $ git stamp Issue "FOO-456 #close" + $ git stamp Issue FOO-456 \#close | Fix timezone bug | From a118f306b17b9b3ba1222b5306ce8596aee8f688 Mon Sep 17 00:00:00 2001 From: Damien Tardy-Panis Date: Fri, 7 Oct 2016 17:41:53 +0200 Subject: [PATCH 10/13] stamp: remove non used multiple lines error messages --- bin/git-stamp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/git-stamp b/bin/git-stamp index 1f0877c..84fbd62 100755 --- a/bin/git-stamp +++ b/bin/git-stamp @@ -22,7 +22,7 @@ EOF error() { if [[ -n "$1" ]]; then - local msg=$( echo "error: $1" | sed 's/\\n/\\n /g' ) + local msg=$( echo "error: $1" ) echo -e "${msg}" >&2 fi usage From 9ea8f98e5c63aaef5da2881504f4d1560ccb0ee3 Mon Sep 17 00:00:00 2001 From: Damien Tardy-Panis Date: Fri, 7 Oct 2016 17:50:00 +0200 Subject: [PATCH 11/13] stamp: add zsh autocompletion --- etc/git-extras-completion.zsh | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/etc/git-extras-completion.zsh b/etc/git-extras-completion.zsh index 09be7a1..5bb7245 100644 --- a/etc/git-extras-completion.zsh +++ b/etc/git-extras-completion.zsh @@ -337,6 +337,10 @@ _git-squash() { ':branch-name:__gitex_branch_names' } +_git-stamp() { + _arguments -C \ + '(--replace -r)'{--replace,-r}'[replace stamps with same id]' +} _git-summary() { _arguments '--line[summarize with lines rather than commits]' @@ -407,6 +411,7 @@ zstyle ':completion:*:*:git:*' user-commands \ show-tree:'show branch tree of commit history' \ show-unmerged-branches:'show unmerged branches' \ squash:'import changes from a branch' \ + stamp:'stamp the last commit message' \ standup:'recall the commit history' \ summary:'show repository summary' \ sync:'sync local branch with remote branch' \ From a7779a1029dec5fd60f86479a8e41ce57d2c12b7 Mon Sep 17 00:00:00 2001 From: Damien Tardy-Panis Date: Fri, 7 Oct 2016 18:06:04 +0200 Subject: [PATCH 12/13] stamp: add warning in documentation about corner case --- man/git-stamp.1 | 3 +++ man/git-stamp.html | 4 +++- man/git-stamp.md | 2 ++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/man/git-stamp.1 b/man/git-stamp.1 index 207ed90..3c4d8b2 100644 --- a/man/git-stamp.1 +++ b/man/git-stamp.1 @@ -24,6 +24,9 @@ You can change this behavior by using the \-\-replace flag\. .br With this flag, all the related stamps with the same identifier will be removed first before the new one gets appended\. . +.P +\fBWARNING!\fR If a commit message without stamp have a line starting with the same identifier, it will be interpreted as a stamp +. .SH "OPTIONS" \-r, \-\-replace . diff --git a/man/git-stamp.html b/man/git-stamp.html index 776ee3d..f443963 100644 --- a/man/git-stamp.html +++ b/man/git-stamp.html @@ -87,6 +87,8 @@ By default all stamps are appended as a new paragraph to the commit message.
With this flag, all the related stamps with the same identifier will be removed first before the new one gets appended.

+

WARNING! If a commit message without stamp have a line starting with the same identifier, it will be interpreted as a stamp

+

OPTIONS

-r, --replace

@@ -141,7 +143,7 @@ $ git stamp Issue FOO-456 \#close

AUTHOR

-

Written by Damien Tardy-Panis <damien@tardypad.me>

+

Written by Damien Tardy-Panis <damien@tardypad.me>

REPORTING BUGS

diff --git a/man/git-stamp.md b/man/git-stamp.md index d7d8975..da97c68 100644 --- a/man/git-stamp.md +++ b/man/git-stamp.md @@ -14,6 +14,8 @@ By default all stamps are appended as a new paragraph to the commit message. You can change this behavior by using the --replace flag. With this flag, all the related stamps with the same identifier will be removed first before the new one gets appended. +`WARNING!` If a commit message without stamp have a line starting with the same identifier, it will be interpreted as a stamp + ## OPTIONS -r, --replace From c5bd28dd51733634f6b26ca3ef12bbbd33d71423 Mon Sep 17 00:00:00 2001 From: Damien Tardy-Panis Date: Fri, 7 Oct 2016 18:22:40 +0200 Subject: [PATCH 13/13] stamp: show real looking results in Commands.md doc --- Commands.md | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/Commands.md b/Commands.md index 1eefefc..cba10d3 100644 --- a/Commands.md +++ b/Commands.md @@ -974,13 +974,26 @@ Reference the issues numbers from your bug tracker ```bash $ git stamp Issue FOO-123 + +commit 787590e42c9bacd249f3b79faee7aecdc9de28ec +Author: Jack +Commit: Jack + + Fix timezone bug + + Issue FOO-123 + $ git stamp Issue FOO-456 \#close -Fix timezone bug +commit f8d920511e052bea39ce2088d1d723b475aeff87 +Author: Jack +Commit: Jack -Issue FOO-123 + Fix timezone bug -Issue FOO-456 #close + Issue FOO-123 + + Issue FOO-456 #close ``` Link to its review page @@ -988,13 +1001,17 @@ Link to its review page ```bash $ git stamp Review https://reviews.foo.org/r/4567/ -Fix timezone bug +commit 6c6bcf43bd32a76e37b6fc9708d3ff0ae723c7da +Author: Jack +Commit: Jack -Issue FOO-123 + Fix timezone bug -Issue FOO-456 #close + Issue FOO-123 -Review https://reviews.foo.org/r/4567/ + Issue FOO-456 #close + + Review https://reviews.foo.org/r/4567/ ``` Replace previous issues with a new one @@ -1003,11 +1020,15 @@ Replace previous issues with a new one ```bash $ git stamp --replace issue BAR-123 -Fix timezone bug +commit 2b93c56b2340578cc3478008e2cadb05a7bcccfa +Author: Jack +Commit: Jack -Review https://reviews.foo.org/r/4567/ + Fix timezone bug -issue BAR-123 + Review https://reviews.foo.org/r/4567/ + + issue BAR-123 ```