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 '[ -~]\0' | 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 发布文章使用:只允许注册用户才可以访问!


git hooks All In One的更多相关文章

  1. [git hooks] pre-commit 配置

    在开发过程中,通常使用 eslint 来规范团队的代码风格.但是 eslint 只能在开发服务器启动的时候才去检验代码.如果一个人在不启动开发服务器的情况下,修改了代码直接提交到git,那么别人pul ...

  2. Git Hooks、GitLab CI持续集成以及使用Jenkins实现自动化任务

    Git Hooks.GitLab CI持续集成以及使用Jenkins实现自动化任务 前言 在一个共享项目(或者说多人协同开发的项目)的开发过程中,为有效确保团队成员编码风格的统一,确保部署方式的统一, ...

  3. 使用Git Hooks实现开发部署任务自动化

    前言 版本控制,这是现代软件开发的核心需求之一.有了它,软件项目可以安全的跟踪代码变更并执行回溯.完整性检查.协同开发等多种操作.在各种版本控制软件中,git是近年来最流行的软件之一,它的去中心化架构 ...

  4. 用 Git Hooks 进行自动部署

    原文发表于 http://ourai.ws/posts/deployment-with-git-hooks/ 昨天开始接手开发公司前端团队的主页,在稍微修改点东西后推送到远程仓库想看下线上结果时发现并 ...

  5. 012-基于 git hooks 的前端代码质量控制解决方案

    原文看这里:https://github.com/kuitos/kui...全部文章看这里 https://github.com/kuitos/kui... 国际惯例先说下故事背景 通常情况下,如果我 ...

  6. 通过Gradle Plugin实现Git Hooks检测机制

    背景 项目组多人协作进行项目开发时,经常遇到如下情况:如Git Commit信息混乱,又如提交者信息用了自己非公司的私人邮箱等等.因此,有必要在Git操作过程中的适当时间点上,进行必要的如统一规范.安 ...

  7. [NPM] Run npm scripts with git hooks

    In this lesson we will look about how we can integrate with git hooks to help enforce a certain leve ...

  8. 搭建Git服务器环境----Git hooks代码自动部署

    引言:自己想搭一套git的服务端环境,不想用github码云等.经多方资料整合,实验总结,以下是亲测有效的方式.可用于公司日常开发 一.搭建Git环境 ① 安装 Git Linux 做为服务器端系统, ...

  9. 8.3 Customizing Git - Git Hooks

    https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks https://github.com/git/git/blob/master/temp ...

  10. 8.3 Customizing Git - Git Hooks 钩子 自动拉取 自动部署 提交工作流钩子,电子邮件工作流钩子和其他钩子

    https://git-scm.com/book/en/v2/Customizing-Git-Git-Hooks https://github.com/git/git/blob/master/temp ...

随机推荐

  1. 今天聊点干货—关于CSS样式来源

    样式来源 CSS样式共有5个来源,它们分别是\(\color{#FF3030}{浏览器默认样式}\).\(\color{#FF3030}{用户样式}\).\(\color{#FF3030}{链接样式} ...

  2. MySQL调优性能监控之show profile

    用show profile查询工具指定具体的type show profile在mysql5.7之后过时 show profile命令用于跟踪执行过的sql语句的资源消耗信息,可以帮助查看sql语句的 ...

  3. Python_1生成器(下)之单线并行--生产着消费者模型

    1 import time 2 def consumer(name): 3 print('%s准备吃包子了!' %name) 4 while True: 5 baozi = yield 6 print ...

  4. __init__ raises an exception, then __del__ will still be called

    issue 808164: socket.close() doesn't play well with __del__ - Python tracker https://bugs.python.org ...

  5. GC 卡顿 优化 三色标记优势

    小结: 1. 三色标记的一个明显好处是能够让用户程序和 mark 并发的进行 Go GC 卡顿由秒级降到毫秒级以下:到底做了哪些优化? https://mp.weixin.qq.com/s/2BMGG ...

  6. loj10012 Best Cow Fences

    题目描述 原题来自:USACO 2003 Mar. Green 给定一个长度为 N 的非负整数序列 A ,求一个平均数最大的,长度不小于 L 的子段. 输入格式 第一行用空格分隔的两个整数 N 和 L ...

  7. java中的IO处理和使用,API详细介绍(二)

    字符流 [向文件中写入数据] 现在我们使用字符流 /** * 字符流 * 写入数据 * */ import java.io.*; class hello{ public static void mai ...

  8. multiselect多选下拉框

    具体实现 <input type="hidden" id="q_dueDay" name="q_dueDay" value=" ...

  9. 并发编程补充--方法interrupted、isinterrupted详解

    并发编程 interrupted()源码 /** * Tests whether the current thread has been interrupted. The * <i>int ...

  10. this.$nextTick( 回调函数 )的作用

    首先要明确几个概念 1.Vue的核心思想 数据驱动 和 组件化系统 2.同步和异步 在没有特殊情下,程序一般先执行同步代码,等待同步执行完之后,执行异步代码 下面进入正题,首先贴出程序片段: 在该段代 ...