githooks

作者: 发条蛙 | 来源:发表于2018-02-26 11:12 被阅读0次

最近代码提交的时候,总会遇到一些拷贝的代码中包含tab的情况,因此需要在提交代码前进行格式检查,发现了这个hooks挺好用的,可以在commit之前检查新增代码中是否包含tab,如果包含,则不予提交:

https://github.com/martinjoiner/portable-code-pre-commit-hook

但问题是,怎么样将这项工作同步到项目中,则参考如下文档:

https://www.viget.com/articles/two-ways-to-share-git-hooks-with-your-team/

以AOSP为例,最终的实现步骤为:

  1. 创建自定义hooks目录:
    mkdir .githooks
    
  2. 下载hooks:
    cd .githooks
    wget https://raw.githubusercontent.com/martinjoiner/portable-code-pre-commit-hook/master/pre-commit .
    chmod +x pre-commit
    
  3. 考虑到AOSP的编译需要执行source build/envsetup.sh,也因此添加如下行到该文件末尾:
    find .git/hooks -type l -exec rm {} \; && find .githooks -type f -exec ln -sf ../../{} .git/hooks/ \;
    

最终项目组的小伙伴们都能用到该功能了。

相关文章

  • githooks

    最近代码提交的时候,总会遇到一些拷贝的代码中包含tab的情况,因此需要在提交代码前进行格式检查,发现了这个hook...

  • githooks

    名称 githooks-Git使用的挂钩。(githook在官网的介绍[https://git-scm.com/d...

  • [vue,git]vuecli3 添加githooks,代码提交

    vuecli githooks配置官方链接[https://cli.vuejs.org/zh/guide/cli-...

  • git hook

    git hook https://git-scm.com/docs/githooks 什么是git hook g...

  • iOS 项目接入 Githooks

    可以直接查看 github项目,利用git子模块的方式引入到工程中. https://github.com/squ...

  • vue 代码规范 之 husky

    简单的举一些常见的githooks例子 Git Hook 执行时机 说明pre-commit git...

  • Git钩子 GitHook

    名称 githooks-Git使用的挂钩。(githook在官网的介绍) 描述 如同其他许多的版本控制系统一样,G...

网友评论

      本文标题:githooks

      本文链接:https://www.haomeiwen.com/subject/limexftx.html