mirror of
https://github.com/michaeldv/pit.git
synced 2025-12-08 23:53:25 +00:00
Treat leading or trailing digits in Git branch name as Pit task number
This commit is contained in:
26
README.md
26
README.md
@@ -58,27 +58,29 @@ Pit distribution comes with tools/commit-msg file. Copy this file to
|
|||||||
$ cp ~/pit/tools/commit-msg .git/hooks
|
$ cp ~/pit/tools/commit-msg .git/hooks
|
||||||
$ chmod +x .git/hooks/commit-msg
|
$ chmod +x .git/hooks/commit-msg
|
||||||
|
|
||||||
Create git branch using task number as a branch name. Now on every commit to
|
Create Git branch using Pit task number as leading or trailing digits of the
|
||||||
the branch the hook will prompt you to update task status. The hook appends
|
branch name. Now on every commit to the branch the hook will prompt you to
|
||||||
Pit task number to the commit message, updates Pit task status, and creates
|
update task status. The hook appends Pit task number to the commit message,
|
||||||
task note with the commit massage. For example:
|
updates Pit task status, and creates task note with the commit massage.
|
||||||
|
|
||||||
$ git checkout -b 2
|
For example:
|
||||||
Switched to a new branch '2'
|
|
||||||
|
$ git checkout -b bugfix-42
|
||||||
|
Switched to a new branch 'bugfix-42'
|
||||||
|
|
||||||
$ touch README
|
$ touch README
|
||||||
$ git add .
|
$ git add .
|
||||||
$ git commit -am "Added README file"
|
$ git commit -am "Added README file"
|
||||||
What is the status of task 2?
|
What is the status of task 42?
|
||||||
(I)n progress
|
(I)n progress
|
||||||
(P)ostponed
|
(P)ostponed
|
||||||
(O)pen
|
(O)pen
|
||||||
(D)one
|
(D)one
|
||||||
Enter the status for task 2 [D]:
|
Enter the status for task 42 [D]:
|
||||||
i
|
i
|
||||||
updated task 2: My second task (status: in progress)
|
updated task 42: My second task (status: in progress)
|
||||||
created note 2: Added README file [task 2, status:in progress] (task 2)
|
created note 42: Added README file [task 42, status:in progress] (task 42)
|
||||||
[2 0d930fb] Added README file [task 2, status:in progress]
|
[bugfix-2 0d930fb] Added README file [task 42, status:in progress]
|
||||||
0 files changed, 0 insertions(+), 0 deletions(-)
|
0 files changed, 0 insertions(+), 0 deletions(-)
|
||||||
create mode 100644 README
|
create mode 100644 README
|
||||||
|
|
||||||
@@ -189,7 +191,7 @@ A few tips to get you going:
|
|||||||
### License ###
|
### License ###
|
||||||
Copyright (c) 2010 Michael Dvorkin
|
Copyright (c) 2010 Michael Dvorkin
|
||||||
|
|
||||||
mike[at]dvorkin.net aka mike[at]fatfreecrm.com
|
mike[at]dvorkin.net aka mike[at]fatfreecrm.com aka twitter.com/mid
|
||||||
|
|
||||||
THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS
|
THIS SOFTWARE IS PROVIDED BY THE AUTHORS "AS IS" AND ANY EXPRESS
|
||||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||||
|
|||||||
@@ -3,7 +3,9 @@
|
|||||||
# Sample Pit integration hook.
|
# Sample Pit integration hook.
|
||||||
#
|
#
|
||||||
# 1. Appends Pit task number to the commit message when you use
|
# 1. Appends Pit task number to the commit message when you use
|
||||||
# task number as your git branch name.
|
# task number as part of your Git branch name. Specifically,
|
||||||
|
# leading or trailing digits of the branch name are treated
|
||||||
|
# as Pit task number.
|
||||||
#
|
#
|
||||||
# 2. Lets you specify task status and updates it in Pit accordingly.
|
# 2. Lets you specify task status and updates it in Pit accordingly.
|
||||||
#
|
#
|
||||||
@@ -18,8 +20,15 @@ exec < /dev/tty
|
|||||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
||||||
branch=${ref#refs/heads/}
|
branch=${ref#refs/heads/}
|
||||||
|
|
||||||
if [[ $branch =~ ^([0-9]+)$ ]]
|
if [[ $branch =~ ^([0-9]+) ]]; then
|
||||||
then
|
pit_task=${BASH_REMATCH[1]}
|
||||||
|
else
|
||||||
|
if [[ $branch =~ ([0-9]+)$ ]]; then
|
||||||
|
pit_task=${BASH_REMATCH[1]}
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -n "$pit_task" ]; then
|
||||||
pit_task=${BASH_REMATCH[1]}
|
pit_task=${BASH_REMATCH[1]}
|
||||||
|
|
||||||
echo "What is the status of task ${pit_task}?"
|
echo "What is the status of task ${pit_task}?"
|
||||||
|
|||||||
Reference in New Issue
Block a user