githooks_使用Githooks改善团队的开发工作流程

githooks

by Daniel Deutsch

由Daniel Deutsch

使用Githooks改善团队的开发工作流程 (Improve your team’s development workflow with Githooks)

Every product that is developed by more than one programmer needs to have some guidelines to harmonize the workflow.

由多个程序员开发的每个产品都需要有一些准则来协调工作流程。

A standardized software development workflow between programmers allows, for example:

程序员之间的标准化软件开发工作流程允许例如:

  • faster engineering, since each developer can rely on a habitual activity

    更快的工程设计,因为每个开发人员都可以依靠习惯性活动
  • fewer errors, as the workflow itself shall be structured in a way to avoid some mistakes

    错误更少,因为工作流本身的结构应避免某些错误
  • easy integration of new members

    轻松整合新成员
  • improved log of history

    改进的历史记录

One very easy to use feature are “Githooks”(if you are using Git for version control).

一个非常易于使用的功能是“ Githooks ”(如果您使用Git进行版本控制)。

In this article I want to show how easy it actually is to set up a few workflow guidelines with Githooks. This will allow your team to be on one page when developing software.

在本文中,我想展示使用Githooks设置一些工作流程指南实际上是多么容易。 这样一来,您的团队就可以在开发软件时集中在一页上。

目录 (Table of Contents)

  • Why Githooks?

    为什么选择Githooks?

  • GitFlow and Checkout, Commit, Push

    GitFlow和签出,提交,推送

  • Post-checkout

    结帐后

  • Commit-msg

    提交消息

  • Pre-push

    预推

  • “Enforce” the hooks

    “执行”挂钩

  • Fix one common problem

    解决一个常见问题

  • Thanks

    谢谢

为什么选择Githooks? (Why Githooks?)

Githooks are, as the word suggests, a hook for Git commands. Intuitively this makes sense. With Git you are essentially managing the workflow of a piece of software. Every Branch is a part of the whole piece. Every Commit is a building block of a Branch.

顾名思义,Githooks是Git命令的钩子。 直观上讲,这是有道理的。 使用Git,您实际上是在管理软件的工作流程。 每个分支都是整体的一部分。 每个提交都是分支的构建块。

So in order to standardize quality in software development, one must standardize actions in the building process of the product.

因此,为了标准化软件开发的质量,必须标准化产品构建过程中的动作。

There are many Git commands that can be hooked for setting standards. Remember, there are quite a few:

可以挂钩许多Git命令来设置标准。 请记住,有很多:

  • applypatch-msg

    Applypatch-msg
  • pre-applypatch

    预先贴布
  • post-applypatch

    申请后
  • pre-commit

    预先提交
  • prepare-commit-msg

    准备提交消息
  • commit-msg

    提交消息
  • post-commit

    提交后
  • pre-rebase

    变基前
  • post-checkout

    结帐后
  • post-merge

    合并后
  • pre-receive

    预先接收
  • pre-push

    预推
  • update

    更新
  • post-update

    更新后
  • pre-auto-gc

    前自动gc
  • post-rewrite

    重写后

To establish an improved workflow you don’t have to use all of them. Focus on the few important ones. In my experience so far, those are:

要建立改进的工作流程,您不必全部使用。 专注于几个重要的方面。 根据我到目前为止的经验,这些是:

  • commit-msg/pre-commit

    提交消息/预提交
  • post-checkout

    结帐后
  • pre-push

    预推

Let me explain why.

让我解释一下原因。

GitFlow和签出,提交,推送 (GitFlow and Checkout, Commit, Push)

Using Git as version control system allows to set a workflow. I do this using the GitFlow method.

使用Git作为版本控制系统可以设置工作流程。 我使用GitFlow方法执行此操作。

It is basically to develop a piece of software where each feature is represented by a branch.

基本上是要开发一种软​​件,其中每个功能都由一个分支表示。

In the following examples I will always check naming with Regex tests or execute another script.

在以下示例中,我将始终使用Regex测试检查命名或执行其他脚本。

结帐后 (Post-checkout)

The increased importance of a branch allows for the first hook on “post-checkout”. It is triggered after a new branch is created with Git.

分支机构重要性的提高使您可以在“结帐后”上进行第一个挂钩。 使用Git创建新分支后,将触发该事件。

Often a naming convention is applied to make branches comparable and understand their use for the whole product.

通常使用命名约定来使分支具有可比性,并了解分支在整个产品中的用途。

You can create a simple shell script like this to ensure naming:

您可以创建一个简单的shell脚本,以确保命名:

提交消息 (Commit-msg)

In web development there are multiple libraries that help with setting up a hook for committing. Often they are not necessary, as simple scripts can be written by yourself as well.

在Web开发中,有多个库可帮助设置提交钩子。 通常它们不是必需的,因为您也可以自己编写简单的脚本。

See validation of a git message for example:

例如,请参见验证git消息:

预推 (Pre-push)

“Git push” is the process of “sharing” your branch with the team. It is often the last step before opening a pull-request for a merge with the main branch.

“推挤”是与团队“共享”分支的过程。 这通常是打开与主分支合并的拉取请求之前的最后一步。

This is a good time to check other guidelines like “linting” of the code, or if all tests are passing.

现在是检查其他准则(如代码的“ lint”)或所有测试是否通过的好时机。

An example for executing another script could be:

执行另一个脚本的示例可能是:

“执行”挂钩 (“Enforce” the hooks)

Another step is to actually enforce those hooks.

另一个步骤是实际执行这些挂钩。

In JavaScript and NPM/Yarn package managers there is a “postinstall” script already built in. It allows for the execution of a script after the installing process. But what exactly should be executed?

在JavaScript和NPM / Yarn程序包管理器中,已经内置了一个“后安装”脚本。它允许在安装过程之后执行脚本。 但是到底应该执行什么呢?

Create your own install script! Like:

创建您自己的安装脚本! 喜欢:

解决一个常见问题 (Fix one common problem)

One issue that kept me guessing for a while was that Git hooks are NOT executable by default. This means that they need to be made executable with

一个让我猜了一段时间的问题是,默认情况下,Git挂钩不可执行。 这意味着需要通过以下方式使它们成为可执行文件:

chmod +x <pathToHook>

chmod +x <pathToHo ok>

See StackOverflow discussion here.

请参阅此处的 StackOverflow讨论。

谢谢 (Thanks)

I hope that this will help some of you to align the workflow of your development team and make everyone’s lives much easier. :-)

我希望这将有助于你们中的一些人调整开发团队的工作流程,并使每个人的生活变得更加轻松。 :-)

Thanks for reading my article! Feel free to leave any feedback!

感谢您阅读我的文章! 随时留下任何反馈!

Daniel is a software developer, a LL.M. student in business law, and organizer of tech-related events in Vienna. His current personal learning efforts focus on machine learning.

Daniel是LL.M.的软件开发人员。 商法专业学生,维也纳技术相关活动的组织者。 他目前的个人学习重点是机器学习。

Connect on:

连接:

  • LinkedIn

    领英

  • Github

    Github

  • Medium

  • Twitter

    推特

  • Steemit

    Steemit

  • Hashnode

    哈希节点

翻译自: https://www.freecodecamp.org/news/improve-development-workflow-of-your-team-with-githooks-9cda15377c3b/

githooks

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/393719.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

分享AI有道干货 | 126 篇 AI 原创文章精选(ML、DL、资源、教程)

一年多来&#xff0c;公众号【AI有道】已经发布了 140 的原创文章了。内容涉及林轩田机器学习课程笔记、吴恩达 deeplearning.ai 课程笔记、机器学习、深度学习、笔试面试题、资源教程等等。值得一提的是每篇文章都是我用心整理的&#xff0c;编者一贯坚持使用通俗形象的语言给…

c语言qt生成dll与加载dll,Qt制作界面的DLL以及调用

1、将界面做成dll修改pro文件DEFINES WIDGETDLL_LIBRARYTEMPLATE lib修改头文件#if defined(WIDGETDLL_LIBRARY)# define WIDGETDLLSHARED_EXPORT Q_DECL_EXPORT#else# define WIDGETDLLSHARED_EXPORT Q_DECL_IMPORT#endifclass WIDGETDLLSHARED_EXPORT WidgetDll:public QWi…

leetcode1338. 数组大小减半(贪心算法)

给你一个整数数组 arr。你可以从中选出一个整数集合&#xff0c;并删除这些整数在数组中的每次出现。 返回 至少 能删除数组中的一半整数的整数集合的最小大小。 示例 1&#xff1a; 输入&#xff1a;arr [3,3,3,3,5,5,5,2,2,7] 输出&#xff1a;2 解释&#xff1a;选择 {3…

20162329 张旭升 2017 - 2018 《程序设计与数据结构》第五周总结

20162329 2017-2018-1 《程序设计与数据结构》第五周学习总结 教材学习内容总结 1.学习目标 了解集合的概念了解并使用抽象数据类型初步了解使用Java泛型学习栈这种数据结构用数组、链表实现栈2.学习内容 集合的概念&#xff1a; 集合是手机并组织其他对象的对象&#xff0c;他…

centos 安装trace_前期的准备工作-MacOS Mojave 10.14.3 下安装CentOS 7及Bochs 002

MacOS Mojave 10.14.3 下使用虚拟机安装CentOS 7 以及 Bochs 2.6.9CentOS 7.6.1810 系统下 安装Bochs 2.6.91 下载CentOS 7.6.1810网址为https://www.centos.org/遇到的问题安装后无法使用使用网络&#xff0c;最简单的解决方法就是增加一个新的网络适配器&#xff0c;使用Nat共…

js中的extend的用法及其JS中substring与substr的区别

1. JS中substring与substr的区别 之前在项目中用到substring方法&#xff0c;因为C#中也有字符串的截取方法Substring方法&#xff0c;当时也没有多想就误以为这两种方法的使用时一样的。这样就直接按照在C#中使用Substring的方式&#xff0c;直接在js中用了substring&#…

事件处理程序

转载于:https://www.cnblogs.com/ypx666/p/10869448.html

fis3 配置文件

1 代码: fis.match(*.less, {// fis-parser-less 插件进行解析parser: fis.plugin(less),// .less 文件后缀构建后被改成 .css 文件rExt: .css });// 配置配置文件&#xff0c;注意&#xff0c;清空所有的配置&#xff0c;只留下以下代码即可。 fis.match(*.{png,js,css}, {rel…

核心指导网络由任务编码器_如何在现实世界中与实际用户一起指导您的编码和编码生涯...

核心指导网络由任务编码器by Bob Berry由Bob Berry 如何在现实世界中与实际用户一起指导您的编码和编码生涯 (How to guide your coding and your coding career with real users, in the real world) Experience drives everything. It’s the basis of our reality. It’s a…

脉冲时间宽度c语言,基于AT89C52脉冲宽度测量仪的设计与实现

赵翠玉摘要&#xff1a;本文基于AT89C52的脉冲宽度测量仪的设计。该仪器测量结果采用了软件数字滤波&#xff0c;消除了测量中抖动问题&#xff0c;测量精度高、稳定性好&#xff0c;具有一定的实用性。关键词&#xff1a;AT89C52;测量仪;脉冲宽度中图分类号&#xff1a;TM935.…

leetcode1433. 检查一个字符串是否可以打破另一个字符串(贪心算法)

给你两个字符串 s1 和 s2 &#xff0c;它们长度相等&#xff0c;请你检查是否存在一个 s1 的排列可以打破 s2 的一个排列&#xff0c;或者是否存在一个 s2 的排列可以打破 s1 的一个排列。 字符串 x 可以打破字符串 y &#xff08;两者长度都为 n &#xff09;需满足对于所有 …

cordova 人脸识别_html5与EmguCV前后端实现——人脸识别篇(一)

上个月因为出差的关系&#xff0c;断更了很久&#xff0c;为了补偿大家长久的等待&#xff0c;送上一个新的系列&#xff0c;之前几个系列也会抽空继续更新。大概半年多前吧&#xff0c;因为工作需要&#xff0c;我开始研究图像识别技术。OpenCV在这方面已经有了很多技术积累&a…

[转载] mysql 索引中的USING BTREE 的意义

索引是在存储引擎中实现的&#xff0c;因此每种存储引擎的索引都不一定完全相同&#xff0c;并且每种存储引擎也不一定支持所有索引类型。 根据存储引擎定义每个表的最大索引数和最大索引长度。所有存储引擎支持每个表至少16个索引&#xff0c;总索引长度至少为256字节。 大多数…

git-命令

git config --global user.email “邮箱” git config --global user.name ”用户名” git init           初始化 忽略指定文件 echo "temp/" >> .gitignore echo "private_key" >> .gitginore 状态 git status 添加 git add …

C语言 floor四舍五入,Math函數的四舍五入,Floor,Ceiling,Round的一些注意事項!...

1.Math.Round&#xff1a;四舍六入五取偶引用內容Math.Round(0.0) //0Math.Round(0.1) //0Math.Round(0.2) //0Math.Round(0.3) //0Math.Round(0.4) //0Math.Round(0.5) //0Math.Round(0.6) //1Math.Round(0.7) //1Math.Round(0.8) //1Math.Round(0.9) //1說明&#xff1a;對於…

Command Magicks:如何使用控制台处理文件和字符串

by Luciano Strika通过卢西亚诺斯特里卡(Luciano Strika) Command Magicks&#xff1a;如何使用控制台处理文件和字符串 (Command Magicks: How to Manipulate Files and Strings with the Console) As developers, there are lots of repetitive things we do every day that…

dreamweaver后缀名_让 Dreamweaver 8 支持其它扩展名的方法

有的时候&#xff0c;我们为了网站的安全考虑&#xff0c;常常会修改网站的扩展名&#xff0c;如我看到有些网站的扩展名为 *.do&#xff0c;很明显这个扩展名是有意改掉的&#xff0c;可是改了这扩展名对于我们修改网页来说就麻烦了&#xff0c;比如用 Dreamweaver 8 来修改的…

sublime 3143 注册码

请大家支持购买正版&#xff0c;或者使用Atom、Vimsublime 3143版本的注册码&#xff1a;—– BEGIN LICENSE —– TwitterInc 200 User License EA7E-890007 1D77F72E 390CDD93 4DCBA022 FAF60790 61AA12C0 A37081C5 D0316412 4584D136 94D7F7D4 95BC8C1C 527DA828 560B…

【BZOJ1857】【SCOI2010】传送带 [三分]

传送带 Time Limit: 1 Sec Memory Limit: 64 MB[Submit][Status][Discuss]Description 在一个2维平面上有两条传送带&#xff0c;每一条传送带可以看成是一条线段。两条传送带分别为线段AB和线段CD。lxhgww在AB上的移动速度为P&#xff0c;在CD上的移动速度为Q&#xff0c;在平…

google android广告异步加载,谷歌广告异步代码和同步代码的解决方法

通常大部分人初次接触谷歌google adsense广告联盟都会有疑问&#xff0c;在新建单元界面我们可以看到获取代码类型选项。下面是学习啦小编为大家整理的关于谷歌广告异步代码和同步代码的解决方法&#xff0c;一起来看看吧!谷歌广告异步代码和同步代码的解决方法选择同步还是异步…