{"action":"created","comment":{"url":"https://api.github.com/repos/cnpm/mirrors/pulls/comments/59708369","id":59708369,"diff_hunk":"@@ -0,0 +1,136 @@\n+/**\n+ * Copyright(c) cnpm and other contributors.\n+ * MIT Licensed\n+ *\n+ * Authors:\n+ *   fengmk2 <fengmk2@gmail.com> (http://fengmk2.com)\n+ */\n+\n+'use strict';\n+\n+/**\n+ * Module dependencies.\n+ */\n+\n+var debug = require('debug')('mirrors:sync:nodegit');\n+var util = require('util');\n+var urllib = require('urllib');\n+var Syncer = require('./syncer');\n+\n+module.exports = NodeGitSyncer;\n+\n+function NodeGitSyncer(options) {\n+  if (!(this instanceof NodeGitSyncer)) {\n+    return new NodeGitSyncer(options);\n+  }\n+  Syncer.call(this, options);\n+  this._npmPackageUrl = 'https://registry.npmjs.com/nodegit';\n+  this._storeUrl = 'https://nodegit.s3.amazonaws.com/nodegit/nodegit/';\n+}\n+\n+util.inherits(NodeGitSyncer, Syncer);\n+\n+var proto = NodeGitSyncer.prototype;\n+\n+proto.check = function() {\n+  return true;\n+};\n+\n+proto.listdiff = function* (fullname, dirIndex) {\n+  if (dirIndex !== 0) {\n+    return [];\n+  }\n+\n+  var existsCount = 0;\n+  var existDirs = yield this.listExists('/');\n+  var existDirsMap = {};\n+  for (var i = 0; i < existDirs.length; i++) {\n+    var item = existDirs[i];\n+    existDirsMap[item.name] = true;\n+  }\n+  var result = yield urllib.request(this._npmPackageUrl, {\n+    timeout: 60000,\n+    dataType: 'json',\n+    gzip: true,\n+    followRedirect: true,\n+  });\n+  var versions = result.data.versions || {};\n+  var needs = [];\n+  for (var version in versions) {\n+    var pkg = versions[version];\n+    var binaryInfo = pkg.binary || {};\n+    pkg.dirname = 'v' + pkg.version + '/';\n+    pkg.publish_time = result.data.time[pkg.version];\n+    if (existDirsMap[pkg.dirname]) {\n+      existsCount++;\n+      continue;\n+    }\n+    if (binaryInfo.host && binaryInfo.host.indexOf(this._storeUrl) === 0) {","path":"sync/nodegit.js","position":68,"original_position":68,"commit_id":"d0fd92215781dcb8fd780017582c84185cb36f40","original_commit_id":"6fa7dee3e89547d682a5419f59e170402368d5ee","user":{"login":"fengmk2","id":156269,"avatar_url":"https://avatars.githubusercontent.com/u/156269?v=3","gravatar_id":"","url":"https://api.github.com/users/fengmk2","html_url":"https://github.com/fengmk2","followers_url":"https://api.github.com/users/fengmk2/followers","following_url":"https://api.github.com/users/fengmk2/following{/other_user}","gists_url":"https://api.github.com/users/fengmk2/gists{/gist_id}","starred_url":"https://api.github.com/users/fengmk2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fengmk2/subscriptions","organizations_url":"https://api.github.com/users/fengmk2/orgs","repos_url":"https://api.github.com/users/fengmk2/repos","events_url":"https://api.github.com/users/fengmk2/events{/privacy}","received_events_url":"https://api.github.com/users/fengmk2/received_events","type":"User","site_admin":false},"body":"嗯，没法同步\n\nSent from my iPhone\n\n> On Apr 14, 2016, at 4:53 PM, Yiyu He <notifications@github.com> wrote:\n> \n> In sync/nodegit.js:\n> \n> > +    dataType: 'json',\n> > +    gzip: true,\n> > +    followRedirect: true,\n> > +  });\n> > +  var versions = result.data.versions || {};\n> > +  var needs = [];\n> > +  for (var version in versions) {\n> > +    var pkg = versions[version];\n> > +    var binaryInfo = pkg.binary || {};\n> > +    pkg.dirname = 'v' + pkg.version + '/';\n> > +    pkg.publish_time = result.data.time[pkg.version];\n> > +    if (existDirsMap[pkg.dirname]) {\n> > +      existsCount++;\n> > +      continue;\n> > +    }\n> > +    if (binaryInfo.host && binaryInfo.host.indexOf(this._storeUrl) === 0) {\n> 前期有一些老版本不是用这个 host 的就不管了？\n> \n> —\n> You are receiving this because you authored the thread.\n> Reply to this email directly or view it on GitHub\n> \n","created_at":"2016-04-14T12:32:31Z","updated_at":"2016-04-14T12:32:31Z","html_url":"https://github.com/cnpm/mirrors/pull/96#discussion_r59708369","pull_request_url":"https://api.github.com/repos/cnpm/mirrors/pulls/96","_links":{"self":{"href":"https://api.github.com/repos/cnpm/mirrors/pulls/comments/59708369"},"html":{"href":"https://github.com/cnpm/mirrors/pull/96#discussion_r59708369"},"pull_request":{"href":"https://api.github.com/repos/cnpm/mirrors/pulls/96"}}},"pull_request":{"url":"https://api.github.com/repos/cnpm/mirrors/pulls/96","id":66427351,"html_url":"https://github.com/cnpm/mirrors/pull/96","diff_url":"https://github.com/cnpm/mirrors/pull/96.diff","patch_url":"https://github.com/cnpm/mirrors/pull/96.patch","issue_url":"https://api.github.com/repos/cnpm/mirrors/issues/96","number":96,"state":"closed","locked":false,"title":"feat: mirror nodegit","user":{"login":"fengmk2","id":156269,"avatar_url":"https://avatars.githubusercontent.com/u/156269?v=3","gravatar_id":"","url":"https://api.github.com/users/fengmk2","html_url":"https://github.com/fengmk2","followers_url":"https://api.github.com/users/fengmk2/followers","following_url":"https://api.github.com/users/fengmk2/following{/other_user}","gists_url":"https://api.github.com/users/fengmk2/gists{/gist_id}","starred_url":"https://api.github.com/users/fengmk2/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fengmk2/subscriptions","organizations_url":"https://api.github.com/users/fengmk2/orgs","repos_url":"https://api.github.com/users/fengmk2/repos","events_url":"https://api.github.com/users/fengmk2/events{/privacy}","received_events_url":"https://api.github.com/users/fengmk2/received_events","type":"User","site_admin":false},"body":"closes #92","created_at":"2016-04-14T04:23:02Z","updated_at":"2016-04-14T12:32:31Z","closed_at":"2016-04-14T09:18:36Z","merged_at":"2016-04-14T09:18:36Z","merge_commit_sha":"c4c4eca5d7d6e2d1d3dc5f577127c9fe76fe05a2","assignee":{"login":"dead-horse","id":985607,"avatar_url":"https://avatars.githubusercontent.com/u/985607?v=3","gravatar_id":"","url":"https://api.github.com/users/dead-horse","html_url":"https://github.com/dead-horse","followers_url":"https://api.github.com/users/dead-horse/followers","following_url":"https://api.github.com/users/dead-horse/following{/other_user}","gists_url":"https://api.github.com/users/dead-horse/gists{/gist_id}","starred_url":"https://api.github.com/users/dead-horse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dead-horse/subscriptions","organizations_url":"https://api.github.com/users/dead-horse/orgs","repos_url":"https://api.github.com/users/dead-horse/repos","events_url":"https://api.github.com/users/dead-horse/events{/privacy}","received_events_url":"https://api.github.com/users/dead-horse/received_events","type":"User","site_admin":false},"milestone":{"url":"https://api.github.com/repos/cnpm/mirrors/milestones/1","html_url":"https://github.com/cnpm/mirrors/milestones/1.0","labels_url":"https://api.github.com/repos/cnpm/mirrors/milestones/1/labels","id":939961,"number":1,"title":"1.0","description":"- 网站 & JSON API\r\n- `mirror-cli` 客户端工具\r\n- 补齐同步\r\n\r\n","creator":{"login":"dead-horse","id":985607,"avatar_url":"https://avatars.githubusercontent.com/u/985607?v=3","gravatar_id":"","url":"https://api.github.com/users/dead-horse","html_url":"https://github.com/dead-horse","followers_url":"https://api.github.com/users/dead-horse/followers","following_url":"https://api.github.com/users/dead-horse/following{/other_user}","gists_url":"https://api.github.com/users/dead-horse/gists{/gist_id}","starred_url":"https://api.github.com/users/dead-horse/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dead-horse/subscriptions","organizations_url":"https://api.github.com/users/dead-horse/orgs","repos_url":"https://api.github.com/users/dead-horse/repos","events_url":"https://api.github.com/users/dead-horse/events{/privacy}","received_events_url":"https://api.github.com/users/dead-horse/received_events","type":"User","site_admin":false},"open_issues":3,"closed_issues":23,"state":"open","created_at":"2015-01-17T18:51:34Z","updated_at":"2016-04-14T09:18:36Z","due_on":"2015-01-30T16:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/cnpm/mirrors/pulls/96/commits","review_comments_url":"https://api.github.com/repos/cnpm/mirrors/pulls/96/comments","review_comment_url":"https://api.github.com/repos/cnpm/mirrors/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cnpm/mirrors/issues/96/comments","statuses_url":"https://api.github.com/repos/cnpm/mirrors/statuses/d0fd92215781dcb8fd780017582c84185cb36f40","head":{"label":"cnpm:mirror-nodegit","ref":"mirror-nodegit","sha":"d0fd92215781dcb8fd780017582c84185cb36f40","user":{"login":"cnpm","id":6365106,"avatar_url":"https://avatars.githubusercontent.com/u/6365106?v=3","gravatar_id":"","url":"https://api.github.com/users/cnpm","html_url":"https://github.com/cnpm","followers_url":"https://api.github.com/users/cnpm/followers","following_url":"https://api.github.com/users/cnpm/following{/other_user}","gists_url":"https://api.github.com/users/cnpm/gists{/gist_id}","starred_url":"https://api.github.com/users/cnpm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cnpm/subscriptions","organizations_url":"https://api.github.com/users/cnpm/orgs","repos_url":"https://api.github.com/users/cnpm/repos","events_url":"https://api.github.com/users/cnpm/events{/privacy}","received_events_url":"https://api.github.com/users/cnpm/received_events","type":"Organization","site_admin":false},"repo":{"id":29094885,"name":"mirrors","full_name":"cnpm/mirrors","owner":{"login":"cnpm","id":6365106,"avatar_url":"https://avatars.githubusercontent.com/u/6365106?v=3","gravatar_id":"","url":"https://api.github.com/users/cnpm","html_url":"https://github.com/cnpm","followers_url":"https://api.github.com/users/cnpm/followers","following_url":"https://api.github.com/users/cnpm/following{/other_user}","gists_url":"https://api.github.com/users/cnpm/gists{/gist_id}","starred_url":"https://api.github.com/users/cnpm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cnpm/subscriptions","organizations_url":"https://api.github.com/users/cnpm/orgs","repos_url":"https://api.github.com/users/cnpm/repos","events_url":"https://api.github.com/users/cnpm/events{/privacy}","received_events_url":"https://api.github.com/users/cnpm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cnpm/mirrors","description":"mirrors all you need","fork":false,"url":"https://api.github.com/repos/cnpm/mirrors","forks_url":"https://api.github.com/repos/cnpm/mirrors/forks","keys_url":"https://api.github.com/repos/cnpm/mirrors/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cnpm/mirrors/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cnpm/mirrors/teams","hooks_url":"https://api.github.com/repos/cnpm/mirrors/hooks","issue_events_url":"https://api.github.com/repos/cnpm/mirrors/issues/events{/number}","events_url":"https://api.github.com/repos/cnpm/mirrors/events","assignees_url":"https://api.github.com/repos/cnpm/mirrors/assignees{/user}","branches_url":"https://api.github.com/repos/cnpm/mirrors/branches{/branch}","tags_url":"https://api.github.com/repos/cnpm/mirrors/tags","blobs_url":"https://api.github.com/repos/cnpm/mirrors/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cnpm/mirrors/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cnpm/mirrors/git/refs{/sha}","trees_url":"https://api.github.com/repos/cnpm/mirrors/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cnpm/mirrors/statuses/{sha}","languages_url":"https://api.github.com/repos/cnpm/mirrors/languages","stargazers_url":"https://api.github.com/repos/cnpm/mirrors/stargazers","contributors_url":"https://api.github.com/repos/cnpm/mirrors/contributors","subscribers_url":"https://api.github.com/repos/cnpm/mirrors/subscribers","subscription_url":"https://api.github.com/repos/cnpm/mirrors/subscription","commits_url":"https://api.github.com/repos/cnpm/mirrors/commits{/sha}","git_commits_url":"https://api.github.com/repos/cnpm/mirrors/git/commits{/sha}","comments_url":"https://api.github.com/repos/cnpm/mirrors/comments{/number}","issue_comment_url":"https://api.github.com/repos/cnpm/mirrors/issues/comments{/number}","contents_url":"https://api.github.com/repos/cnpm/mirrors/contents/{+path}","compare_url":"https://api.github.com/repos/cnpm/mirrors/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cnpm/mirrors/merges","archive_url":"https://api.github.com/repos/cnpm/mirrors/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cnpm/mirrors/downloads","issues_url":"https://api.github.com/repos/cnpm/mirrors/issues{/number}","pulls_url":"https://api.github.com/repos/cnpm/mirrors/pulls{/number}","milestones_url":"https://api.github.com/repos/cnpm/mirrors/milestones{/number}","notifications_url":"https://api.github.com/repos/cnpm/mirrors/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cnpm/mirrors/labels{/name}","releases_url":"https://api.github.com/repos/cnpm/mirrors/releases{/id}","deployments_url":"https://api.github.com/repos/cnpm/mirrors/deployments","created_at":"2015-01-11T14:49:47Z","updated_at":"2016-04-09T06:34:13Z","pushed_at":"2016-04-14T09:18:37Z","git_url":"git://github.com/cnpm/mirrors.git","ssh_url":"git@github.com:cnpm/mirrors.git","clone_url":"https://github.com/cnpm/mirrors.git","svn_url":"https://github.com/cnpm/mirrors","homepage":"https://npm.taobao.org/mirrors","size":9361,"stargazers_count":12,"watchers_count":12,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":5,"forks":6,"open_issues":5,"watchers":12,"default_branch":"master"}},"base":{"label":"cnpm:master","ref":"master","sha":"f75ab77636eee2ffe642ab36a0c70fe29a6ef63f","user":{"login":"cnpm","id":6365106,"avatar_url":"https://avatars.githubusercontent.com/u/6365106?v=3","gravatar_id":"","url":"https://api.github.com/users/cnpm","html_url":"https://github.com/cnpm","followers_url":"https://api.github.com/users/cnpm/followers","following_url":"https://api.github.com/users/cnpm/following{/other_user}","gists_url":"https://api.github.com/users/cnpm/gists{/gist_id}","starred_url":"https://api.github.com/users/cnpm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cnpm/subscriptions","organizations_url":"https://api.github.com/users/cnpm/orgs","repos_url":"https://api.github.com/users/cnpm/repos","events_url":"https://api.github.com/users/cnpm/events{/privacy}","received_events_url":"https://api.github.com/users/cnpm/received_events","type":"Organization","site_admin":false},"repo":{"id":29094885,"name":"mirrors","full_name":"cnpm/mirrors","owner":{"login":"cnpm","id":6365106,"avatar_url":"https://avatars.githubusercontent.com/u/6365106?v=3","gravatar_id":"","url":"https://api.github.com/users/cnpm","html_url":"https://github.com/cnpm","followers_url":"https://api.github.com/users/cnpm/followers","following_url":"https://api.github.com/users/cnpm/following{/other_user}","gists_url":"https://api.github.com/users/cnpm/gists{/gist_id}","starred_url":"https://api.github.com/users/cnpm/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cnpm/subscriptions","organizations_url":"https://api.github.com/users/cnpm/orgs","repos_url":"https://api.github.com/users/cnpm/repos","events_url":"https://api.github.com/users/cnpm/events{/privacy}","received_events_url":"https://api.github.com/users/cnpm/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cnpm/mirrors","description":"mirrors all you need","fork":false,"url":"https://api.github.com/repos/cnpm/mirrors","forks_url":"https://api.github.com/repos/cnpm/mirrors/forks","keys_url":"https://api.github.com/repos/cnpm/mirrors/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cnpm/mirrors/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cnpm/mirrors/teams","hooks_url":"https://api.github.com/repos/cnpm/mirrors/hooks","issue_events_url":"https://api.github.com/repos/cnpm/mirrors/issues/events{/number}","events_url":"https://api.github.com/repos/cnpm/mirrors/events","assignees_url":"https://api.github.com/repos/cnpm/mirrors/assignees{/user}","branches_url":"https://api.github.com/repos/cnpm/mirrors/branches{/branch}","tags_url":"https://api.github.com/repos/cnpm/mirrors/tags","blobs_url":"https://api.github.com/repos/cnpm/mirrors/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cnpm/mirrors/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cnpm/mirrors/git/refs{/sha}","trees_url":"https://api.github.com/repos/cnpm/mirrors/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cnpm/mirrors/statuses/{sha}","languages_url":"https://api.github.com/repos/cnpm/mirrors/languages","stargazers_url":"https://api.github.com/repos/cnpm/mirrors/stargazers","contributors_url":"https://api.github.com/repos/cnpm/mirrors/contributors","subscribers_url":"https://api.github.com/repos/cnpm/mirrors/subscribers","subscription_url":"https://api.github.com/repos/cnpm/mirrors/subscription","commits_url":"https://api.github.com/repos/cnpm/mirrors/commits{/sha}","git_commits_url":"https://api.github.com/repos/cnpm/mirrors/git/commits{/sha}","comments_url":"https://api.github.com/repos/cnpm/mirrors/comments{/number}","issue_comment_url":"https://api.github.com/repos/cnpm/mirrors/issues/comments{/number}","contents_url":"https://api.github.com/repos/cnpm/mirrors/contents/{+path}","compare_url":"https://api.github.com/repos/cnpm/mirrors/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cnpm/mirrors/merges","archive_url":"https://api.github.com/repos/cnpm/mirrors/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cnpm/mirrors/downloads","issues_url":"https://api.github.com/repos/cnpm/mirrors/issues{/number}","pulls_url":"https://api.github.com/repos/cnpm/mirrors/pulls{/number}","milestones_url":"https://api.github.com/repos/cnpm/mirrors/milestones{/number}","notifications_url":"https://api.github.com/repos/cnpm/mirrors/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cnpm/mirrors/labels{/name}","releases_url":"https://api.github.com/repos/cnpm/mirrors/releases{/id}","deployments_url":"https://api.github.com/repos/cnpm/mirrors/deployments","created_at":"2015-01-11T14:49:47Z","updated_at":"2016-04-09T06:34:13Z","pushed_at":"2016-04-14T09:18:37Z","git_url":"git://github.com/cnpm/mirrors.git","ssh_url":"git@github.com:cnpm/mirrors.git","clone_url":"https://github.com/cnpm/mirrors.git","svn_url":"https://github.com/cnpm/mirrors","homepage":"https://npm.taobao.org/mirrors","size":9361,"stargazers_count":12,"watchers_count":12,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":6,"mirror_url":null,"open_issues_count":5,"forks":6,"open_issues":5,"watchers":12,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/cnpm/mirrors/pulls/96"},"html":{"href":"https://github.com/cnpm/mirrors/pull/96"},"issue":{"href":"https://api.github.com/repos/cnpm/mirrors/issues/96"},"comments":{"href":"https://api.github.com/repos/cnpm/mirrors/issues/96/comments"},"review_comments":{"href":"https://api.github.com/repos/cnpm/mirrors/pulls/96/comments"},"review_comment":{"href":"https://api.github.com/repos/cnpm/mirrors/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cnpm/mirrors/pulls/96/commits"},"statuses":{"href":"https://api.github.com/repos/cnpm/mirrors/statuses/d0fd92215781dcb8fd780017582c84185cb36f40"}}}}