Skip to content

Commit 6a21ead

Browse files
committed
Disallow --add with an existing author name
Fixes a root cause of #2
1 parent 386981b commit 6a21ead

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

git-coauthor

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,12 @@ function err() {
1313

1414
function author_create() {
1515
local -r author="$1"
16+
17+
if author_exact_match "${author}"; then
18+
err "author already exists"
19+
return 1
20+
fi
21+
1622
git config --global --add coauthor.author "${author}"
1723
}
1824

@@ -29,6 +35,14 @@ function author_list() {
2935
git config --global --get-all coauthor.author
3036
}
3137

38+
function author_exact_match() {
39+
local -r query="$1"
40+
41+
author_list | grep -i -m 1 -E "^${query}$"
42+
43+
return $?
44+
}
45+
3246
function author_match() {
3347
local -r query="$1"
3448
local match

0 commit comments

Comments
 (0)