<kbd id="afajh"><form id="afajh"></form></kbd>
<strong id="afajh"><dl id="afajh"></dl></strong>
    <del id="afajh"><form id="afajh"></form></del>
        1. <th id="afajh"><progress id="afajh"></progress></th>
          <b id="afajh"><abbr id="afajh"></abbr></b>
          <th id="afajh"><progress id="afajh"></progress></th>

          受夠了!這糟糕的git commit記錄

          共 4222字,需瀏覽 9分鐘

           ·

          2021-06-18 05:18

          你有沒(méi)有這么寫(xiě)過(guò) commit

          你是否再也無(wú)法忍受隨意的風(fēng)格?每次更新版本都不清楚更新了哪些功能?修復(fù)了哪些 bug?溯源的時(shí)候非常痛苦?不如試試國(guó)際知名項(xiàng)目angular.js的提交規(guī)范

          還可以配置生成 ChangeLog,就像這樣

          簡(jiǎn)單嘗試一下

          該怎么做呢?先來(lái)簡(jiǎn)單嘗試一下,隨意一個(gè)個(gè)提交

          git commit -m "feat: xxxx"

          安裝自動(dòng)生成 Changelog 的組件,npm 自行安裝

          npm install -g conventional-changelog
          npm install -g conventional-changelog-cli

          如果報(bào)錯(cuò)可切換到淘寶源

          npm config set registry https://registry.npm.taobao.org

          自動(dòng)生成

          conventional-changelog -p angular -i CHANGELOG.md -s

          生成效果,出現(xiàn) CHANGELOG.md 文件,可以自行拷貝到 tag 說(shuō)明里

          # (2021-06-13)

          ### Features

          xxx ([572c950](https://github.com/golang-minibear2333/gin-blog/commit/572c9501ae291dafe26c03fdb8d4544d43a09567))

          寫(xiě)入啟動(dòng)項(xiàng),以后用changelog命令就可以執(zhí)行啦

          sudo -i
          echo alias changelog=\"conventional-changelog -p angular -i CHANGELOG.md -s\" >> /etc/rc.local

          PS: mac 系統(tǒng)需要設(shè)置開(kāi)機(jī)啟動(dòng)功能

          commit 規(guī)范

          實(shí)戰(zhàn)完畢,簡(jiǎn)單介紹下格式

          <type>(<scope>): <subject>
          <空行>
          <body>
          <空行>
          <footer>

          舉例

          feat(日志): 更新日志模塊

          1. 使用lumberjack庫(kù)增加日志模塊
          2. 配置全局配置并接入配置中心

          Close #1

          • 其中 type 指提交類型,必選
          • scope 可選,指 commit 的影響范圍,比如會(huì)影響到哪個(gè)模塊/性能/哪一層(業(yè)務(wù)層,持久層,緩存,rpc),如果是特性代碼,可以寫(xiě)特性名稱
          • subject 必選,簡(jiǎn)短描述
          • body 可選,詳細(xì)描述,表明代碼提交的動(dòng)機(jī)
          • footer 可選,結(jié)尾,可以是不兼容變更說(shuō)明,也可以是關(guān)閉 issue

          type 展開(kāi)說(shuō)明

          feat:新功能(feature)
          fix:修補(bǔ)bug
          docs:文檔(documentation)
          style:格式(不影響代碼運(yùn)行的變動(dòng))
          refactor:重構(gòu)(即不是新增功能,也不是修改bug的代碼變動(dòng))
          test:增加測(cè)試
          chore:構(gòu)建過(guò)程或輔助工具的變動(dòng)

          footer 展開(kāi)說(shuō)明

          以 BREAKING CHANGE 開(kāi)頭,后面是變更的具體描述,表示不兼容變更

          BREAKING CHANGE: 配置文件全部提取到配置中心,僅保留配置中     心注冊(cè)u(píng)rl

          Before:

          Server:
          RunMode: debug
          HttpPort: 8000
          ReadTimeout: 60
          WriteTimeout: 60

          After:

          Server:
          RunMode: debug
          configUrl: http://192.168.1.1:8010

          也可以關(guān)閉 issue

          Close #1

          自動(dòng)生成

          用交互式的方式自動(dòng)生成 commit message,運(yùn)行下面命令,使全局其支持 Angular 的 Commit message 格式。

          echo '{"path":"cz-conventional-changelog"}' > ~/.czrc

          以后你執(zhí)行 git cz 就可以替代git commit -m

          $ git add .
          $ git cz
          [email protected][email protected]

          ? 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 nor adds a feature
            perf:     A code change that improves performance
            test:     Adding missing tests or correcting existing tests
          (Move up and down to reveal more choices)
          • 使用上下鍵選擇類型,按步驟操作即可

          限制別人的提交

          提交是自由的,能規(guī)范自己的提交,能規(guī)范別人的提交嗎,是可以的,安裝組件

          npm install husky --save-dev

          會(huì)自動(dòng)生成 package.json 文件,在里面追加內(nèi)容

            "husky": {
              "hooks": {
                "commit-msg""commitlint -e $GIT_PARAMS"
              }
            }

          這樣就可以完成自動(dòng)校驗(yàn)了,但是如果本地安裝 node 也白搭

          如果是自建服務(wù)器可以通過(guò)修改--bare下的 hooks 文件來(lái)操作,但開(kāi)源代碼無(wú)法這樣操作,.git 目錄也不能提交,husky的方案,可以下載代碼后通過(guò)node運(yùn)行時(shí)更新hooks文件

          我沒(méi)辦法給中心所有項(xiàng)目提出這樣的規(guī)范,也沒(méi)辦法規(guī)定每個(gè)人都安裝 node,規(guī)范下自己還是可以做到的

          小結(jié)

          npm config set registry https://registry.npm.taobao.org
          npm install -g conventional-changelog
          npm install -g conventional-changelog-cli
          sudo -i
          echo alias changelog=\"conventional-changelog -p angular -i CHANGELOG.md -s\" >> /etc/rc.local
          npm install husky --save-dev

          package.json 文件,在里面追加內(nèi)容

            "husky": {
              "hooks": {
                "commit-msg""commitlint -e $GIT_PARAMS"
              }
            }

          未來(lái)提交就用

          git cz

          引用

          一個(gè)維護(hù)版本日志整潔的 Git 提交規(guī)范

          瀏覽 66
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          評(píng)論
          圖片
          表情
          推薦
          點(diǎn)贊
          評(píng)論
          收藏
          分享

          手機(jī)掃一掃分享

          分享
          舉報(bào)
          <kbd id="afajh"><form id="afajh"></form></kbd>
          <strong id="afajh"><dl id="afajh"></dl></strong>
            <del id="afajh"><form id="afajh"></form></del>
                1. <th id="afajh"><progress id="afajh"></progress></th>
                  <b id="afajh"><abbr id="afajh"></abbr></b>
                  <th id="afajh"><progress id="afajh"></progress></th>
                  亚洲不卡在线 | 亚洲性爱手机版 | 久久久久久久伊人大香蕉视频 | 中文字幕第23页 | 中文精品欧美无线码一区 |