zoukankan      html  css  js  c++  java
  • xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!

    git hooks All In One

    $ xgqfrms git:(main) cd .git/
    $ .git git:(main) ls
    COMMIT_EDITMSG HEAD           branches       description    index          logs           packed-refs
    FETCH_HEAD     ORIG_HEAD      config         hooks          info           objects        refs
    $ .git git:(main) cd hooks
    $ hooks git:(main) ls -al
    total 112
    drwxr-xr-x  14 xgqfrms-mbp  staff   448 Dec  7 00:01 .
    drwxr-xr-x  16 xgqfrms-mbp  staff   512 Dec 26 21:29 ..
    -rwxr-xr-x   1 xgqfrms-mbp  staff   478 Dec  7 00:01 applypatch-msg.sample
    -rwxr-xr-x   1 xgqfrms-mbp  staff   896 Dec  7 00:01 commit-msg.sample
    -rwxr-xr-x   1 xgqfrms-mbp  staff  4655 Dec  7 00:01 fsmonitor-watchman.sample
    -rwxr-xr-x   1 xgqfrms-mbp  staff   189 Dec  7 00:01 post-update.sample
    -rwxr-xr-x   1 xgqfrms-mbp  staff   424 Dec  7 00:01 pre-applypatch.sample
    -rwxr-xr-x   1 xgqfrms-mbp  staff  1643 Dec  7 00:01 pre-commit.sample
    -rwxr-xr-x   1 xgqfrms-mbp  staff   416 Dec  7 00:01 pre-merge-commit.sample
    -rwxr-xr-x   1 xgqfrms-mbp  staff  1348 Dec  7 00:01 pre-push.sample
    -rwxr-xr-x   1 xgqfrms-mbp  staff  4898 Dec  7 00:01 pre-rebase.sample
    -rwxr-xr-x   1 xgqfrms-mbp  staff   544 Dec  7 00:01 pre-receive.sample
    -rwxr-xr-x   1 xgqfrms-mbp  staff  1492 Dec  7 00:01 prepare-commit-msg.sample
    -rwxr-xr-x   1 xgqfrms-mbp  staff  3635 Dec  7 00:01 update.sample
    
    

    pre-commit

    $ code pre-commit.sample
    
    
    #!/bin/sh
    #
    # 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.
    #
    # To enable this hook, rename this file to "pre-commit".
    
    if git rev-parse --verify HEAD >/dev/null 2>&1
    then
    	against=HEAD
    else
    	# Initial commit: diff against an empty tree object
    	against=$(git hash-object -t tree /dev/null)
    fi
    
    # If you want to allow non-ASCII filenames set this variable to true.
    allownonascii=$(git config --type=bool hooks.allownonascii)
    
    # Redirect output to stderr.
    exec 1>&2
    
    # Cross platform projects tend to avoid non-ASCII filenames; prevent
    # them from being added to the repository. We exploit the fact that the
    # printable range starts at the space character and ends with tilde.
    if [ "$allownonascii" != "true" ] &&
    	# Note that the use of brackets around a tr range is ok here, (it's
    	# even required, for portability to Solaris 10's /usr/bin/tr), since
    	# the square bracket bytes happen to fall in the designated range.
    	test $(git diff --cached --name-only --diff-filter=A -z $against |
    	  LC_ALL=C tr -d '[ -~]' | wc -c) != 0
    then
    	cat <<EOF
    Error: Attempt to add a non-ASCII file name.
    
    This can cause problems if you want to work with people on other platforms.
    
    To be portable it is advisable to rename the file.
    
    If you know what you are doing you can disable this check using:
    
      git config hooks.allownonascii true
    EOF
    	exit 1
    fi
    
    # If there are whitespace errors, print the offending file names and fail.
    exec git diff-index --check --cached $against --
    
    
    

    husky

    refs

    https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks

    https://git-scm.com/docs/githooks

    https://www.atlassian.com/git/tutorials/git-hooks

    husky

    https://www.cnblogs.com/xgqfrms/p/11650177.html



    ©xgqfrms 2012-2020

    www.cnblogs.com 发布文章使用:只允许注册用户才可以访问!


  • 相关阅读:
    第二章:Java内存区域
    第六章:内核数据结构
    第十章:内核同步方法
    第九章:内核同步介绍
    第九章:zookeeper内部原理
    第三章:开始使用zookeeper的API
    第二章:了解zookeeper
    【观点】健康的心智是中国未来最大的生产力
    【流程管理分享】人事不分,问题不断
    为什么中国人勤劳而不富裕?为什么宋朝富裕而不强大?
  • 原文地址:https://www.cnblogs.com/xgqfrms/p/14194242.html
Copyright © 2011-2022 走看看