-
Notifications
You must be signed in to change notification settings - Fork 2
/
fix-mail.sh
36 lines (30 loc) · 1.4 KB
/
fix-mail.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
#!/bin/bash
# ex:
# GIT_USER='joe123'
# GIT_USER_EMAIL='[email protected]'
# another user variants:
# GIT_USER_VARIANTS=('joe1', 'joseph')
# resulted combinations to fix for author + commit user:
# 1. <any user> from 'joe123@localhost' -> <any user> from '[email protected]'
# 2. <any user> from '[email protected]' -> <any user> from '[email protected]'
# 3. 'user' from '[email protected]' -> 'joe123' from '[email protected]'
# 3. 'joe1' from '[email protected]' -> 'joe123' from '[email protected]'
# 4. 'joseph' from '[email protected]' -> 'joe123' from '[email protected]'
#
if [[ -z "${GIT_USER+x}" ]]; then
echo "$0: error: GIT_USER must be defined"
exit 255
fi >&2
if [[ -z "${GIT_USER_EMAIL+x}" ]]; then
echo "$0: error: GIT_USER_EMAIL must be defined"
exit 255
fi >&2
git filter-branch --env-filter \
"source \"$PROJECTS_ROOT\"'/andry81/gitcmd/gitcmd/scripts/git_filter_branch_user.sh'; \
git_fb_u a:c \"$GIT_USER_EMAIL\" '*' \"$GIT_USER@localhost\" '*'; \
git_fb_u a:c \"$GIT_USER_EMAIL\" '*' \"$GIT_USER@${GIT_USER_EMAIL#*@}\" '*'; \
git_fb_u a:c \"$GIT_USER_EMAIL\" \"$GIT_USER\" '[email protected]' 'user'; \
for (( i=0; i < ${#GIT_USER_VARIANTS[@]}; i++ )); then \
git_fb_u a:c \"$GIT_USER_EMAIL\" \"$GIT_USER\" \"$GIT_USER_EMAIL\" \"${GIT_USER_VARIANTS[i]}\"; \
done" -- --all && \
"$PROJECTS_ROOT"'/andry81/gitcmd/gitcmd/scripts/git_filter_branch_cleanup.sh'