Created
June 13, 2023 14:06
-
-
Save johnfosborneiii/9b10655bc5759d56a12c65d34f2bdb6d to your computer and use it in GitHub Desktop.
This file contains hidden or 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/bash | |
# Check if the script is being run from within a Git repository | |
if ! git rev-parse --is-inside-work-tree > /dev/null 2>&1; then | |
echo "Please run this script from within the Git repository you want to analyze." | |
exit 1 | |
else | |
# symbolic reference to avoid ambiguous reference errors | |
git remote set-head origin -a > /dev/null 2>&1 | |
fi | |
# Variables | |
keyword="add" | |
days_ago=$(date -d "60 days ago" +%Y-%m-%d) | |
count=0 | |
# Fetch the latest changes | |
git fetch | |
# Get the list of Pull Requests | |
pull_requests=$(git log --merges --since="$days_ago" --pretty=format:"%s" | grep pull | sed -e "s/.*#\([0-9]\+\).*/\1/g" | sort -rn | uniq) | |
while read ref; do | |
#curl -s https://api.github.com/repos/wolfi-dev/os/pulls/"${ref}" 2>/dev/null | jq; | |
title=$(gh pr view "$ref" --json title -q ".title" 2>/dev/null) | |
if [[ "$title" != "null" && "$title" == *"$keyword"* ]]; then | |
echo $title | |
((count++)) | |
fi | |
done <<< $pull_requests | |
echo "Number of Pull Requests with '$keyword' in the name in the last 60 total days: $count" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment