Commit git hook to repo

前端 未结 1 814
名媛妹妹
名媛妹妹 2021-01-22 00:42

I have a problem with configuration tslint and pre-commit hook. The point is that i created tsconfig file which work\'s well. And added bash script which not allow me to commit

相关标签:
1条回答
  • 2021-01-22 01:28

    "Committing a hook" is not possible for security reasons. If you could, then someone just cloning your repo and running basic operations could get arbitrary code executed on their machines.

    Two common ways to deal with this are:

    • Document what people have to do to get the hook operational in their repository.

    • Automate what people have to do to get it. For example, in a project using a Makefile, I have this in the Makefile and people can just run make setup-pre-push-hook to get the hook to run "make check" whenever they push:

    setup-pre-push-hook: setup-pre-push-hook-file
        grep -q 'make check' .git/hooks/pre-push || \
            printf '\n%s\n\n' 'make check' >> .git/hooks/pre-push
    
    setup-pre-push-hook-file:
        test -f .git/hooks/pre-push || echo '#!/bin/sh' >.git/hooks/pre-push
        test -x .git/hooks/pre-push || chmod +x .git/hooks/pre-push
    
    0 讨论(0)
提交回复
热议问题