-
Notifications
You must be signed in to change notification settings - Fork 0
/
update.sh
47 lines (32 loc) · 1.06 KB
/
update.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
#!/bin/bash
# Source the configuration file
source config.sh
cd project-clone
echo fetching
git fetch -p origin
echo copying
cd ../
cp -u -R project-clone/. project-modified
cd project-modified
git remote set-url origin --push "$target_repo"
echo filtering
export FILTER_BRANCH_SQUELCH_WARNING=1
# Build the filter-branch command dynamically
filter_cmd="git filter-branch -f --env-filter '"
for old_email in "${!email_mappings[@]}"; do
new_author="${email_mappings[$old_email]}"
filter_cmd+="
if [ \"\$GIT_COMMITTER_EMAIL\" = \"$old_email\" ]; then
export GIT_COMMITTER_EMAIL=\"$(echo $new_author | cut -d' ' -f1)\"
export GIT_COMMITTER_NAME=\"$(echo $new_author | cut -d' ' -f2-)\"
fi
if [ \"\$GIT_AUTHOR_EMAIL\" = \"$old_email\" ]; then
export GIT_AUTHOR_EMAIL=\"$(echo $new_author | cut -d' ' -f1)\"
export GIT_AUTHOR_NAME=\"$(echo $new_author | cut -d' ' -f2-)\"
fi
"
done
filter_cmd+=" ' --tag-name-filter cat -- --branches --tags"
eval "$filter_cmd"
echo pushing
git push #-f