Created
September 8, 2023 23:18
-
-
Save dgraham/d947867d3089803af3b4712c82a63ec3 to your computer and use it in GitHub Desktop.
git cowork
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/sh | |
if [ "$1" = "--stop" ] | |
then | |
git config --unset-all cowork.author | |
elif [ -n "$1" ] | |
then | |
author=$(git log --no-merges --author "$1" -1 --pretty="%an <%ae>") | |
if [ -n "$author" ] | |
then | |
git config --add cowork.author "$author" | |
echo "$author" | |
cat <<EOF > .git/hooks/commit-msg | |
#!/bin/sh | |
git config --get-all cowork.author | while read -r author | |
do | |
git interpret-trailers --in-place --trailer "Co-authored-by: \$author" "\$1" | |
done | |
EOF | |
chmod u+x .git/hooks/commit-msg | |
else | |
echo "Author not found" | |
exit 1 | |
fi | |
else | |
git log --no-merges --author "$1" --pretty="%an <%ae>" | sort | uniq | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment