install_git_hooks.py 文件源码

python
阅读 40 收藏 0 点赞 0 评论 0

项目:django-zerodowntime 作者: rentlytics 项目源码 文件源码
def handle(self, *args, **options):
        commit_msg_path = os.path.join(self.HOOK_PATH, 'commit-msg')

        hook_exists = os.path.exists(commit_msg_path)

        if hook_exists:
            with open(commit_msg_path, 'r') as fp:
                hook_content = fp.read()
        else:
            hook_content = '#!/usr/bin/env bash\n\n'

        if 'ZERODOWNTIME_COMMIT_MSG_HOOK' not in hook_content:
            hook_content += COMMIT_MSG_HOOK

            with open(commit_msg_path, 'w') as fp:
                fp.write(hook_content)

            st = os.stat(commit_msg_path)
            os.chmod(commit_msg_path, st.st_mode | stat.S_IEXEC)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号