-
Notifications
You must be signed in to change notification settings - Fork 0
/
git_author.sh
executable file
·54 lines (45 loc) · 1.21 KB
/
git_author.sh
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#!/bin/bash -u
function git_get_user() {
export get_name=$(git config --get user.name)
export get_email=$(git config --get user.email)
}
function git_print_user() {
git_get_user
export TAB=" "
echo "current author name:"
echo "${TAB}${get_name}"
echo
echo "current author email:"
echo "${TAB}${get_email}"
}
function git_set_user() {
local set_name="Jon Lighthall"
local set_email="jon.lighthall@gmail.com"
git_print_user
local do_update=false
if [[ "${get_name}" == "${set_name}" ]]; then
if [ ${DEBUG:-0} -gt 0 ]; then
echo "names match"
fi
else
echo -e "${TAB}\x1B[1;31mnames do not match\x1B[0m"
echo "${TAB}setting git user name..."
git config user.name "${set_name}"
do_update=true
fi
if [[ "${get_email}" == "${set_email}" ]]; then
if [ ${DEBUG:-0} -gt 0 ]; then
echo "emails match"
fi
else
echo -e "${TAB}\x1B[1;31memails do not match\x1B[0m"
echo "${TAB}setting git user email..."
git config user.email "${set_email}"
do_update=true
fi
if ${do_update}; then
echo
git_print_user
fi
}
git_set_user