#!/bin/sh # Git-Replace-Author : pre-commit hook # P532 - Sub-project # Made By: Ankit Sadana # Username: asadana # Made On: 12/18/2015 # Git Source Repository : git@github.com:asadana/Git-Check-Author.git # Last Edited By: Ankit Sadana # Username: asadana # Last Edited On: 12/21/2015 # ============================================================ # # An example hook script to verify what is about to be committed. # Called by "git commit" with no arguments. The hook should # exit with non-zero status after issuing an appropriate message if # it wants to stop the commit. # # ============================================================ # Retreive the GIT_AUTHOR_EMAIL from the git config # And trims everything after '@' target_author_name=${GIT_AUTHOR_EMAIL%@*} # If condition checks if the email username is same as GIT_AUTHOR_NAME if [[ $target_author_name != $GIT_AUTHOR_NAME ]]; then echo "##########################################" echo "Your name should be the same as your username." echo "Example: IU-ID " echo echo "Fix your username by using:" echo "git config user.name IU-ID" echo "Then try commiting again" echo "##########################################" exit 1 else # Uncomment this for debugging # echo "Correct Email! Thank you" echo exit 0 fi