feat: gc with associate array GIT_USERS, code simplified, better hint
This commit is contained in:
parent
42e9a4168b
commit
180f1e1259
@ -316,32 +316,19 @@ unalias gc 2>/dev/null
|
|||||||
unalias gcm 2>/dev/null
|
unalias gcm 2>/dev/null
|
||||||
function gc {
|
function gc {
|
||||||
while true;do
|
while true;do
|
||||||
users=($GIT_USERS)
|
for user email in ${(kv)GIT_USERS}; do
|
||||||
for ((i=1; i<=${#users[@]}; i++)) do
|
printf "%-20s" $user
|
||||||
echo "$i | $users[$i]"
|
echo $email
|
||||||
done
|
done
|
||||||
echo 'please input your number or name:'
|
echo $fg[green]'Please input github username listed above(let admin add if not existed):'$reset_color
|
||||||
read input
|
read user
|
||||||
for ((i=1; i<=${#users[@]}; i++)) do
|
email=$GIT_USERS[$user]
|
||||||
if [[ $input == $users[$i] ]];then
|
if [[ "$email" != "" ]]; then
|
||||||
name=$input
|
break
|
||||||
index=$i
|
fi
|
||||||
break 2
|
echo $fg[red]'Invalid option...'$reset_color
|
||||||
elif [[ "$input" =~ '^[0-9]+$' ]];then
|
|
||||||
if [[ $input -gt 0 && $input -le ${#users[@]} ]];then
|
|
||||||
name=$users[$input]
|
|
||||||
index=$input
|
|
||||||
break 2
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo 'invalid option...'
|
|
||||||
done
|
done
|
||||||
emails=($GIT_EMAILS)
|
(git commit --author="$user <$email>" --verbose $*) || return
|
||||||
git config user.name $name
|
|
||||||
git config user.email $emails[$index]
|
|
||||||
(git commit --verbose $*) || return
|
|
||||||
(git commit --amend --author="$name <$emails[$index]>") || return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function gcm {
|
function gcm {
|
||||||
|
Loading…
Reference in New Issue
Block a user