diff options
author | Ting-Wei Lan <lantw44@gmail.com> | 2014-09-23 17:48:01 +0800 |
---|---|---|
committer | Ting-Wei Lan <lantw44@gmail.com> | 2014-09-23 17:48:01 +0800 |
commit | 2c1738296e8245c39f891bc2b147f4c3a6e4300f (patch) | |
tree | 2af0453422be57b5a01ccebacbeeeb5826cf2082 | |
parent | dcff8a66e131e9a6768c79fce450de791f7b90b7 (diff) | |
download | configfile-2c1738296e8245c39f891bc2b147f4c3a6e4300f.tar.gz configfile-2c1738296e8245c39f891bc2b147f4c3a6e4300f.tar.zst configfile-2c1738296e8245c39f891bc2b147f4c3a6e4300f.zip |
bash_include: 加入檢查 git commit 的名字與 email 的功能bash_include-20140923
-rw-r--r-- | bash_include | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/bash_include b/bash_include index 0dafccc..b7b19e7 100644 --- a/bash_include +++ b/bash_include @@ -234,6 +234,32 @@ alias screen256='screen -T screen-256color' alias vimhtml='vim -c "set ts=2" -c "set sw=2"' +# Functions: Overrided external commands to prevent misuse ################### + +function git () +{ + if [ "$1" = "commit" ]; then + if [ "`command git config user.name`" = "LAN-TW" ]; then + printf '==> \e[1;31mBASHRC ERROR\e[m: STOP USING THIS CRYPTIC NAME!\n' + return 1 + fi + if command git config user.name | safe_grep ' ' >/dev/null; then :; + else + printf '==> \e[1;31mBASHRC ERROR\e[m: Your real name does not contain spaces!\n' + return 1 + fi + if [[ "$PWD" == *gnome* ]] || [[ "$PWD" == *jhbuild* ]]; then + if [[ "`command git config user.email`" == *gnome* ]]; then :; + else + printf '==> \e[1;31mBASHRC ERROR\e[m: Please use GNOME email for GNOME project!\n' + return 2 + fi + fi + fi + command git "$@" +} + + # Functions: Shared Internal Functions ####################################### function createdir_askmode () |