Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

New script to close tickets

  • Loading branch information...
commit c22b20b8732da7ff61ec497347b08375106efae1 1 parent c2f5b2b
Stephen Paul Weber authored July 23, 2009

Showing 1 changed file with 66 additions and 0 deletions. Show diff stats Hide diff stats

  1. 66  bin/git-ticket-close
66  bin/git-ticket-close
... ...
@@ -0,0 +1,66 @@
  1
+#!/bin/sh
  2
+
  3
+COMMIT=1
  4
+DELETE=0
  5
+while [ $# -gt 0 ]; do
  6
+	case "$1" in
  7
+		-C)
  8
+			COMMIT=0
  9
+			shift
  10
+		;;
  11
+		-d)
  12
+			DELETE=1
  13
+			shift
  14
+		;;
  15
+		-*)
  16
+			echo "Unsupported switch $1" 1>&2
  17
+			exit 1
  18
+		;;
  19
+		*)
  20
+			break
  21
+		;;
  22
+	esac
  23
+done
  24
+
  25
+if [ "$DELETE" -eq 1 -a "$COMMIT" -eq 0 ]; then
  26
+	echo "Cannot delete when not commiting." 1>&2
  27
+	exit 1
  28
+fi
  29
+
  30
+SUBDIRECTORY_OK=1
  31
+if ! . "`git --exec-path`/git-sh-setup"; then
  32
+	exit 1
  33
+fi
  34
+if ! cd_to_toplevel; then
  35
+	exit 1
  36
+fi
  37
+
  38
+mkdir -p .tickets
  39
+cd .tickets
  40
+
  41
+TICKET="`echo "$*" | sed -e's/\//-/'`"
  42
+
  43
+if [ -z "$1" -o ! -f "$TICKET" ]; then
  44
+	echo "You must supply a valid ticket to close." 1>&2
  45
+	exit 1
  46
+fi
  47
+
  48
+if [ -n "`grep '^Status:' "$TICKET"`" ]; then
  49
+	DATA="`sed -e's/^Status: .*$/Status: Closed/i' "$TICKET"`"
  50
+else
  51
+	DATA="`sed -e"2 i\
  52
+Status: Closed
  53
+" "$TICKET"`"
  54
+fi
  55
+echo "$DATA" > "$TICKET"
  56
+
  57
+git add "$TICKET"
  58
+if [ "$COMMIT" -eq 1 ]; then
  59
+	git commit -em"Closes: $*"
  60
+	if [ "$DELETE" -eq 1 ]; then
  61
+		git rm "$TICKET"
  62
+		T="`git rm "$TICKET"-* 2>&1`"
  63
+		cd ..
  64
+		git commit -m"Remove closed ticket $*"
  65
+	fi
  66
+fi

0 notes on commit c22b20b

Please sign in to comment.
Something went wrong with that request. Please try again.