From ae58ae07a67508edc0a4ab5ae301a8b9d83d27d5 Mon Sep 17 00:00:00 2001 From: Andrei Jiroh Eugenio Halili Date: Sat, 27 Feb 2021 22:27:52 +0800 Subject: [PATCH] fix-wrong-emails: Improve the script to allow args and some help stuff Signed-off-by: Andrei Jiroh Eugenio Halili --- bin/fix-wrong-emails | 39 ++++++++++++++++++++++++--------------- 1 file changed, 24 insertions(+), 15 deletions(-) diff --git a/bin/fix-wrong-emails b/bin/fix-wrong-emails index 28636cb..ad4baed 100755 --- a/bin/fix-wrong-emails +++ b/bin/fix-wrong-emails @@ -1,16 +1,25 @@ -git filter-branch --env-filter ' -WRONG_EMAIL="andreijiroh@mafebythepins.tk" -NEW_NAME="Andrei Jiroh Eugenio Halili" -NEW_EMAIL="andreijiroh@madebythepins.tk" +#!/bin/bash -if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ] -then - export GIT_COMMITTER_NAME="$NEW_NAME" - export GIT_COMMITTER_EMAIL="$NEW_EMAIL" -fi -if [ "$GIT_AUTHOR_EMAIL" = "$WRONG_EMAIL" ] -then - export GIT_AUTHOR_NAME="$NEW_NAME" - export GIT_AUTHOR_EMAIL="$NEW_EMAIL" -fi -' --tag-name-filter cat -- --branches --tags +if [[ $1 != "" ]]; then + git filter-branch --env-filter ' + WRONG_EMAIL=$1 + NEW_NAME="Andrei Jiroh Eugenio Halili" + NEW_EMAIL="andreijiroh@madebythepins.tk" + + if [ "$GIT_COMMITTER_EMAIL" = "$WRONG_EMAIL" ] + then + export GIT_COMMITTER_NAME="$NEW_NAME" + export GIT_COMMITTER_EMAIL="$NEW_EMAIL" + fi + if [ "$GIT_AUTHOR_EMAIL" = "$WRONG_EMAIL" ] + then + export GIT_AUTHOR_NAME="$NEW_NAME" + export GIT_AUTHOR_EMAIL="$NEW_EMAIL" + fi + ' --tag-name-filter cat -- --branches --tags +else + echo "Usage $0 " + echo "Easily fix wrong emails in Git commit history. It is advised to use this script only" + echo "on non-public commits, since this might be distaterous for forks to pull any changes" + echo "in the public commits." +fi \ No newline at end of file