31 lines
823 B
Bash
31 lines
823 B
Bash
#!/bin/bash
|
|
|
|
function get_org_of_current_repo() {
|
|
local orgs_from_global_config=$(git config --get-regexp ^orgs. | cut -d . -f 2)
|
|
|
|
for org in $orgs_from_global_config; do
|
|
local org_remotes=$(git remote -v | grep -i $org/)
|
|
|
|
if [ ! -z "$org_remotes" ]; then
|
|
echo $org
|
|
fi
|
|
done
|
|
}
|
|
|
|
|
|
org=$(get_org_of_current_repo)
|
|
|
|
if [ ! -z "$org" ]; then
|
|
organization_email=$(git config orgs\.$org\.email)
|
|
repository_email=$(git config --local user.email)
|
|
|
|
if [ "$organization_email" != "$repository_email" ]; then
|
|
echo "Organization '$org' identified!"
|
|
echo "Setting the configured e-mail <$organization_email>"
|
|
git config --local user.email $organization_email
|
|
|
|
echo "Please repeat the commit command to use the new e-mail"
|
|
exit 1
|
|
fi
|
|
fi
|