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. Kubernetes集群管理工具kubectl命令技巧大全

    一. kubectl概述 Kubectl是用于控制Kubernetes集群的命令行工具,通过kubectl能够对集群本身进行管理,并能够在集群上进行容器化应用的安装部署. kubectl命令的语法如下 ...

  2. 2、fork函数与进程ID

    1. fork函数 fork函数用于克隆一份当前的进程资源,调用fork函数之后,进程一分为二,并且两个进程的资源是一样的(只是资源内容完全一样,并不是同一份资源).fork函数的函数原型为:pid_ ...

  3. PE节表

  4. 加密填补 填充 pad padding

    RFC 1423 - Privacy Enhancement for Internet Electronic Mail: Part III: Algorithms, Modes, and Identi ...

  5. sentry 错误监控 报警

    错误监控 报警 Sentry | Error Tracking Software - JavaScript, Python, PHP, Ruby, more https://sentry.io/wel ...

  6. 正则r的作用

    >>> mm = "c:\\a\\b\\c" >>> mm 'c:\\a\\b\\c' >>> print(mm) c:\a\ ...

  7. 「笔记」数位DP

    目录 写在前面 引入 求解 特判优化 代码 例题 「ZJOI2010」数字计数 「AHOI2009」同类分布 套路题们 「SDOI2014」数数 写在最后 写在前面 19 年前听 zlq 讲课的时候学 ...

  8. 洛谷P4981

    Description 给定 n 个点,组成一棵树,有多少种组合方法: Analysis 首先,结合题目简化意义和这句话 最多可能存在多少种父子关系 我们可以知道当且仅当有至少一个节点的儿子不同时称他 ...

  9. Java8中流的性能

    流(Stream)是Java8为了实现最佳性能而引入的一个全新的概念.在过去的几年中,随着硬件的持续发展,编程方式已经发生了巨大的改变,程序的性能也随着并行处理.实时.云和其他一些编程方法的出现而得到 ...

  10. Spring3文件上传,提速你的Web开发

    Spring1 推出的时候可以说是不小的颠覆了J2EE 的开发,彻底把EJB打败,将J2EE开发进行简化,Spring2 推出以后完美的与多种开源框架与服务器的结合,让你对其拥抱的更紧,Spring变 ...