mirror of
https://github.com/tj/git-extras.git
synced 2026-09-10 07:26:17 -04:00
18 lines
452 B
Bash
Executable file
18 lines
452 B
Bash
Executable file
#!/usr/bin/env bash
|
|
|
|
set -e -o pipefail
|
|
|
|
coauthor=$1
|
|
email=$2
|
|
|
|
test -z "$coauthor" && echo "co-author required." 1>&2 && exit 1
|
|
test -z "$email" && echo "co-author email required." 1>&2 && exit 1
|
|
|
|
old_message="$(git log --format=%B -n1)"
|
|
if [[ "$old_message" == *"Co-authored-by:"* ]]; then
|
|
git commit --amend -m "$old_message
|
|
Co-authored-by: $coauthor <$email>"
|
|
else
|
|
git commit --amend -m "$old_message" -m "Co-authored-by: $coauthor <$email>"
|
|
fi
|