{"id":6367,"date":"2011-10-24T14:54:12","date_gmt":"2011-10-24T05:54:12","guid":{"rendered":"http:\/\/fukata.org\/?p=6367"},"modified":"2017-08-11T22:58:48","modified_gmt":"2017-08-11T22:58:48","slug":"git-pre-commit-perltidy","status":"publish","type":"post","link":"https:\/\/blog.fukata.org\/archives\/6367\/","title":{"rendered":"git pre-commit\u6642\u306b\u81ea\u52d5\u7684\u306bPerltidy\u3092\u5b9f\u884c\u3059\u308b"},"content":{"rendered":"

\u524d\u56de\u306e\u8a18\u4e8b\u3067vim\u4fdd\u5b58\u6642\u306b\u81ea\u52d5\u7684\u306bPerltidy\u3092\u9069\u7528\u3059\u308b\u8a2d\u5b9a\u3092\u66f8\u304d\u307e\u3057\u305f\u304c\u3001\u6bce\u56dePerltidy\u304c\u9069\u7528\u3055\u308c\u308b\u3068\u82e5\u5e72\u30e9\u30b0\u304c\u3042\u308b\u306e\u3067\u958b\u767a\u52b9\u7387\u304c\u843d\u3061\u305d\u3046\u3067\u5acc\u3060\u306a\u3041\u3068\u601d\u3044\u3001\u3069\u3046\u305b\u306a\u3089pre-commit\u6642\u306bperltidy\u304b\u3051\u3066\u30b3\u30df\u30c3\u30c8\u3057\u305f\u3044\u3068\u3044\u3046\u3053\u3068\u3067\u4f5c\u308a\u307e\u3057\u305f\u3002<\/p>\n

\u4f7f\u3044\u65b9\u306f\u5404\u81ea\u30ed\u30fc\u30ab\u30eb\u30ea\u30dd\u30b8\u30c8\u30ea\u306e.git\/hooks\/pre-commit\u306b\u4e0b\u8a18\u306e\u5185\u5bb9\u3092\u8cbc\u308a\u4ed8\u3051\u3066\u304f\u3060\u3055\u3044\u3002<\/p>\n

\r\n#!\/bin\/bash\r\n\r\nCURRENT_DIR=\"$(pwd)\/$(dirname $0)\"\r\nPJ=\"${CURRENT_DIR%\/.}\/..\/..\"\r\nORIG_IFS=$IFS\r\nIFS=$'\\n'\r\n\r\nfor f in $(git diff --cached --name-only --diff-filter=A,M)\r\ndo\r\n\t# file is perl and exits\r\n\tif [[ \"$f\" =~ ^.+\\.(pl|pm)$ && -e \"$PJ\/$f\" ]]; then\r\n\t\tperltidy -q -b \"$PJ\/$f\"\r\n\t\tif [ $? -eq 0 ]; then\r\n\t\t\tgit add \"$PJ\/$f\"\r\n\t\t\trm -f \"$PJ\/$f.bak\"\r\n\t\tfi\r\n\tfi\r\ndone\r\n\r\nIFS=$ORIG_IFS\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"

\u524d\u56de\u306e\u8a18\u4e8b\u3067vim\u4fdd\u5b58\u6642\u306b\u81ea\u52d5\u7684\u306bPerltidy\u3092\u9069\u7528\u3059\u308b\u8a2d\u5b9a\u3092\u66f8\u304d\u307e\u3057\u305f\u304c\u3001\u6bce\u56dePerltidy\u304c\u9069\u7528\u3055\u308c\u308b\u3068\u82e5\u5e72\u30e9\u30b0\u304c\u3042\u308b\u306e\u3067\u958b\u767a\u52b9\u7387\u304c\u843d\u3061\u305d\u3046\u3067\u5acc\u3060\u306a\u3041\u3068\u601d\u3044\u3001\u3069\u3046\u305b\u306a\u3089pre-commit\u6642 … \u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":2,"featured_media":9223372036854775807,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1980],"tags":[854],"_links":{"self":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/6367"}],"collection":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/comments?post=6367"}],"version-history":[{"count":0,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/posts\/6367\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/media\/9223372036854775807"}],"wp:attachment":[{"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/media?parent=6367"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/categories?post=6367"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.fukata.org\/wp-json\/wp\/v2\/tags?post=6367"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}