From 98da0fa1869757734610ec34fbeb0396f26c0026 Mon Sep 17 00:00:00 2001 From: clyhtsuriva Date: Wed, 2 Nov 2022 22:21:53 +0100 Subject: Putting the first scripts in a bin/ folder --- bin/number-of-pr-in | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100755 bin/number-of-pr-in (limited to 'bin/number-of-pr-in') diff --git a/bin/number-of-pr-in b/bin/number-of-pr-in new file mode 100755 index 0000000..a32e4b5 --- /dev/null +++ b/bin/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 " + 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 "$@" -- cgit v1.2.3