aboutsummaryrefslogtreecommitdiff
path: root/number-of-pr-in
diff options
context:
space:
mode:
authorclyhtsuriva <aimeric@adjutor.xyz>2022-11-01 22:27:43 +0100
committerclyhtsuriva <aimeric@adjutor.xyz>2022-11-01 22:27:43 +0100
commit1d047ac51d82c8d72b20bff623903dedd9756107 (patch)
tree7a0b4bd1ed6e78003fd238585bb2f616b68beaa0 /number-of-pr-in
Inital commit
Diffstat (limited to 'number-of-pr-in')
-rwxr-xr-xnumber-of-pr-in42
1 files changed, 42 insertions, 0 deletions
diff --git a/number-of-pr-in b/number-of-pr-in
new file mode 100755
index 0000000..a32e4b5
--- /dev/null
+++ b/number-of-pr-in
@@ -0,0 +1,42 @@
+#!/usr/bin/env bash
+#
+# number-of-pr-in
+# Author : Clyhtsuriva
+
+usage () {
+ echo "Usage: number-of-pr-in <repository>"
+ exit 1
+}
+
+number-of-pr-in () {
+
+ [ $# -eq 1 ] || usage
+
+ GH_REPO=void-linux/$1
+ LIMIT=1000 # Search API => 1000 results max
+
+ gh repo view "$GH_REPO" 1> /dev/null || exit 1
+
+ GH_PR_LIST=$(gh pr list \
+ --repo "$GH_REPO" \
+ --author "@me" \
+ --state merged \
+ --limit $LIMIT)
+
+ PARSED=$(echo "$GH_PR_LIST" | \
+ awk '{ print $2 }' | \
+ sed 's/://g' | \
+ sort | \
+ uniq -c | \
+ sort -nr | \
+ sed 's/ //g')
+
+
+ COLOR_ON=$(tput setaf 3; tput bold)
+ COLOR_OFF=$(tput sgr0)
+
+ # shellcheck disable=SC2001
+ echo "$PARSED" | sed "s/[^[:blank:]]\{1,\}/$COLOR_ON&$COLOR_OFF/1"
+}
+
+number-of-pr-in "$@"