Skip to content

Instantly share code, notes, and snippets.

@LSLeary
Last active December 20, 2022 04:00
Show Gist options
  • Save LSLeary/5de3c26b10e6ac4de55cb7f5a4e4582c to your computer and use it in GitHub Desktop.
Save LSLeary/5de3c26b10e6ac4de55cb7f5a4e4582c to your computer and use it in GitHub Desktop.
Write good commit messages, then let a script write your PR for you—or at least the bulk of it.
#! /usr/bin/env sh
# Configuration: where PRs are written
prdir=$HOME/PRs
# Argument: the git rev or ref upon which the PR is based
base=$1
repo=$(basename "$(git rev-parse --show-toplevel)")
mkdir -p "$prdir/$repo"
branch=$(git branch --show-current)
prfile=$prdir/$repo/$branch.md
commits() {
echo "#### Summary"
echo ""
echo "#### Commits"
echo ""
git log "$base..HEAD" --reverse '--pretty=format:##### %s%n%n%b' |
sed -e 's/^\([^#]\)/> \1/'
echo ""
echo "#### Commentary"
echo ""
}
if [ -e "$prfile" ]; then
echo "PR file already exists. Appending commits."
fi
commits >> "$prfile"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment