{"id":1629,"date":"2014-10-27T10:00:49","date_gmt":"2014-10-27T01:00:49","guid":{"rendered":"http:\/\/www.skyarch.net\/blog\/?p=1629"},"modified":"2014-10-28T09:17:48","modified_gmt":"2014-10-28T00:17:48","slug":"git%e3%83%aa%e3%83%9d%e3%82%b8%e3%83%88%e3%83%aa%e3%81%ae%e8%bf%bd%e5%8a%a0%e8%a1%8c%e6%95%b0%e3%83%ac%e3%83%9d%e3%83%bc%e3%83%86%e3%82%a3%e3%83%b3%e3%82%b0-gitlab","status":"publish","type":"post","link":"https:\/\/www.skyarch.net\/blog\/git%e3%83%aa%e3%83%9d%e3%82%b8%e3%83%88%e3%83%aa%e3%81%ae%e8%bf%bd%e5%8a%a0%e8%a1%8c%e6%95%b0%e3%83%ac%e3%83%9d%e3%83%bc%e3%83%86%e3%82%a3%e3%83%b3%e3%82%b0-gitlab\/","title":{"rendered":"git\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u8ffd\u52a0\u884c\u6570\u30ec\u30dd\u30fc\u30c6\u30a3\u30f3\u30b0 (gitlab)"},"content":{"rendered":"<h1>\u76ee\u7684<\/h1>\n<p>git\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u66f4\u65b0\u884c\u6570\u3092\u53d6\u5f97\/\u30ec\u30dd\u30fc\u30c6\u30a3\u30f3\u30b0\u3057\u305f\u3044<br \/>\n\u591a\u6570\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\/\u591a\u6570\u306e\u4eba\u304c\u3044\u308b\u74b0\u5883\u3067\u898b\u3084\u3059\u304f\u30ec\u30dd\u30fc\u30c6\u30a3\u30f3\u30b0\u3057\u305f\u3044<\/p>\n<h2>\u53d6\u5f97\u3067\u304d\u308b\u30ec\u30dd\u30fc\u30c8<\/h2>\n<h2>\u30e1\u30fc\u30eb\u4ef6\u540d<\/h2>\n<pre>\n[Report] git update row count since YYYY-MM-DD\n<\/pre>\n<h2>\u30e1\u30fc\u30eb\u672c\u6587<\/h2>\n<pre>\n========\nSummary\n========\n\nTotal 1000 Line Updated\n\n=========\nDescription\n=========\n\n- test1@test.com\n  project1: 50\n  project2: 100\n\n- test2@test.com\n  project1: 100\n  project3: 1000\n<\/pre>\n<h2>\u3069\u306e\u3088\u3046\u306b\u53d6\u5f97\u3057\u3066\u3044\u308b\u304b<\/h2>\n<p>git log\u30b3\u30de\u30f3\u30c9\u3092\u5229\u7528\u3057\u3066\u53d6\u5f97\u3057\u307e\u3059\u3002<\/p>\n<h3>\u30ea\u30dd\u30b8\u30c8\u30ea\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306b\u79fb\u52d5\u3057git log\u30b3\u30de\u30f3\u30c9\u3092\u6253\u3064<\/h3>\n<p>\u4e0b\u8a18\u30b3\u30de\u30f3\u30c9\u3067\u5bfe\u8c61\u30ec\u30dd\u30b8\u30c8\u30ea\u3078\u306e\u66f4\u65b0\u884c\u6570\u3092\u65e5\u4ed8\u6307\u5b9a\u3067\u6c42\u3081\u308b\u4e8b\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# pwd\r\n\/home\/git\/repositories\/skyarchnetworks\/linuxscripts.git\r\n# git log --author='test@test.com' --since=2014-07-01 --oneline --shortstat --no-merges 2&gt;\/dev\/null\r\n533ecf8 Feature:  fix exit code to 2  and print message\r\n 2 files changed, 59 insertions(+), 16 deletions(-)\r\n<\/pre>\n<p>\u4e0b\u8a18\u30b9\u30af\u30ea\u30d7\u30c8\u4e2d\u3067\u306f\u8ffd\u52a0\u884c\u6570\u306e\u307f\u3092\u30ab\u30a6\u30f3\u30c8\u3057\u3066\u304a\u308a\u307e\u3059\u3002<br \/>\n\u3053\u306e\u305f\u3081\u3001\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u5229\u7528\u3059\u308b\u65b0\u898f\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u304c\u8ffd\u52a0\u3055\u308c\u308b\u3068\u5927\u5909\u306a\u884c\u6570\u304c\u8ffd\u52a0\u3055\u308c\u30ec\u30dd\u30fc\u30c8\u304c<br \/>\n\u3042\u307e\u308a\u4f7f\u3044\u7269\u306b\u306a\u3089\u306a\u3044\u305f\u3081\u3001\u3042\u304f\u307e\u3067\u3082\u65e2\u5b58\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\u306e\u9032\u6357\u76ee\u5b89\u3068\u3057\u305f\u307b\u3046\u304c\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h2>\u5b9f\u969b\u306b\u52d5\u4f5c\u3055\u305b\u3066\u3044\u308b\u30b9\u30af\u30ea\u30d7\u30c8<\/h2>\n<p>member \u914d\u5217\u3092\u9806\u6b21author \u306b\u5165\u308c\u3066\u56de\u3057\u3066\u3044\u307e\u3059\u3002<br \/>\n\u305d\u306e\u969b\u306b gitlab\u304c\u4f5c\u6210\u3059\u308b .wiki.git \u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u306f\u7121\u8996\u3059\u308b\u3088\u3046\u306b\u3057\u3066\u3044\u307e\u3059\u3002<\/p>\n<p>\u6ce8\u610f\u70b9\u3068\u3057\u3066\u306fgit push\u3059\u308b\u969b\u306eauthor \u540d\u304c\u305d\u306e\u307e\u307e\u30ec\u30dd\u30b8\u30c8\u30ea\u4e0a\u306b\u53cd\u6620\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067<br \/>\n\u7d71\u4e00\u3059\u308b\u5fc5\u8981\u304c\u3042\u308a\u307e\u3059\u3002<br \/>\n(gitlab \u3060\u3068\u30e6\u30fc\u30b6\u540d\/\u30e1\u30fc\u30eb\u30a2\u30c9\u30ec\u30b9\u3069\u3061\u3089\u3067\u3082\u53d7\u3051\u4ed8\u3051\u3066\u304f\u308c\u308b\u305f\u3081\u3002)<\/p>\n<pre class=\"brush: ruby; title: ; notranslate\" title=\"\">\r\n#!\/usr\/bin\/ruby\r\n\r\nrequire 'rubygems'\r\nrequire 'active_support\/all'\r\nrequire 'mail'\r\nrequire 'pp'\r\n\r\nmembers = &#x5B;\r\n  'test1@test.com',\r\n  'test2@test.com'\r\n]\r\nresult = {}\r\ntotal = 0\r\nsince = Time.now.last_month.strftime(&quot;%Y-%m-25&quot;)\r\n\r\nDir::chdir('\/home\/git\/repositories')\r\ngit_repo_path = Dir.glob('*\/*')\r\nmembers.each {|author|\r\n    result&#x5B;&quot;#{author}&quot;] = {}\r\n    git_repo_path.each {|dir|\r\n        if \/\\.wiki\/ !~ dir\r\n            project = dir.gsub(\/.*\\\/(.*)\\.git\/, '\\1')\r\n            line = (`cd #{dir} &amp;&amp; git log --author='#{author}' --since=#{since} --oneline --shortstat --no-merges 2&gt;\/dev\/null | grep insertions | cut -d&quot; &quot; -f5 | awk 'BEGIN {sum=0} {sum+=$1} END {print sum}'`).to_i\r\n            next if line == 0\r\n            result&#x5B;&quot;#{author}&quot;]&#x5B;&quot;#{project}&quot;] = line\r\n            total = total + line\r\n        end\r\n    }\r\n}\r\npp result\r\npp total\r\n\r\nMail.defaults do\r\n  delivery_method :smtp, { address: 'localhost', port: 25 }\r\nend\r\n\r\nsummary =&lt;&lt;&quot;EOS&quot;\r\n========\r\nSummary\r\n========\r\n\r\nTotal #{total} Line Updated\r\n\r\n=========\r\nDescription\r\n=========\r\n\r\nEOS\r\n\r\n\r\nresult.each do |k, v|\r\n  next if v.empty?\r\n  summary = summary + &lt;&lt;EOS\r\n- #{k}\r\nEOS\r\n  v.each do |project, line|\r\nsummary = summary + &lt;&lt;EOS\r\n  #{project}: #{line}\r\nEOS\r\n  end\r\n  summary = summary + &quot;\\n&quot;\r\nend\r\n\r\nMail.deliver do\r\n  from    'git_report@test.com'\r\n  to      'test@test.com'\r\n  subject &quot;&#x5B;Report] git update row count since #{since}&quot;\r\n  body    &quot;#{summary}&quot;\r\nend\r\n\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\u76ee\u7684 git\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u66f4\u65b0\u884c\u6570\u3092\u53d6\u5f97\/\u30ec\u30dd\u30fc\u30c6\u30a3\u30f3\u30b0\u3057\u305f\u3044 \u591a\u6570\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8\/\u591a\u6570\u306e\u4eba\u304c\u3044\u308b\u74b0\u5883\u3067\u898b\u3084\u3059\u304f\u30ec\u30dd\u30fc\u30c6\u30a3\u30f3\u30b0\u3057\u305f\u3044 \u53d6\u5f97\u3067\u304d\u308b\u30ec\u30dd\u30fc\u30c8 \u30e1\u30fc\u30eb\u4ef6\u540d [Report] git update row coun&#8230;<\/p>\n","protected":false},"author":2,"featured_media":1632,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"","_original_post":"","footnotes":""},"categories":[9],"tags":[],"class_list":{"0":"post-1629","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-dev","8":"ja"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/1629","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/comments?post=1629"}],"version-history":[{"count":5,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/1629\/revisions"}],"predecessor-version":[{"id":1665,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/1629\/revisions\/1665"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media\/1632"}],"wp:attachment":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media?parent=1629"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/categories?post=1629"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/tags?post=1629"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}