{"id":527,"date":"2018-03-03T21:58:38","date_gmt":"2018-03-03T12:58:38","guid":{"rendered":"https:\/\/yuis-programming.com\/?p=527"},"modified":"2018-02-22T16:01:40","modified_gmt":"2018-02-22T07:01:40","slug":"file-sync-with-git-gulp-expect-cron-atom","status":"publish","type":"post","link":"https:\/\/yuis-programming.com\/?p=527","title":{"rendered":"Git gulp expect cron Atom\u3067\u30ea\u30e2\u30fc\u30c8\u30b5\u30fc\u30d0\u30fc\u540c\u58eb\u3067\u30d5\u30a1\u30a4\u30eb\u540c\u671f\u3092\u3059\u308b"},"content":{"rendered":"<p>\u30ea\u30e2\u30fc\u30c8\u30de\u30b7\u30f3\u4e0a\u306e\u30c6\u30ad\u30b9\u30c8\u3084\u30d5\u30a1\u30a4\u30eb\u3092\u3001\u30db\u30b9\u30c8PC\u306b\u30b3\u30d4\u30da\u3059\u308b\u306e\u304c\u9762\u5012\u3060\u3063\u305f\u306e\u3067\u3001<br \/>\nGit gulp expect cron Atom\u3092\u4f7f\u3063\u3066\u30d5\u30a1\u30a4\u30eb\u540c\u671f\u3067\u304d\u308b\u3088\u3046\u306a\u30b7\u30b9\u30c6\u30e0\u3092\u8003\u3048\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<div id=\"toc_container\" class=\"no_bullets\"><p class=\"toc_title\">Contents<\/p><ul class=\"toc_list\"><li><a href=\"#git_push\"><span class=\"toc_number toc_depth_1\">1<\/span> \u30d5\u30a1\u30a4\u30eb\u304c\u66f4\u65b0\u3055\u308c\u308b\u305f\u3073\u306b\u81ea\u52d5\u3067git push\u3059\u308b<\/a><\/li><li><a href=\"#crongit_pull\"><span class=\"toc_number toc_depth_1\">2<\/span> cron\u3067git pull\u3092\u5b9a\u671f\u7684\u306b\u5b9f\u884c<\/a><\/li><li><a href=\"#pull\"><span class=\"toc_number toc_depth_1\">3<\/span> pull\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b<\/a><\/li><\/ul><\/div>\n<h2><span id=\"git_push\">\u30d5\u30a1\u30a4\u30eb\u304c\u66f4\u65b0\u3055\u308c\u308b\u305f\u3073\u306b\u81ea\u52d5\u3067git push\u3059\u308b<\/span><\/h2>\n<p>\/mnt\/c\/pg\/expect\/git_push<\/p>\n<pre><code>#!\/usr\/bin\/expect\n\n# C:\\pg\\expect\\rsync_ssh\n\n# log_file \/var\/log\/expect.log\n\nset USER \"yuis-ice\"\nset PW \"YOUROWN\"\nset Prompt \"\\[#$%&gt;\\]\"\n\nset timeout 5\n\nputs [exec git add -A ;]\nputs [exec git commit -m '.' ;]\n\nspawn git push -u origin master\n\nexpect {\n    -glob \"Username\" {\n        send -- \"${USER}\\n\"\n        exp_continue\n    }\n    -glob \"Password\" {\n        send -- \"${PW}\\n\"\n    }\n}\n\nexpect {\n    -glob \"${Prompt}\" {\n        interact\n        exit 0\n    }\n}\n<\/code><\/pre>\n<p>\u5171\u6709\u3057\u305f\u3044\u30c7\u30a3\u30ec\u30af\u30c8\u30ea\u3067\u3001\u307e\u305a\u306fgit remote add\u307e\u3067\u3092\u6e08\u307e\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<p>\u6b21\u306b\u3001gulp\u306e\u8a2d\u5b9a\u3067\u3059\u3002<\/p>\n<pre><code>npm install -D gulp\nnpm init -y\nnpm install child_process\n<\/code><\/pre>\n<p>gulpfile.js<\/p>\n<pre><code>var gulp = require(\"gulp\");\nvar ps = require('child_process').exec;\n\ngulp.task('exec_file', function() {\n  var command = \"\/mnt\/c\/pg\/expect\/git_push\";\n  ps(command , function (err, stdout, stderr) {\n    console.log(stdout);\n  });\n});\n\ngulp.task(\"watch\", function() {\n  var targets = [\n    '.\/**'\n  ];\n  gulp.watch(targets, ['exec_file']);\n});\n<\/code><\/pre>\n<h2><span id=\"crongit_pull\">cron\u3067git pull\u3092\u5b9a\u671f\u7684\u306b\u5b9f\u884c<\/span><\/h2>\n<p>\u6700\u521d\u306bclone\u3057\u3066\u304a\u304d\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre><code>clone github.com\/repo.git\n<\/code><\/pre>\n<p>\u3053\u3046\u3044\u3046\u611f\u3058\u306e\u30b9\u30af\u30ea\u30d7\u30c8\u3092cron\u306b\u767b\u9332\u3057\u3066\u304a\u304d\u307e\u3059\u3002<\/p>\n<pre><code>cd repo.git\ngit pull\n<\/code><\/pre>\n<p>\u3053\u308c\u3067\u30d5\u30a1\u30a4\u30eb\u306e\u540c\u671f\u304c\u3067\u304d\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>Atom\u3060\u3068\u30d5\u30a1\u30a4\u30eb\u306e\u66f4\u65b0\u304c\u3042\u308c\u3070\u3059\u3050\u306b\u30d5\u30a1\u30a4\u30eb\u3092\u6700\u65b0\u306e\u3082\u306e\u306b\u3057\u3066\u304f\u308c\u307e\u3059\u306e\u3067\u3001pull\u3059\u308b\u3068\u52dd\u624b\u306b\u30d5\u30a1\u30a4\u30eb\u3092pull\u3057\u305f\u3082\u306e\u306b\u7f6e\u304d\u63db\u3048\u3066\u304f\u308c\u307e\u3059\u306e\u3067\u4fbf\u5229\u3067\u3059\u3002<\/p>\n<h2><span id=\"pull\">pull\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\u3067\u304d\u308b\u3088\u3046\u306b\u3059\u308b<\/span><\/h2>\n<p>pull\u3057\u305f\u30d5\u30a1\u30a4\u30eb\u3092\u7de8\u96c6\u3057\u305f\u308a\u3059\u308b\u3068\u3001\u3053\u3046\u3044\u3046\u30a8\u30e9\u30fc\u304c\u3067\u308b\u3088\u3046\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n\u89e3\u6c7a\u7b56\u3068\u3057\u3066\u2026<\/p>\n<pre><code>error: Your local changes to the following files would be overwritten by merge:\n        README.md\nPlease, commit your changes or stash them before you can merge.\n<\/code><\/pre>\n<p>\u8aad\u307f\u53d6\u308a\u5c02\u7528\u3001\u3068\u3057\u3066\u5229\u7528\u3059\u308b\u306e\u304c\u826f\u3044\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u3082\u3057\u66f8\u304d\u63db\u3048\u3066\u305d\u308c\u3092commit\u3057\u305f\u3044\u3068\u304b\u304c\u3042\u308c\u3070\u3001\u66f8\u304d\u63db\u3048\u3066\u3057\u307e\u3044\u307e\u3057\u3087\u3046\u3002<br \/>\n\u305d\u3046\u3059\u308b\u3068\u5148\u7a0b\u306e\u30a8\u30e9\u30fc\u304c\u3067\u3066\u3001\u540c\u671f\u304c\u30b9\u30c8\u30c3\u30d7\u3057\u307e\u3059\u3002<\/p>\n<p>\u305d\u3057\u3066\u3001commit\u3092\u3059\u308c\u3070\u3044\u3044\u308f\u3051\u3067\u3059\u3002<\/p>\n<p>\u3082\u3057\u66f8\u304d\u63db\u3048\u3066\u3057\u307e\u3063\u305f\u306e\u304c\u9593\u9055\u3044\u3060\u3063\u305f\u5834\u5408\u3001\u6b21\u306e\u30b3\u30de\u30f3\u30c9\u3067\u30ed\u30fc\u30ab\u30eb\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u306e\u5909\u66f4\u3092\u7834\u68c4\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<\/p>\n<p><code>git reset --hard<\/code><\/p>\n<p>[get_title https:\/\/stackoverflow.com\/questions\/15745045\/how-do-i-resolve-git-saying-commit-your-changes-or-stash-them-before-you-can-me]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u30ea\u30e2\u30fc\u30c8\u30de\u30b7\u30f3\u4e0a\u306e\u30c6\u30ad\u30b9\u30c8\u3084\u30d5\u30a1\u30a4\u30eb\u3092\u3001\u30db\u30b9\u30c8PC\u306b\u30b3\u30d4\u30da\u3059\u308b\u306e\u304c\u9762\u5012\u3060\u3063\u305f\u306e\u3067\u3001 Git gulp expe [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[1],"tags":[],"acf":[],"jetpack_featured_media_url":"","jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8Rxwo-8v","_links":{"self":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/527"}],"collection":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=527"}],"version-history":[{"count":0,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=\/wp\/v2\/posts\/527\/revisions"}],"wp:attachment":[{"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=527"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=527"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/yuis-programming.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=527"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}