Permalink
Browse files

Initial commit

  • Loading branch information...
0 parents commit 194c91ba59901c4ea4a636ea88c9b8ec79d10215 @singpolyma committed Jul 23, 2009
Showing with 122 additions and 0 deletions.
  1. +49 −0 bin/git-ticket
  2. +60 −0 bin/git-ticket-comment
  3. +13 −0 bin/git-ticket-list
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+COMMIT=1
+if [ "$1" = "-C" ]; then
+ COMMIT=0
+ shift
+fi
+
+if [ -z "$1" ]; then
+ echo "You must supply a subject for the ticket." 1>&2
+ exit 1
+fi
+
+if ! . "`git --exec-path`/git-sh-setup"; then
+ exit 1
+fi
+if ! cd_to_toplevel; then
+ exit 1
+fi
+
+mkdir -p .tickets
+cd .tickets
+
+NAME="`echo "$*" | sed -e's/\//-/'`"
+
+if [ ! -f "$NAME" ]; then
+ echo -n "From: " >> "$NAME"
+ git var GIT_AUTHOR_IDENT | sed -e's/^\(.*\) [^ ]* [^ ]*$/\1/' >> "$NAME"
+ echo -n "Date: " >> "$NAME"
+ date +"%a, %d %b %Y %H:%M:%S %z (%Z)" >> "$NAME"
+ echo "Subject: $*" >> "$NAME"
+ echo "Status: New" >> "$NAME"
+ echo "Type: " >> "$NAME"
+ echo >> "$NAME"
+ echo >> "$NAME"
+fi
+
+git_editor "$NAME"
+
+if [ -z "`tail -n2 "$NAME" | sed -e's/\n\n//'`" ]; then
+ rm -f "$NAME"
+ echo "Cancelled" 1>&2
+ exit
+fi
+
+git add "$NAME"
+if [ "$COMMIT" -eq 1 ]; then
+ git commit -m"New Ticket: $*"
+fi
@@ -0,0 +1,60 @@
+#!/bin/sh
+
+COMMIT=1
+if [ "$1" = "-C" ]; then
+ COMMIT=0
+ shift
+fi
+
+if ! . "`git --exec-path`/git-sh-setup"; then
+ exit 1
+fi
+if ! cd_to_toplevel; then
+ exit 1
+fi
+
+mkdir -p .tickets
+cd .tickets
+
+TICKET="`echo "$*" | sed -e's/\//-/'`"
+
+if [ -z "$1" -o ! -f "$TICKET" ]; then
+ echo "You must supply a valid ticket to comment on." 1>&2
+ exit 1
+fi
+
+MESSAGEID="`grep -i Message-Id < "$TICKET" | cut -d':' -f2 | sed -e's/^ *//'`"
+if [ -z "$MESSAGEID" ]; then
+ MESSAGEID="<`openssl dgst -sha1 < "$TICKET"`@`hostname`>"
+ M="`sed -e"2 i\
+Message-Id: $MESSAGEID
+" "$TICKET"`"
+ echo "$M" > "$TICKET"
+fi
+
+NAME="`mktemp`"
+
+echo -n "From: " >> "$NAME"
+git var GIT_AUTHOR_IDENT | sed -e's/^\(.*\) [^ ]* [^ ]*$/\1/' >> "$NAME"
+echo -n "Date: " >> "$NAME"
+date +"%a, %d %b %Y %H:%M:%S %z (%Z)" >> "$NAME"
+echo "In-Reply-To: $MESSAGEID" >> "$NAME"
+echo "Subject: Re: $*" >> "$NAME"
+echo >> "$NAME"
+echo >> "$NAME"
+
+git_editor "$NAME"
+
+if [ -z "`tail -n2 "$NAME" | sed -e's/\n\n//'`" ]; then
+ rm -f "$NAME"
+ echo "Cancelled" 1>&2
+ exit
+fi
+
+NEWNAME="$TICKET-`openssl dgst -sha1 < "$NAME"`"
+mv "$NAME" "$NEWNAME"
+
+git add "$NEWNAME"
+if [ "$COMMIT" -eq 1 ]; then
+ git commit -m"New Ticket: $*"
+fi
@@ -0,0 +1,13 @@
+#!/bin/sh
+
+if ! . "`git --exec-path`/git-sh-setup"; then
+ exit 1
+fi
+if ! cd_to_toplevel; then
+ exit 1
+fi
+
+if [ -d .tickets ]; then
+ cd .tickets
+ grep -vil 'In-Reply-To' *
+fi

0 comments on commit 194c91b

Please sign in to comment.