11#! /bin/bash
22
3- # Check if required arguments are provided
3+ # Check if required argument is provided
44if [ " $# " -ne 1 ]; then
55 printf $' Usage: %s <YYYY-MM>\n\n For instance `%s 2024-07`\n\n ' " ${0} " " ${0} "
66 exit 1
@@ -16,15 +16,12 @@ repository='leanprover-community/mathlib4'
1616startDate=" ${1} "
1717endDate=" ${2} "
1818
19- # find how many commits to master there have been in the last month
19+ # find how many commits to master there have been in the given range -- note that there is a limit to how many commits `gh` returns
2020commits_in_range=" $( git log --since=" ${startDate} " --until=" ${endDate} " --pretty=oneline | wc -l) "
2121
22- # Retrieve merged PRs from the given range
22+ # Retrieve merged (i.e. closed, due to bors) PRs from the given range
2323prs=$( gh pr list --repo " $repository " --state closed --base master --search " closed:${startDate} ..${endDate} " --json number,labels,title,author --limit " $(( commits_in_range * 2 )) " )
2424
25- # # Print PR numbers, their labels and their title
26- # echo "$prs" | jq -r '.[] | select(.title | startswith("[Merged by Bors]")) | "PR #\(.number) - Labels: \((.labels | map(.name) | join(", ")) // "No labels") - Title: \(.title)"'
27-
2825# Store to file `found_by_gh.txt` the PR numbers, as found by `gh`
2926echo " $prs " | jq -r ' .[] | select(.title | startswith("[Merged by Bors]")) | "(#\(.number))"' | sort >> found_by_gh.txt
3027
@@ -35,7 +32,7 @@ git log --pretty=oneline --since="${startDate}" --until="${endDate}" |
3532echo " $prs "
3633}
3734
38- # the current year and month
35+ # the year and month being processed
3936yr_mth=" ${1} " # "$(date +%Y-%m)"
4037yr_mth_day=${yr_mth} -01
4138
@@ -52,9 +49,6 @@ printf $'\n\nBetween %s and %s there were\n' "${yr_mth_day}" "${end_date/%T*}"
5249
5350printf $' * %s commits to `master` and\n ' " ${commits_in_range} "
5451
55- # echo "First run: ${start_date} ${yr_mth}-15T23:59:59"
56- # echo "Second run: ${yr_mth}-16T00:00:00 ${end_date}"
57-
5852(
5953findInRange " ${start_date} " " ${yr_mth} -15T23:59:59" | sed -z ' s=]\n*$=,\n='
6054findInRange " ${yr_mth} -16T00:00:00" " ${end_date} " | sed -z ' s=^\[=='
0 commit comments