約末半年前於部門架設了Gitlab伺服器,有鑑於推動部門使用更快更統一的模式來寫git相關的指令,我發現了一個很棒的開源軟體,這個軟體可以幫助我們達到快速發布版本號(tag),並且可以根據我們寫的commit規範 (conventional commit) 來生成非常漂亮的changelog。
今天著重點會在 https://github.com/conventional-changelog/standard-version
這個專案上,如果各位跟我一樣是自己架設GitLab server,想當然耳的我們的網址裡面不會出現gitlab的網址,所以你可能會發現你使用standard-version下的指令,生出來的Changelog應該是不完全的,如下圖

網址後面的 https://10.xx.xx.xx/你的專案/compare/v1.0.0-9…v1.0.0-10
那個你的專案消失了,原因是因為gitlab有所謂subgroup的概念,但原生專案是針對github所設計的,因此不會自動幫你切分出subgroup 還有你的專案。
如果你跟我一樣遇到自架網站後commit的path連結遺失,出現404 not found的問題,我對standard-version進行了修改,希望能夠幫到大家。
C:\Users\yourname\AppData\Roaming\npm\node_modules\standard-version\node_modules\hosted-git-info\git-host-info.js 檔案中,將domain改為你自己的server位置
gitlab: {
'protocols': [ 'git+ssh', 'git+https', 'ssh', 'https' ],
'domain': 'gitlab.com',
將gitlab.com 改為 你的server位置 for example: 10.x.x.x or astrid.com ….
再來
C:\Users\yourname\AppData\Roaming\npm\node_modules\standard-version\node_modules\get-pkg-repo\index.js
檔案當中,修改以下指令
// comment
//this.type = getType(repoUrl);
// add below
this.type = 'gitlab';
C:\Users\yourname\AppData\Roaming\npm\node_modules\standard-version\node_modules\parse-github-repo-url\index.js
//comment
// if (~url.host.indexOf('gitlab'))
// replace as below line
if (~url.host.indexOf('10.xx.xx.xx')) {
你就可以看到妳的專案名稱還有subgroup名稱囉!
