Last active
May 21, 2022 20:14
-
-
Save carlisia/07fa820be5e38d173b274ca8be67de39 to your computer and use it in GitHub Desktop.
gh-queries
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/local/bin/bash | |
# update local copies to be ready to checkout code for review when needed | |
# printf "π§§ co main: \n" | |
# gita super net checkout main | |
# printf "π§§ git fetch: \n" | |
# gita fetch net | |
# printf "π§§ git pull: \n" | |
# gita pull net | |
all_paths=() | |
read -r -a all_repo_names < <(gita group ll net) | |
for i in "${all_repo_names[@]}" | |
do | |
all_paths+=( "$(gita ls "$i")" ) | |
done | |
now=$(date +"%m_%d_%Y") | |
printf "π Ran on: %s\n" "${now}" | |
echo -e "π€ Large PRs to review - weekly (qββΏβq)\n" | |
for i in "${all_paths[@]}" | |
do | |
pushd "$i" > /dev/null || exit; | |
# search query | |
res=$(gh pr list -s open --search " -author:@me -author:knative-automation label:size/S,size/XS" --json author,title,author,createdAt,updatedAt,mergedAt,number,url,state,labels,files) | |
name=$(git remote show origin -n | grep "Fetch URL:" | sed -E "s#^.*/(.*)#\1#" | sed "s#.git##") | |
if [ "$name" == "serving" ]; then | |
# Contributions that count for the Networking WG are all of those made to the `networking`, as well as all | |
# the `net-*` repos and the `serving` repo. However, for the `serving` repo, only the contributions made | |
# to Go packages designated as part of 'area/networking' are attributed to the Networking WG. | |
# One way to search for that is to run the following at the root of the `serving` repo: | |
# `echo "\n" | find . -name OWNERS | xargs grep -rl 'area/networking'`. | |
# This block handles this special case where PRs that contain files pertaining to the Networking WG | |
# need to be included in the result. | |
# fetch all the owners files for this WG area | |
NETWORKING_DIR=$(dirname $(find . -name OWNERS | xargs grep -rl 'area/networking') | xargs | sed 's/\.\///g' | yq -o=json | jq ' [.] | map(. |= split(" ")) [] | sort_by(.) | .[]' ) | |
serving=() | |
for p in $NETWORKING_DIR; do | |
# echo "$res" | jq -s '.[] | map(select([.files[].path] | contains([ '"$p"' ]))) | .[]' | |
serving+=$(echo "$res" | jq -s '.[] | map(select([.files[].path] | contains([ '"$p"' ]))) | .[] ' ) | |
done | |
printf 'π¦ project: %s\n' "$name"; | |
printf 'π open in editor: %s\n---\n' "$i"; | |
echo "${serving[@]}" | jq -s ' | |
[.[] | | |
{ | |
updated: (if .updatedAt == null then "" else (.updatedAt | strptime("%Y-%m-%dT%H:%M:%SZ") | todate[0:10]) end), | |
created: (if .createdAt == null then "" else (.createdAt | strptime("%Y-%m-%dT%H:%M:%SZ") | todate[0:10]) end ), | |
num: .number, | |
author: .author.login, | |
title: .title | .[0:70], | |
labels: [.labels[].name] | join(", "), | |
url: .url, } | |
] | sort_by("lastupdate")' | jtbl -m | |
continue | |
fi | |
len=$(echo "$res" | jq '[.[]] | length') | |
if [ "$len" == 0 ]; then | |
continue | |
fi | |
printf 'π¦ project: %s, %s\n' "$name" "$len"; | |
printf 'π open in editor: %s\n---\n' "$i"; | |
echo "$res" | jq ' | |
[.[] | | |
{ | |
updated: (if .updatedAt == null then "" else (.updatedAt | strptime("%Y-%m-%dT%H:%M:%SZ") | todate[0:10]) end), | |
created: (if .createdAt == null then "" else (.createdAt | strptime("%Y-%m-%dT%H:%M:%SZ") | todate[0:10]) end ), | |
num: .number, | |
author: .author.login, | |
title: .title | .[0:70], | |
labels: [.labels[].name] | join(", "), | |
url: .url, | |
} | |
] | sort_by("lastupdate")' | jtbl -m | |
printf '\n'; | |
popd > /dev/null || exit; | |
done | |
echo -e "\ndone β " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment