-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgit-create-id-alias.sh
More file actions
executable file
·27 lines (25 loc) · 1.14 KB
/
git-create-id-alias.sh
File metadata and controls
executable file
·27 lines (25 loc) · 1.14 KB
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
#!/usr/bin/env bash
git config --global alias.id "$(tail -n+4 "$0")" && git config --global alias.id
exit
!function show_or_set_id() {
if [ "$#" -eq 0 ]; then
(
printf '%s\t%s\n' user.name "$(git config --get --null --show-origin user.name | tr '\0' '\t')"
printf '%s\t%s\n' user.email "$(git config --get --null --show-origin user.email | tr '\0' '\t')"
) | column -t -s $'\t'
echo "Contributors:"
git --no-pager log --all --format=tformat:'%an <%ae>%n%cn <%ce>' | sort -u | sed 's/^/'$'\t''/'
if [ "$(git config --global --get --bool user.useconfigonly)" != "true" -o "$(git config --global --get user.name)" == "" -o "$(git config --global --get user.email)" != "" ]; then
echo
echo "WARNING: User identity is configured incorrectly. Run the following commands to fix it:"
echo " git config --global user.useConfigOnly true"
echo " git config --global user.name \"$(finger $(whoami) | awk '/Name:/ {print $4" "$5}')\""
echo " git config --global --unset user.email"
fi
elif [ "$#" -eq 1 ]; then
git config --local user.email "$1"
else
echo "USAGE: git id [email-to-set]" >&2
fi
}
show_or_set_id