Prevent pushing branches to kubernetes repos directly

Signed-off-by: Marcus Noble <github@marcusnoble.co.uk>
This commit is contained in:
Marcus Noble 2023-07-03 09:06:07 +01:00
parent c44a00fbcb
commit a0a1834112
Signed by: AverageMarcus
GPG Key ID: B8F2DB8A7AEBAF78
2 changed files with 11 additions and 1 deletions

View File

@ -76,6 +76,16 @@ git() {
elif [ "$1" = "co" ]; then # Sign all commits
shift
_git checkout -b $@
elif [ "$1" = "push" ]; then # Sign all commits
shift
if [ $# -eq 0 ]; then
remote_url=$(_git remote get-url $(git current-remote))
if [[ $remote_url == *"kubernetes/"* ]] || [[ $remote_url == *"kubernetes-sigs/"* ]]; then
echo "⚠️ Don't push directly to Kubernetes"
return 1
fi
fi
_git push $@
else
_git $@
fi

View File

@ -51,7 +51,7 @@
logg = "log --color --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit"
dif = "!git diff -w"
pop = "!git stash pop"
current-remote = "!func(){ REMOTE=$(git rev-parse --abbrev-ref @{u}) ; echo ${REMOTE%/*} ; }; func"
[help]
autocorrect = 1