File: git-coauthor

package info (click to toggle)
git-extras 7.4.0-1
  • links: PTS
  • area: main
  • in suites: forky, sid
  • size: 2,120 kB
  • sloc: sh: 4,312; python: 994; makefile: 146
file content (17 lines) | stat: -rwxr-xr-x 452 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#!/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