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.pswp.cn/news/393719.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/393719.shtml
英文地址,請注明出處:http://en.pswp.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;一起來看看吧!谷歌廣告異步代碼和同步代碼的解決方法選擇同步還是異步…