-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-ai
More file actions
executable file
·35 lines (26 loc) · 857 Bytes
/
git-ai
File metadata and controls
executable file
·35 lines (26 loc) · 857 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env bash
# /// dotfiles
# description = "Git wrapper that adds AI suffix to the author name and email. Usage: `git ai commit ...`."
# author = "goncalomb"
# year = "2026"
# tags = ["stable"]
# ///
set -euo pipefail
NAME_SUFFIX=" (+AI)"
EMAIL_SUFFIX="+ai"
NAME="$(git config --get user.name)"
EMAIL="$(git config --get user.email)"
export GIT_AUTHOR_NAME="$NAME$NAME_SUFFIX"
export GIT_AUTHOR_EMAIL="${EMAIL%@*}$EMAIL_SUFFIX@${EMAIL##*@}"
echo "git-ai: using author '$GIT_AUTHOR_NAME <$GIT_AUTHOR_EMAIL>'"
[ "${#@}" -gt 0 ] && git "$@"
git_no_ai() {
git --no-pager log \
--author="<$GIT_AUTHOR_EMAIL>" \
--grep="(+ai)" --grep="(+AI)" --invert-grep --fixed-strings \
"$@"
}
if [ -n "$(git_no_ai -n1 --format="%h")" ]; then
echo "git-ai: some AI commits don't have '(+AI)' in the message"
git_no_ai --no-decorate
fi