Created
May 9, 2023 13:53
-
-
Save inverse/1214cb5f8f5ded2600601f51359602ee to your computer and use it in GitHub Desktop.
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
#!/usr/bin/env bash | |
set -uf -o pipefail | |
if ! git rev-parse --is-inside-work-tree &>/dev/null; then | |
echo "Not in a git repository" | |
exit 1 | |
fi | |
TEMPLATE_PATH="$(git rev-parse --show-toplevel)/.git/template" | |
git config commit.template $TEMPLATE_PATH | |
if [[ -e "$HOME/.colleagues.txt" ]] ; then | |
COLLEAGUES="$(cat $HOME/.colleagues.txt)" | |
else | |
COLLEAGUES="" | |
fi | |
TRAILERS="" | |
while true ; do | |
pick="$(echo -e "$COLLEAGUES\n$(git shortlog -e -s | cut -f2)" | uniq | fzy)" | |
if [[ "$pick" != "" ]]; then | |
TRAILERS+="Co-authored-by: $pick\n" | |
echo "Added co-author: $pick" | |
else | |
break | |
fi | |
done | |
if [[ "$TRAILERS" != "" ]] ; then | |
echo -e "\n" > $TEMPLATE_PATH | |
echo -e "$TRAILERS" >> $TEMPLATE_PATH | |
echo "🧑💻 Pairing mode enabled. Run 'git unpair' to end session." | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment