首页
在线工具
搜索
1
使用Metrics指标度量工具监控Java应用程序性能(Gauges, Counters, Histograms, Meters和 Timers实例)
2
如何将Virtualbox和VMware虚拟机相互转换
3
Jumpserver的MFA配置
4
Kuboard与KubeSphere的区别:Kubernetes管理平台对比
5
Markdown正确使用姿势
杂谈与随笔
工具与效率
源码阅读
技术管理
运维
数据库
前端开发
后端开发
Search
标签搜索
Angular
Docker
Phabricator
SpringBoot
Java
Chrome
SpringSecurity
SpringCloud
DDD
Git
Mac
K8S
Kubernetes
ESLint
SSH
高并发
Eclipse
Javascript
Vim
Centos
Jonathan
累计撰写
86
篇文章
累计收到
0
条评论
首页
栏目
杂谈与随笔
工具与效率
源码阅读
技术管理
运维
数据库
前端开发
后端开发
页面
搜索到
2
篇与
的结果
2020-08-19
Git分支命名规范
Git分支命名规范 分支 命名 说明 主分支 master 主分支,所有提供给用户使用的正式版本,都在这个主分支上发布 开发分支 dev 开发分支,永远是功能最新最全的分支 功能分支 feature- 新功能分支,某个功能点正在开发阶段 发布分支 realease- 发布定期要上线的功能 修复分支 fixbug-* 修复线上代码的 bug 主分支 Master 首先,代码库应该有一个、且仅有一个主分支。所有提供给用户使用的正式版本,都在这个主分支上发布。 Git主分支的名字,默认叫做 Master 。它是自动建立的,版本库初始化以后,默认就是在主分支在进行开发。 开发分支 Dev 主分支只用来分布重大版本,日常开发应该在另一条分支上完成。我们把开发用的分支,叫做 Dev 这个分支可以用来生成代码的最新隔夜版本(nightly)。如果想正式对外发布,就在 Master 分支上,对 Dev 分支进行”合并”(merge)。 Git创建 Dev 分支的命令: git checkout -b dev master 将 Dev 分支发布到 Master 分支的命令: 切换到 Master 分支 git checkout master 对 Dev 分支进行合并 git merge –no–ff dev 这里稍微解释一下,上一条命令的–no–ff参数是什么意思。默认情况下,Git执行”快进式合并”(fast-farward merge),会直接将 Master 分支指向 Dev 分支。 使用–no–ff参数后,会执行正常合并,在 Master 分支上生成一个新节点。为了保证版本演进的清晰,我们希望采用这种做法。 功能分支 Feature 功能分支的名字,可以采用feature-*的形式命名。 创建一个功能分支: git checkout -b feature-x dev 开发完成后,将功能分支合并到dev 分支: git checkout dev git merge –no-ff feature-x 删除feature分支: git branch -d feature-x 预发布分支 Release 第二种是预发布分支,它是指发布正式版本之前(即合并到 Master 分支之前),我们可能需要有一个预发布的版本进行测试。 预发布分支是从 Dev 分支上面分出来的,预发布结束以后,必须合并进 Dev 和 Master 分支。它的命名,可以采用release-*的形式。 创建一个预发布分支: git checkout -b release-1.2 dev 确认没有问题后,合并到master分支: git checkout master git merge –no-ff release-1.2 对合并生成的新节点,做一个标签 git tag -a 1.2 再合并到dev 分支: git checkout dev git merge –no-ff release-1.2 最后,删除预发布分支(一般等发完版本后删除): git branch -d release-1.2 修补分支 Bug 最后一种是修补bug分支。软件正式发布以后,难免会出现bug。这时就需要创建一个分支,进行bug修补。 修补bug分支是从 Master 分支上面分出来的。修补结束以后,再合并进 Master 和 Dev 分支。它的命名,可以采用fixbug-*的形式。 创建一个修补bug分支: git checkout -b fixbug-0.1 master 修补结束后,合并到master分支: git checkout master git merge –no-ff fixbug-0.1 git tag -a 0.1.1 再合并到dev 分支: git checkout dev git merge –no-ff fixbug-0.1 最后,删除”修补bug分支”: git branch -d fixbug-0.1
2020年08月19日
2018-12-29
Git 提交的正确姿势:Commit message 编写指南
Git提交的正确姿势:Commit message编写指南 第一行不超过50个字符 第二行空一行 第三行开始是描述信息,每行长度不超过72个字符,超过了自己换行。 描述信息主要说明: 这个改动为什么是必要的? 这个改动解决了什么问题? 会影响到哪些其他的代码? 最后最好有一个相应ticket的链接 摘要:Git每次提交代码,都要写Commit message(提交说明),否则就不允许提交。 Git每次提交代码,都要写Commit message(提交说明),否则就不允许提交。 $ git commit -m "hello world" 上面代码的-m参数,就是用来指定commit mesage的。 如果一行不够,可以只执行git commit,就会跳出文本编译器,让你写多行。 $ git commit 基本上,你写什么都行(这里,这里和这里)。 Nov 12, 2013 Tenth Commit N nishugames authored 3 months ago Oct 27, 2013 Ninth Commit N nishugames authored 4 months ago Oct 26, 2013 Eighth Commit N nishugames authored 4 months ago Seventh Commit nishugames authored 4 months ago Sixth Commit N nishugames authored 4 months ago Fifth Commit N nishugames authored 4 months ago Oct 24, 2013 Fourth Commit ... N nishugames authored 4 months ago Third commit N nishugames authored 4 months ago 但是,一般来说,commit message应该清晰明了,说明本次提交的目的。 Commits on Jan 5, 2016 docs(error/SrootScope/inprog): add missing "Stimeout" wytesk133 committed with petebacondarwin 10 days ago docs(tutorial/2): add e2e test missing filename monkpit committed with petebacondarwin 3 hours ago revert: feat(Scompile): Allow ES6 classes as controllers with bindTo... petebacondarwin committed 3 hours ago fix(SanimateCss): only (de)register listeners when events have been a.. Narretz committed 25 days ago fix(loader): use 'false' as default value for transclude' in compone... sarod committed with petebacondarwin 18 days ago Commits on Jan 3, 2016 feat(Scompile): Allow ES6 classes as controllers with bind ToControl.. Igalfaso committed 21 days ago chore(*): Updated year in licence leuanG committed with Igalfaso 3 days ago Commits on Jan 1, 2016 docs: reorganize information about interpolation Narretz committed on Dec 6, 2015 docs: add docs for ngPattern, ngMinlength, ngMaxlength Narretz committed on Sep 24, 2015 docs(SinterpolateProvider): remove superfluous ng-app attribute Narretz committed 4 days ago 目前,社区有多种Commit message的写法规范。本文介绍Angular规范(见上图),这是目前使用最广的写法,比较合理和系统化,并且有配套的工具。 一、Commit message的作用 格式化的Commit message,有几个好处。 (1)提供更多的历史信息,方便快速浏览 比如,下面的命令显示上次发布后的变动,每个commit占据一行。你只看行首,就知道某次commit的目的。 $ git log <last tag> HEAD --pretty=format:%s fix(ng-bind-html): watch string value instead of wrapper (4 days ago) chore(sce): remove unused function (4 days ago) <Chirayu Krishnappa> fix(ngInclude): don't break attribute bindings on ngInclude-ed element fix(ngView): IE8 regression due to expando on non-element nodes (4 days docs(ngClass): fix grammar (4 days ago) <Dave Peticolas> docs(ngCloak): fix grammar, clarity (4 days ago) <Dave Peticolas> docs(ngModelController): clarify issue with isolated scope directive docs(input): fix spelling error and reword for clarity(5 days ago) doc(ngApp): fix grammar(5 days ago)<Dave Peticolas> (origin/g3_v1_2) docs($exceptionHandler): add an example of overriding docs(FAQ): update jQuery compatibility (5 days ago) <Pete Bacon Darwin) docs(guide/services): rewording of explanation (5 days ago) <Pete Bacor docs(guide/services): explain services in plain 1anguage (5 days ago) docs(guide/i18n): change non-existent de-ge to de-de (5 days ago) <Maax docs(ngForm): fix grammar and improve explanation (5 days ago) <Dave Pe docs: update sticker ordering info in FAQ (6 days ago)<naomiblack> docs(ngResource): fix typo (6 days ago) <Tim Statler> docs(ngShowHide): fix typo (6 days ago) <Roberto Bonvallet> docs(guide/$location): describe workaround for collocated apps (6 days docs(tutorial/step_03):add info about karma-ng-scenario plug-in (6 day fix(scenario): include "not "in error messages if test is inverted (6 fix($parse): disallow access to window and dom in expressions (7 days (2)可以过滤某些commit(比如文档改动),便于快速查找信息 比如,下面的命令仅仅显示本次发布新增加的功能。 $ git log <last release> HEAD --grep feature (3)可以直接从commit生成Change log Change Log是发布新版本时,用来说明与上一个版本差异的文档,详见后文。 0.0.4 (2015-07-21) Bug Fixes ·glossary: fix bad things in the glossary (9e572e9) ·intro: fix issue with the intro not working (6de0d8a) Features ·part2: add better veggie lorem ipsum text (06912f4) ·part2: add much better lorem ipsum text (7aaf238) BREAKING CHANGES ·Adding better veggie lorem ipsum text is great and all but it breaks all the other meaty components. Be mindful of this when you test. 二、Commit message的格式 每次提交,Commit message都包括三个部分:Header、Body和Footer。 <type>(<scope>): <subject> <空一行> <body> <空一行> <footer> 其中,Header是必需的,Body和Footer可以省略。 不管是哪一个部分,任何一行都不得超过72个字符(或100个字符)。这是为了避免自动换行影响美观。 2.1 Header Header部分只有一行,包括三个字段: type(必需)、scope(可选)和subject (必需)。 (1) type type用于说明commit的类别,只允许使用下面7个标识。 feat: 新功能(feature) fix: 修补bug docs: 文档(documentation) style:格式(不影响代码运行的变动) refactor: 重构 (即不是新增功能,也不是修改bug的代码变动) test:增加测试 chore:构建过程或辅助工具的变动 如果type为feat和fix,则该commit将肯定出现在Change log之中。其他情况(docs、chore、style、refactor、test)由你决定,要不要放入Change log,建议是不要。 (2) scope scope用于说明commit影响的范围,比如数据层、控制层、视图层等等,视项目不同而不同。 (3) subject subject是commit目的的简短描述,不超过50个字符。 以动词开头,使用第一人称现在时,比如change,而不是changed或changes 第一个字母小写 结尾不加句号(.) 2.2 Body Body部分是对本次commit的详细描述,可以分成多行。下面是一个范例。 More detailed explanatory text, if necessary. Wrap it to about 72 characters or so. Further paragraphs come after blank lines. - Bullet points are okay, too - Use a hanging indent 有两个注意点。 使用第一人称现在时,比如使用change而不是changed或changes。 应该说明代码变动的动机,以及与以前行为的对比。 2.3 Footer Footer部分只用于两种情况。 (1)不兼容变动 如果当前代码与上一个版本不兼容,则Footer部分以BREAKING CHANGE开头,后面是对变动的描述、以及变动理由和迁移方法。 BREAKING CHANGE: isolate scope bindings definition has changed. To migrate the code follow the example below: Before: scope:{ myAttr: 'attribute', } After: scope:{ myAttr: } The removed inject' wasn't generally useful for directives so there should be no code using it. (2)关闭Issue 如果当前commit针对某个issue,那么可以在Footer部分关闭这个issue。 Closes #234 也可以一次关闭多个issue。 Closes #123, #245, #992 2.4 Revert 还有一种特殊情况,如果当前commit用于撤销以前的commit,则必须以revert:开头,后面跟着被撤销Commit的Header。 revert: feat(pencil): add 'graphiteWidth' option This reverts commit 667ecc1654a317a13331b17617d973392f415f02. Body部分的格式是固定的,必须写成This reverts commit <hash>.,其中的hash是被撤销commit的SHA标识符。 如果当前commit与被撤销的commit,在同一个发布(release)里面,那么它们都不会出现在Change log里面。如果两者在不同的发布,那么当前commit,会出现在Change log的Reverts小标题下面。 三、Commitizen Commitizen是一个撰写合格Commit message的工具。 安装命令如下。 $ npm install -g commitizen $ npm install -g cz-conventional-changelog 创建初始化package.json { "name": "yjauth", "version": "0.0.1", "description": "Description for yjauth", "private": true, "config":{ "commitizen":{ "path": "cz-conventional-changelog" } }, "dependencies":{ }, "devDependencies":{ }, "engines":{ "node": ">=0.12.0" } } 然后,在项目目录里,运行下面的命令,使其支持Angular的Commit message格式。 $ commitizen init cz-conventional-changelog --save --save-exact 以后,凡是用到git commit命令,一律改为使用git cz。这时,就会出现选项,用来生成符合格式的Commit message。 ng-poopy master x git add. ng-poopy master X git cz All commit message lines will be cropped at 100 characters. ? Select the type of change that you're committing: (Use arrow keys) > feat: A new feature fix: A bug fix docs: Documentation only changes style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc) refactor: A code change that neither fixes a bug or adds a feature perf: A code change that improves performance test: Adding missing tests chore: Changes to the build process or auxiliary tools and libraries such as documentation generation 四、validate-commit-msg validate-commit-msg用于检查Node项目的Commit message是否符合格式。 安装: npm install ghooks --save-dev 接着,把这个脚本加入Git的hook。下面是在package.json里面使用ghooks,把这个脚本加为commit-msg时运行。 "config":{ "ghooks":{ "commit-msg": "./validate-commit-msg.js" } } 然后,每次git commit的时候,这个脚本就会自动检查Commit message是否合格。如果不合格,就会报错。 $ git add -A $ git commit -m "edit markdown" INVALID COMMIT MSG: does not match "<type>(<scope>): <subject>"! was: edit markdown 五、生成Change log 如果你的所有Commit都符合Angular格式,那么发布新版本时,Change log就可以用脚本自动生成(例1, 例2, 例3)。 生成的文档包括以下三个部分。 New features Bug fixes Breaking changes. 每个部分都会罗列相关的commit,并且有指向这些commit的链接。当然,生成的文档允许手动修改,所以发布前,你还可以添加其他内容。 conventional-changelog就是生成Change log的工具,运行下面的命令即可。 $ npm install -g conventional-changelog-cli $ cd my-project $ conventional-changelog -p angular -i CHANGELOG.md -s This will not overwrite any previous changelog. The above generates a changelog based on commits since the last semver tag that match the pattern of a "Feature", "Fix", "Performance Improvement" or "Breaking Changes". If you first time use this tool and want to generate all previous changelog, you could do $ conventional-changelog -p angular -i CHANGELOG.md -s -r 0 上面命令不会覆盖以前的Change log,只会在CHANGELOG.md的头部加上自从上次发布以来的变动。 如果你想生成所有发布的Change log,要改为运行下面的命令。 $ conventional-changelog -p angular -i CHANGELOG.md -w -r 0 为了方便使用,可以将其写入package.json的scripts字段。 { "scripts":{ "changelog": "conventional-changelog -p angular -i CHANGELOG.md -w -r 0" } }
2018年12月29日