summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-05-23 14:34:47 +0100
committerDaniel Silverstone <daniel.silverstone@codethink.co.uk>2012-05-23 14:34:47 +0100
commitdfb2b45f05dc8c4d35f6e785f8dd39ff22835975 (patch)
tree27ba4cabf284174fc7f5e2f0ff73b2bcc5743118
parenta3c5f4edac12bc4e2caf4b94f54703ac31072586 (diff)
downloadgit-pull-request-dfb2b45f05dc8c4d35f6e785f8dd39ff22835975.tar.bz2
Add support for filtering pull requests to 'waiting' only
-rwxr-xr-xgit-pull-request.sh51
1 files changed, 34 insertions, 17 deletions
diff --git a/git-pull-request.sh b/git-pull-request.sh
index 13495a8..f84e8f1 100755
--- a/git-pull-request.sh
+++ b/git-pull-request.sh
@@ -24,6 +24,7 @@ g,git Show the git commands being run behind the curtain
List Options
H,heads Show the non-archived pull requests
A,archive Show the archived pull requests
+w,waiting Show only those which are 'waiting' on review/merge
p,pattern= Specify a regexp to match for which pull requests to show
"
@@ -41,6 +42,7 @@ do
-g) GIT_SHOWCMD=1 ;;
-H) SHOW_HEADS=1 ;;
-A) SHOW_ARCHIVE=1 ;;
+ -w) SHOW_WAITING=1 ;;
-p) SHOW_PATTERN="$2"; shift ;;
--) shift; break;;
*) usage ;;
@@ -112,25 +114,23 @@ load_meta_from ()
METADATA[ROOT]=$(first_commit_on "${SHA}")
}
-summarise_meta_at ()
+display_meta_summary ()
{
- local PR SHA BRANCH
+ local PR
PR="$1"
- SHA="$2"
- BRANCH="$3"
- load_meta_from "$SHA"
-
echo -ne "${PR}\t${METADATA[STATE]}\t"
echo $(rgit log --pretty="format:%s" "${METADATA[ROOT]}")
}
-summarise_meta ()
+summarise_meta_at ()
{
- local COMMIT BRANCH
- while read COMMIT BRANCH; do
- summarise_meta_at "$1" "$COMMIT" "$BRANCH"
- done <<<$(rgit show-ref "$1"__meta)
+ local PR SHA BRANCH
+ PR="$1"
+ SHA="$2"
+
+ load_meta_from "$SHA"
+ display_meta_summary "${PR}"
}
#############################################################################
@@ -145,14 +145,31 @@ cmd_list () {
test "x$SHOW_HEADS" = "x1" && META_HEADS=$(find_requests heads ${GREP})
test "x$SHOW_ARCHIVE" = "x1" && META_ARCHIVE=$(find_requests archive ${GREP})
+ local SHOWN
METAS="${META_HEADS} ${META_ARCHIVE}"
- if test "x$METAS" = "x "; then
- say "No pull requests found"
+ for META in ${METAS}; do
+ local COMMIT BRANCH
+ while read COMMIT BRANCH; do
+ load_meta_from "${COMMIT}"
+ local WANT=1
+ if test "x$SHOW_WAITING" = "x1"; then
+ case "${METADATA[STATE]}" in
+ new|updated) ;;
+ *)
+ WANT=0
+ ;;
+ esac
+ fi
+ if test "x$WANT" = "x1"; then
+ display_meta_summary "${META}"
+ SHOWN=1
+ fi
+ done <<<$(rgit show-ref "${META}"__meta)
+ done
+
+ if test "x$SHOWN" != "x1"; then
+ echo 2>&1 "No pull-requests found matching criteria"
exit 1
- else
- for META in ${METAS}; do
- summarise_meta $META
- done
fi
}