{"id":124705,"date":"2020-06-14T19:19:00","date_gmt":"2020-06-14T11:19:00","guid":{"rendered":"http:\/\/4563.org\/?p=124705"},"modified":"2020-06-14T19:19:00","modified_gmt":"2020-06-14T11:19:00","slug":"%e5%af%b9%e6%8f%90%e4%ba%a4%e5%88%b0-gitlab-%e7%9a%84%e4%bb%a3%e7%a0%81-message-%e8%bf%9b%e8%a1%8c%e9%aa%8c%e8%af%81%e4%bb%a5%e7%ac%a6%e5%90%88-angular-%e8%a7%84%e8%8c%83","status":"publish","type":"post","link":"http:\/\/4563.org\/?p=124705","title":{"rendered":"\u5bf9\u63d0\u4ea4\u5230 gitlab \u7684\u4ee3\u7801 message \u8fdb\u884c\u9a8c\u8bc1\u4ee5\u7b26\u5408 Angular \u89c4\u8303"},"content":{"rendered":"<div>\n<div>\n<div>\n<h1>                  \u5bf9\u63d0\u4ea4\u5230 gitlab \u7684\u4ee3\u7801 message \u8fdb\u884c\u9a8c\u8bc1\u4ee5\u7b26\u5408 Angular \u89c4\u8303               <\/h1>\n<p> <\/p>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : gouchaoer <\/span>  <span><i><\/i> 7<\/span> <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<\/p><\/div>\n<div isfirst=\"1\"> <\/p>\n<p>\u73b0\u5728\u56e2\u961f\u91c7\u7528 Angular \u4ee3\u7801\u89c4\u8303\uff0c\u9700\u8981\u5bf9\u63d0\u4ea4\u5230 gitlab \u7684\u4ee3\u7801\u8fdb\u884c\u9a8c\u8bc1\uff0c\u7531\u4e8e gitlab \u63d0\u4f9b\u4e86 hooks \u673a\u5236\uff0c\u6240\u4ee5\u505a\u8d77\u6765\u8fd8\u662f\u6bd5\u7adf\u65b9\u4fbf\u7684\uff0c\u8fd9\u91cc\u5199\u4e00\u4e9b\u6211\u600e\u4e48\u505a\u7684<\/p>\n<p>\u9996\u5148 Angular \u4ee3\u7801\u89c4\u8303\u53c2\u8003\uff1a http:\/\/www.ruanyifeng.com\/blog\/2016\/01\/commit_message_change_log.html<\/p>\n<p>gitlab \u7684 hook \u673a\u5236\u53c2\u8003\uff1a https:\/\/docs.gitlab.com\/ee\/administration\/server_hooks.html<\/p>\n<p>\u4e5f\u5c31\u662f\u8bf4\u6211\u4eec\u53ef\u4ee5\u5728 pre-receive \u3001update \u548c post-receive \u8fd9 3 \u4e2a\u9636\u6bb5\u6765\u5bf9 commit message \u8fdb\u884c\u9a8c\u8bc1\uff0c\u6211\u4e4b\u524d\u5199\u7684\u7684\u5728 update \u4e2d\u9a8c\u8bc1\u7684\uff0c\u4f60\u53ef\u4ee5\u9009\u4f60\u719f\u6089\u7684\u811a\u672c\u8bed\u8a00\u6765\u5199\u3002\u5728 gitlab \u8c03\u7528 update \u811a\u672c\u7684\u65f6\u5019\u4f1a\u4f20\u5165\u66f4\u65b0\u7684 2 \u4e2a commit \u7684 hash ID\uff0c\u7136\u540e\u5728\u8fd9\u91cc\u53ef\u4ee5\u8c03\u7528 git \u6765\u89e3\u6790\u51fa\u6709\u54ea\u4e9b commit \u9700\u8981\u9a8c\u8bc1\uff08\u4f60\u6700\u597d\u627e\u4e2a\u522b\u4eba\u5199\u597d\u7684\u89e3\u6790 git commit message \u7684\u5e93\uff09\uff0c\u5982\u679c\u9a8c\u8bc1\u901a\u8fc7\u5c31\u8fd4\u56de 0\uff0c\u5426\u5219\u8fd4\u56de\u975e 0\uff0c\u6807\u51c6\u8f93\u51fa\u53ef\u4ee5\u5728 git push \u7684\u547d\u4ee4\u884c\u4e2d\u770b\u5230\u3002\u9700\u8981\u6ce8\u610f\u7684\u65f6\u5019\u5f53 push \u7684\u4e3a tag \u6216\u8005\u65b0\u7684\u5206\u652f\u7684\u65f6\u5019\uff0chash ID \u53ef\u80fd\u4e3a\u201c0000000000000000000000000000000000000000\u201d\uff0c\u8fd8\u6709\u5c31\u662f\u201cMerge branch\u201d\u7684\u9700\u8981\u8003\u8651\u8fb9\u754c\u60c5\u51b5\uff0c\u5927\u90e8\u5206\u90fd\u662f\u5185\u5bb9\u5904\u7406\u6ca1\u5565\u53ef\u8bf4\u7684\u3002\u5982\u679c\u4f60\u4eec\u8fd8\u6709\u522b\u7684\u8981\u6c42\uff0c\u53ef\u4ee5\u81ea\u5df1\u52a0\u3002<\/p>\n<p>Angular \u89c4\u8303\u6b63\u5219\u53ef\u4ee5\u5199\u6210\uff1a<\/p>\n<p>\/\/\u5339\u914d Angular \u89c4\u8303\u5173\u952e\u5b57<\/p>\n<pre><code>$res = preg_match(\"#^s*(feat|fix|docs|style|refactor|test|chore)((.+))?:.+#\", $message, $matches);         if(!$res){             $msg = \"your commit message format is wrong, see:'http:\/\/www.ruanyifeng.com\/blog\/2016\/01\/commit_message_change_log.html', message:{$message}\";             if($NEED_VERIFY){                 log_file($msg, true);                 exit(1);             }else{                 log_file($msg);             }         } <\/code><\/pre>\n<p>\u6700\u540e\u5c31\u662f\uff0c\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\u6211\u4eec\u9700\u8981 skip \u6389\u9a8c\u8bc1\uff0c\u4f46\u662f hook \u6ca1\u6709\u63d0\u4f9b\u989d\u5916\u7684\u53c2\u6570\uff0c\u8fd9\u91cc\u53ea\u6709\u624b\u52a8\u53bb\u6539\u4e86\uff0c\u641c\u4e86\u4e00\u4e0b gitlab \u7528\u4e86 git push -o \u7684\u53c2\u6570\uff0c\u5728 pre-receive \u4e0b\uff0c\u52a0\u4e0a\u8fd9\u884c\uff1a<\/p>\n<pre><code>refs = $stdin.read  require_relative '..\/lib\/hooks_utils' push_options = HooksUtils.get_push_options if push_options[0]==\"skip\"     aFile = File.new(\"\/tmp\/gitlab-skip\", \"w\")     if aFile         content = aFile.syswrite(refs)     else         puts \"Unable to open \/tmp\/gitlab-skip\"     end end <\/code><\/pre>\n<p>\u7136\u540e\u5728 update \u811a\u672c\u91cc\u68c0\u67e5\u7684\u65f6\u5019\u53bb \/tmp\/gitlab-skip \u8bfb\u53d6 commit \u7684 hash\uff0c\u770b\u76f8\u7b49\u5c31\u8df3\u8fc7\u9a8c\u8bc1<\/p>\n<\/p><\/div>\n<div> <b>\u5927\u4f6c\u6709\u8a71\u8aaa<\/b> (<span>5<\/span>)        <\/div>\n<div> <\/div>\n<\/p><\/div>\n<\/p><\/div>\n<ul>\n<li data-pid=\"2177099\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : flyingfz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u641c\u4e00\u4e0b git cz                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2177100\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : flyingfz <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             https:\/\/juejin.im\/post\/5cc4694a6fb9a03238106eb9                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2177101\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u4e3b<\/span> <span>\u8cc7\u6df1\u5927\u4f6c : gouchaoer <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             @flyingfz \u6211\u662f\u5728\u670d\u52a1\u5668\u7aef\u9a8c\u8bc1\u7684\uff0c\u4e0d\u662f\u5ba2\u6237\u7aef\uff0c\u5ba2\u6237\u7aef\u6ca1\u6cd5\u5206\u53d1\u8fd9\u4e2a\u5de5\u5177\u3002\u3002\u3002\u3002\u8fd8\u6709\u6211\u9664\u4e86\u8981\u7b26\u5408 Angular \u89c4\u8303\uff0c\u8fd8\u6709\u522b\u7684\u5b9a\u5236\u529f\u80fd\uff0c\u6bd4\u5982\u548c\u9879\u76ee\u7ba1\u7406\u4e4b\u95f4\u8054\u52a8\u3002\u3002\u3002\u8fd9\u4e2a cz \u4f9d\u8d56\u592a\u590d\u6742\uff0c\u6211\u751f\u6210 CHANGELOG \u8c03\u7814\u4e86\u4e00\u4e0b\uff0c\u9009\u4e86 golang \u4e00\u4e2a\uff0c\u76f4\u63a5\u7f16\u8bd1\u6210\u4e8c\u8fdb\u5236\u65e0\u4f9d\u8d56                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2177102\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : yuxizhe <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             gitlab ci \u914d\u7f6e\u4e2a commitlint \u5c31\u884c\u4e86\uff0c\u4e0d\u8981\u778e\u9020\u8f6e\u5b50<br \/>https:\/\/github.com\/conventional-changelog\/commitlint                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li data-pid=\"2177103\" data-uid=\"2\">\n<div>\n<div>\n<div> <span>\u8cc7\u6df1\u5927\u4f6c : SoloCompany <\/span>  <\/div>\n<div> <i title=\"\u5f15\u7528\"><\/i>  <span>          <\/span> <\/div>\n<\/p><\/div>\n<div>                                                             \u5982\u679c\u6ca1\u6709 MR, \u4ec5\u4ec5\u9760 Hook \u6ca1\u6709\u591a\u5c11\u610f\u4e49<br \/>\u5982\u679c\u6709 MR, \u90a3\u5e72\u561b\u8fd8\u8981 Hook? \u6709\u610f\u4e49\u7684\u66ff\u4ee3\u54c1\u5e94\u8be5\u662f approval robot                                                            <\/div>\n<\/p><\/div>\n<\/li>\n<li>\n","protected":false},"excerpt":{"rendered":"<p>\u5bf9\u63d0\u4ea4\u5230 gitlab \u7684\u4ee3\u7801 m&hellip;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[],"tags":[],"_links":{"self":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/124705"}],"collection":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=124705"}],"version-history":[{"count":0,"href":"http:\/\/4563.org\/index.php?rest_route=\/wp\/v2\/posts\/124705\/revisions"}],"wp:attachment":[{"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=124705"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=124705"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/4563.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=124705"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}