Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
anttiharju committed Jan 26, 2025
1 parent 4c932bd commit 45e9a0a
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions bin/deprecate-email
Original file line number Diff line number Diff line change
Expand Up @@ -15,27 +15,29 @@ new_name="$(git config user.name)"

# Replacing author and committer emails has to be done separately to avoid unintentional overwrites
# e.g. in commits with multiple authors.
(export FILTER_BRANCH_SQUELCH_WARNING=1 && \
echo "1/2 Overwriting committer" && \
git filter-branch -f --commit-filter "
if [ \"\$GIT_COMMITTER_EMAIL\" = \"$old_email\" ] || \
([ \"\$GIT_COMMITTER_EMAIL\" = \"[email protected]\" ] && \
([ \"\$GIT_AUTHOR_EMAIL\" = \"$old_email\" ] || \
[ \"\$GIT_AUTHOR_EMAIL\" = \"$new_email\" ]));
then
GIT_COMMITTER_NAME=\"$new_name\";
GIT_COMMITTER_EMAIL=\"$new_email\";
git commit-tree \"\$@\";
else
git commit-tree \"\$@\";
fi" HEAD && \
echo "2/2 Overwriting author" && \
git filter-branch -f --commit-filter "
if [ \"\$GIT_AUTHOR_EMAIL\" = \"$old_email\" ];
then
GIT_AUTHOR_NAME=\"$new_name\";
GIT_AUTHOR_EMAIL=\"$new_email\";
git commit-tree \"\$@\";
else
git commit-tree \"\$@\";
fi" HEAD)
(
export FILTER_BRANCH_SQUELCH_WARNING=1
echo "1/2 Overwriting committer"
git filter-branch -f --commit-filter "
if [ \"\$GIT_COMMITTER_EMAIL\" = \"$old_email\" ] || \
([ \"\$GIT_COMMITTER_EMAIL\" = \"[email protected]\" ] && \
([ \"\$GIT_AUTHOR_EMAIL\" = \"$old_email\" ] || \
[ \"\$GIT_AUTHOR_EMAIL\" = \"$new_email\" ]));
then
GIT_COMMITTER_NAME=\"$new_name\";
GIT_COMMITTER_EMAIL=\"$new_email\";
git commit-tree \"\$@\";
else
git commit-tree \"\$@\";
fi" HEAD
echo "2/2 Overwriting author"
git filter-branch -f --commit-filter "
if [ \"\$GIT_AUTHOR_EMAIL\" = \"$old_email\" ];
then
GIT_AUTHOR_NAME=\"$new_name\";
GIT_AUTHOR_EMAIL=\"$new_email\";
git commit-tree \"\$@\";
else
git commit-tree \"\$@\";
fi" HEAD
)

0 comments on commit 45e9a0a

Please sign in to comment.