-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrewrite_email.sh
More file actions
executable file
·31 lines (25 loc) · 884 Bytes
/
rewrite_email.sh
File metadata and controls
executable file
·31 lines (25 loc) · 884 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
#!/bin/bash
# Set the old email pattern to match and the new email to replace it with
OLD_EMAIL_PATTERN=".*42wolfsburg.de"
NEW_AUTHOR_NAME="Your Name Here" # Change this to your desired name
NEW_AUTHOR_EMAIL="dyarkovs@student.42wolfsburg.de"
# Ensure git is installed
if ! command -v git &> /dev/null; then
echo "Error: Git is not installed. Please install it and try again."
exit 1
fi
# Rewriting commit history
echo "Rewriting commit history to change author emails..."
git filter-repo --quiet --force --commit-callback '
import re
if re.match(r'"'"$OLD_EMAIL_PATTERN"'"', commit.original_author_email):
commit.author_name = "'"$NEW_AUTHOR_NAME"'"
commit.author_email = "'"$NEW_AUTHOR_EMAIL"'"
'
if [ $? -eq 0 ]; then
echo "Successfully updated author emails for matching commits."
else
echo "Error: Failed to rewrite author emails."
exit 1
fi
echo "Done!"