Skip to content

Commit 3e24652

Browse files
committed
Updating email logic
1 parent fed360b commit 3e24652

File tree

1 file changed

+18
-6
lines changed

1 file changed

+18
-6
lines changed

changeauthor.sh

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -195,13 +195,14 @@ fi
195195
# USER_OLD_EMAIL
196196
if [ -z "$USER_OLD_EMAIL" ] && [ "$SHOULD_EXECUTE" -eq 0 ]; then
197197
echo ""
198-
echo "Change Author for Existing Commits"
199-
echo "----------------------------------"
198+
echo "# ---------------------------------- #"
199+
echo "# Change Author for Existing Commits #"
200+
echo "# ---------------------------------- #"
200201
# Prompt user for email to replace ( USER_OLD_EMAIL )
201202
echo ""
202203
echo "Enter the email address of the author you "
203204
echo "would like to replace in the commit history."
204-
echo ""
205+
echo "--------------------------------------------"
205206
read -e -p "Email to Replace: ${COLOR_CYAN}" USER_OLD_EMAIL
206207
echo -e "${COLOR_RESET}"
207208
elif [ -z "$USER_OLD_EMAIL" ] && [ "$SHOULD_EXECUTE" -eq 1 ]; then
@@ -236,7 +237,7 @@ if [ -z "$USER_NEW_EMAIL" ] && [ "$SHOULD_EXECUTE" -eq 0 ]; then
236237
# Prompt user for correct email ( USER_NEW_EMAIL )
237238
echo ""
238239
echo "Enter a new/corrected email for this user."
239-
echo ""
240+
echo "------------------------------------------"
240241
read -e -p "New Email: ${COLOR_CYAN}" USER_NEW_EMAIL
241242
echo -e "${COLOR_RESET}"
242243
elif [ -z "$USER_NEW_EMAIL" ] && [ "$SHOULD_EXECUTE" -eq 1 ]; then
@@ -255,12 +256,23 @@ else
255256
USER_NEW_EMAIL="${USER_NEW_EMAIL}"
256257
fi
257258

259+
if [ "$USER_OLD_EMAIL" == "$USER_NEW_EMAIL" ]; then
260+
# Remote does not exist
261+
echo ""
262+
echo "${COLOR_YELLOW}The old email address, '${USER_OLD_EMAIL}' matches the${COLOR_RESET}"
263+
echo "${COLOR_YELLOW}new email address you provided, '${USER_NEW_EMAIL}'.${COLOR_RESET}"
264+
echo ""
265+
echo "${COLOR_YELLOW}No changes are necessary.${COLOR_RESET}"
266+
echo ""
267+
kill "$SCRIPT_PID"
268+
fi
269+
258270
# USER_NEW_NAME
259271
if [ -z "$USER_NEW_NAME" ] && [ "$SHOULD_EXECUTE" -eq 0 ]; then
260272
# Prompt user for correct name ( USER_NEW_NAME )
261273
echo ""
262274
echo "Enter the new/corrected first and last name for this user."
263-
echo ""
275+
echo "----------------------------------------------------------"
264276
read -e -p "New Name: ${COLOR_CYAN}" USER_NEW_NAME
265277
echo -e "${COLOR_RESET}"
266278
elif [ -z "$USER_NEW_NAME" ] && [ "$SHOULD_EXECUTE" -eq 1 ]; then
@@ -283,7 +295,7 @@ if [ -z "$USER_REMOTE" ] && [ "$SHOULD_EXECUTE" -eq 0 ]; then
283295
# Prompt user for remote (Default: 'origin' )
284296
echo ""
285297
echo "Enter the remote you would like to alter. ${COLOR_YELLOW}(Default: origin)${COLOR_RESET}"
286-
echo ""
298+
echo "--------------------------------------------------------"
287299
read -e -p "Remote Name: ${COLOR_CYAN}" -i "${DEFAULT_REMOTE}" USER_REMOTE
288300
echo -e "${COLOR_RESET}"
289301
elif [ -z "$USER_REMOTE" ] && [ "$SHOULD_EXECUTE" -eq 1 ]; then

0 commit comments

Comments
 (0)