Created
February 5, 2020 07:22
-
-
Save mickdekkers/ebc83082fd05771d36461842bdea452d to your computer and use it in GitHub Desktop.
Generate month-by-month GitHub search urls for your own contributions to a repo in a specified year
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
#!/bin/zsh | |
REPO="org-foo/repo-bar" | |
TARGET_YEAR=2019 | |
function encode_uri_component() { | |
node -e "console.log(encodeURIComponent(process.argv[1]).replace(/%20/g, '+'));" "$1" | |
} | |
function get_pr_search_url() { | |
QUERY="$(encode_uri_component "$1")" | |
echo "https://github.com/${REPO}/pulls?utf8=%E2%9C%93&q=${QUERY}" | |
} | |
function get_my_reviews_url() { | |
START_DATE="$1" | |
END_DATE="$2" | |
QUERY="is:pr sort:created-asc reviewed-by:@me created:${START_DATE}..${END_DATE}" | |
get_pr_search_url "$QUERY" | |
} | |
function get_my_prs_url() { | |
START_DATE="$1" | |
END_DATE="$2" | |
QUERY="is:pr sort:created-asc author:@me created:${START_DATE}..${END_DATE}" | |
get_pr_search_url "$QUERY" | |
} | |
# Note: we use zsh for zero-padded range support | |
for MONTH in {01..12}; do | |
LAST_DAY_OF_MONTH="$(cal "$MONTH" "$TARGET_YEAR" | awk 'NF {DAYS = $NF}; END {print DAYS}')" | |
START_DATE="$TARGET_YEAR-$MONTH-01" | |
END_DATE="$TARGET_YEAR-$MONTH-$LAST_DAY_OF_MONTH" | |
echo "$TARGET_YEAR-$MONTH" | |
echo "PRs: $(get_my_prs_url "$START_DATE" "$END_DATE")" | |
echo "Reviews: $(get_my_reviews_url "$START_DATE" "$END_DATE")" | |
echo | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment