summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-05-23 14:19:02 +0100
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-05-23 14:19:02 +0100
commita3c5f4edac12bc4e2caf4b94f54703ac31072586 (patch)
tree23d14ef25d926c6ff5b7655390dbbc68227d2ee0
parentb830b1879c21269177eeac2bd3f7c88f57a7f9a5 (diff)
downloadgit-pull-request-a3c5f4edac12bc4e2caf4b94f54703ac31072586.tar.bz2
Add precis command
-rwxr-xr-xgit-pull-request.sh35
1 files changed, 28 insertions, 7 deletions
diff --git a/git-pull-request.sh b/git-pull-request.sh
index b3eb9df..13495a8 100755
--- a/git-pull-request.sh
+++ b/git-pull-request.sh
@@ -9,6 +9,7 @@ git pull-request [options] <cmd> [args]
Available sub-commands are:
list List pull requests along with their status
+precis Show the precis from a given pull-request's creation
create Create a new pull request
merge Merge a given pull request into your current branch
needs-work Indicate a pull request needs additional work before merging
@@ -73,6 +74,10 @@ find_requests ()
sed -e 's!.* refs/pull-requests/'"${SUB}"'/!!' | sed -e 's/__meta$//'
}
+first_commit_on ()
+{
+ rgit rev-list --reverse "$1" | head -n 1
+}
load_meta_from ()
{
@@ -104,11 +109,7 @@ load_meta_from ()
fi
done
test "x$BAD" = "x" || exit 1
-}
-
-first_commit_on ()
-{
- rgit rev-list --reverse "$1" | head -n 1
+ METADATA[ROOT]=$(first_commit_on "${SHA}")
}
summarise_meta_at ()
@@ -121,7 +122,7 @@ summarise_meta_at ()
load_meta_from "$SHA"
echo -ne "${PR}\t${METADATA[STATE]}\t"
- echo $(rgit log --pretty="format:%s" $(first_commit_on "$SHA"))
+ echo $(rgit log --pretty="format:%s" "${METADATA[ROOT]}")
}
summarise_meta ()
@@ -155,12 +156,32 @@ cmd_list () {
fi
}
+cmd_precis () {
+ local PR
+ PR="$1"
+ if test "x$PR" = "x"; then
+ echo >&2 "Please specify a pull-request to retrieve the precis of."
+ exit 1
+ fi
+ local COMMIT BRANCH
+ while read _COMMIT _BRANCH; do
+ COMMIT="${_COMMIT}"
+ BRANCH="${_BRANCH}"
+ done <<<$(rgit show-ref "$PR"__meta)
+ if test "x$COMMIT" = "x"; then
+ echo >&2 "Unknown pull-request '${PR}'"
+ exit 1
+ fi
+ load_meta_from "${COMMIT}"
+ rgit log --pretty="%B" "${METADATA[ROOT]}"
+}
+
#############################################################################
## Command invocation #####################################################
#############################################################################
if declare -F "cmd_${SUBCMD}" >/dev/null 2>/dev/null; then
- "cmd_${SUBCMD}"
+ "cmd_${SUBCMD}" "$@"
else
echo >&2 $0: Unknown sub-command: $SUBCMD
usage