mirror of
https://github.com/michaeldv/pit.git
synced 2025-12-08 15:43: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
|
||||
$ chmod +x .git/hooks/commit-msg
|
||||
|
||||
Create git branch using task number as a branch name. Now on every commit to
|
||||
the branch the hook will prompt you to update task status. The hook appends
|
||||
Pit task number to the commit message, updates Pit task status, and creates
|
||||
task note with the commit massage. For example:
|
||||
Create Git branch using Pit task number as leading or trailing digits of the
|
||||
branch name. Now on every commit to the branch the hook will prompt you to
|
||||
update task status. The hook appends Pit task number to the commit message,
|
||||
updates Pit task status, and creates task note with the commit massage.
|
||||
|
||||
$ git checkout -b 2
|
||||
Switched to a new branch '2'
|
||||
For example:
|
||||
|
||||
$ git checkout -b bugfix-42
|
||||
Switched to a new branch 'bugfix-42'
|
||||
|
||||
$ touch README
|
||||
$ git add .
|
||||
$ git commit -am "Added README file"
|
||||
What is the status of task 2?
|
||||
What is the status of task 42?
|
||||
(I)n progress
|
||||
(P)ostponed
|
||||
(O)pen
|
||||
(D)one
|
||||
Enter the status for task 2 [D]:
|
||||
Enter the status for task 42 [D]:
|
||||
i
|
||||
updated task 2: My second task (status: in progress)
|
||||
created note 2: Added README file [task 2, status:in progress] (task 2)
|
||||
[2 0d930fb] Added README file [task 2, status:in progress]
|
||||
updated task 42: My second task (status: in progress)
|
||||
created note 42: Added README file [task 42, status:in progress] (task 42)
|
||||
[bugfix-2 0d930fb] Added README file [task 42, status:in progress]
|
||||
0 files changed, 0 insertions(+), 0 deletions(-)
|
||||
create mode 100644 README
|
||||
|
||||
@@ -189,7 +191,7 @@ A few tips to get you going:
|
||||
### License ###
|
||||
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
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
# Sample Pit integration hook.
|
||||
#
|
||||
# 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.
|
||||
#
|
||||
@@ -18,8 +20,15 @@ exec < /dev/tty
|
||||
ref=$(git symbolic-ref HEAD 2> /dev/null) || return
|
||||
branch=${ref#refs/heads/}
|
||||
|
||||
if [[ $branch =~ ^([0-9]+)$ ]]
|
||||
then
|
||||
if [[ $branch =~ ^([0-9]+) ]]; 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]}
|
||||
|
||||
echo "What is the status of task ${pit_task}?"
|
||||
|
||||
Reference in New Issue
Block a user