To Nha Notes | April 7, 2023, 8:18 p.m.
git log --merges --pretty=oneline --abbrev-commit --grep="Merge pull request #" origin/main..origin/develop
git log --since="2023-01-01" --until="2023-03-31" --merges --pretty=oneline --abbrev-commit --grep="Merge pull request #" origin/main
for pr in $(git log --since="2023-01-01" --until="2023-03-31" --merges --pretty=oneline --abbrev-commit --grep="Merge pull request #" origin/main | sed -e "s/.*#\([0-9]\+\).*/\1/g" | sort -rn | uniq); do
curl -H "Authorization: Bearer <GITHUB_API_TOKEN>" -H "X-GitHub-Api-Version: 2022-11-28" https://api.github.com/repos/<OWNER>/<REPO>/pulls/${pr} 2>&1 | grep title | cut -d'"' -f4 | xargs echo "[https://github.com/<OWNER>/<REPO>/pull/${pr}] $1";
done
Bash script to list all PRs with title merged to a branch
#!/usr/bin/env bash
display_usage() {
echo "Usage: $0 {repo} {since} {until} {token}";
exit 1
}
if [ $# -lt 4 ]
then
display_usage
fi
repo=$1
since=$2
until=$3
token=$4
pulls_api_url="https://api.github.com/repos/resola-ai/${repo}/pulls"
pull_url="https://github.com/resola-ai/${repo}/pull"
for pr in $(git log --since="${since}" --until="${until}" --merges --pretty=oneline --abbrev-commit --grep="Merge pull request #" origin/main | sed -e "s/.*#\([0-9]\+\).*/\1/g" | sort -rn | uniq); do
curl -H "Authorization: Bearer ${token}" -H "X-GitHub-Api-Version: 2022-11-28" ${pulls_api_url}/${pr} 2>&1 | grep title | cut -d'"' -f4 | xargs echo "[${pull_url}/${pr}] $1";
done