{"action":"created","comment":{"url":"https://api.github.com/repos/bundler/bundler/pulls/comments/48520115","id":48520115,"diff_hunk":"@@ -0,0 +1,81 @@\n+require \"bundler/fetcher/base\"\n+\n+module Bundler\n+  class Fetcher\n+    class CompactIndex < Base\n+      require \"bundler/vendor/compact_index_client/lib/compact_index_client\"\n+\n+      def specs(gem_names)\n+        specs_for_names(gem_names)\n+      rescue NetworkDownError => e\n+        raise HTTPError, e.message\n+      rescue AuthenticationRequiredError\n+        raise # We got a 401 from the server. Just fail.\n+      rescue HTTPError => e\n+        Bundler.ui.trace(e)\n+        nil\n+      end\n+\n+      def specs_for_names(gem_names)\n+        gem_info = []\n+        complete_gems = []\n+        remaining_gems = gem_names.dup\n+\n+        until remaining_gems.empty?\n+          Bundler.ui.debug \"Looking up gems #{remaining_gems.inspect}\"\n+\n+          deps = compact_index_client.dependencies(remaining_gems)\n+          next_gems = deps.map {|d| d[3].map(&:first).flatten(1) }.flatten(1).uniq\n+          deps.each {|dep| gem_info << dep }\n+          complete_gems.push(*deps.map(&:first).uniq)\n+          remaining_gems = next_gems - complete_gems\n+        end\n+\n+        gem_info\n+      end\n+\n+      def fetch_spec(spec)\n+        spec -= [nil, \"ruby\", \"\"]\n+        contents = compact_index_client.spec(*spec)\n+        return nil if contents.nil?\n+        contents.unshift(spec.first)\n+        contents[3].map! {|d| Gem::Dependency.new(*d) }\n+        EndpointSpecification.new(*contents)\n+      end\n+\n+      def available?\n+        # Read info file checksums out of /versions, so we can know if gems are up to date\n+        fetch_uri.scheme != \"file\" && compact_index_client.update_and_parse_checksums!\n+      rescue NetworkDownError => e\n+        raise HTTPError, e.message\n+      rescue AuthenticationRequiredError\n+        # We got a 401 from the server. Just fail.\n+        raise\n+      rescue HTTPError\n+        false\n+      end\n+\n+      def api_fetcher?\n+        true\n+      end\n+\n+    private\n+\n+      def compact_index_client\n+        @compact_index_client ||= begin\n+          path_digest = Digest::MD5.hexdigest(display_uri.path)\n+          uri_part = [display_uri.host, display_uri.port, path_digest].compact.join(\".\")","path":"lib/bundler/fetcher/compact_index.rb","position":67,"original_position":67,"commit_id":"d50d6d2cf62fb04e61cdcf453044a16bc053d8a2","original_commit_id":"d50d6d2cf62fb04e61cdcf453044a16bc053d8a2","user":{"login":"segiddins","id":1946610,"avatar_url":"https://avatars.githubusercontent.com/u/1946610?v=3","gravatar_id":"","url":"https://api.github.com/users/segiddins","html_url":"https://github.com/segiddins","followers_url":"https://api.github.com/users/segiddins/followers","following_url":"https://api.github.com/users/segiddins/following{/other_user}","gists_url":"https://api.github.com/users/segiddins/gists{/gist_id}","starred_url":"https://api.github.com/users/segiddins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segiddins/subscriptions","organizations_url":"https://api.github.com/users/segiddins/orgs","repos_url":"https://api.github.com/users/segiddins/repos","events_url":"https://api.github.com/users/segiddins/events{/privacy}","received_events_url":"https://api.github.com/users/segiddins/received_events","type":"User","site_admin":false},"body":"have to make sure we're happy with this as the path","created_at":"2015-12-29T03:30:47Z","updated_at":"2015-12-29T03:30:47Z","html_url":"https://github.com/bundler/bundler/pull/3556#discussion_r48520115","pull_request_url":"https://api.github.com/repos/bundler/bundler/pulls/3556","_links":{"self":{"href":"https://api.github.com/repos/bundler/bundler/pulls/comments/48520115"},"html":{"href":"https://github.com/bundler/bundler/pull/3556#discussion_r48520115"},"pull_request":{"href":"https://api.github.com/repos/bundler/bundler/pulls/3556"}}},"pull_request":{"url":"https://api.github.com/repos/bundler/bundler/pulls/3556","id":33017900,"html_url":"https://github.com/bundler/bundler/pull/3556","diff_url":"https://github.com/bundler/bundler/pull/3556.diff","patch_url":"https://github.com/bundler/bundler/pull/3556.patch","issue_url":"https://api.github.com/repos/bundler/bundler/issues/3556","number":3556,"state":"open","locked":false,"title":"[Fetcher] Add Fetchers for the new index format!","user":{"login":"segiddins","id":1946610,"avatar_url":"https://avatars.githubusercontent.com/u/1946610?v=3","gravatar_id":"","url":"https://api.github.com/users/segiddins","html_url":"https://github.com/segiddins","followers_url":"https://api.github.com/users/segiddins/followers","following_url":"https://api.github.com/users/segiddins/following{/other_user}","gists_url":"https://api.github.com/users/segiddins/gists{/gist_id}","starred_url":"https://api.github.com/users/segiddins/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/segiddins/subscriptions","organizations_url":"https://api.github.com/users/segiddins/orgs","repos_url":"https://api.github.com/users/segiddins/repos","events_url":"https://api.github.com/users/segiddins/events{/privacy}","received_events_url":"https://api.github.com/users/segiddins/received_events","type":"User","site_admin":false},"body":"Things that need to be tested:\r\n\r\n- [x] CompactGemList sources\r\n- [x] mixed compact and full index sources\r\n- [x] mixed compact and api sources\r\n- [x] mixed compact, full, and api sources\r\n- [x] fallback from compact to api\r\n- [x] fallback from compact to full\r\n\r\nThings that need to be finished to ship this:\r\n\r\n - [x] install gems via compact index\r\n - [x] stop requesting /api/v1/dependencies if compact index request succeeds\r\n - [x] stop printing \"Need to query more than 500 gems. Downloading full index instead...\"\r\n - [x] stop printing \"Fetching source index from https://bundler-api-staging.herokuapp.com/\"\r\n - [x] print useful info message, proposed:\r\n    - [x] print \"Fetching gem information from <server>...\" before requesting `/versions`\r\n    - [x] print \".\" for each additional `/info/<gem>` request\r\n - [x] accept full files gzipped\r\n - [x] request and accept ranges using un-gzipped offsets\r\n - [ ] make sure this client works against fastly-cached text files","created_at":"2015-04-10T04:44:35Z","updated_at":"2015-12-29T03:30:47Z","closed_at":null,"merged_at":null,"merge_commit_sha":"73ce8496357573174e4e358f7b547c198d1ab001","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bundler/bundler/pulls/3556/commits","review_comments_url":"https://api.github.com/repos/bundler/bundler/pulls/3556/comments","review_comment_url":"https://api.github.com/repos/bundler/bundler/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bundler/bundler/issues/3556/comments","statuses_url":"https://api.github.com/repos/bundler/bundler/statuses/d50d6d2cf62fb04e61cdcf453044a16bc053d8a2","head":{"label":"bundler:seg-new-index-fetchers","ref":"seg-new-index-fetchers","sha":"d50d6d2cf62fb04e61cdcf453044a16bc053d8a2","user":{"login":"bundler","id":1137638,"avatar_url":"https://avatars.githubusercontent.com/u/1137638?v=3","gravatar_id":"","url":"https://api.github.com/users/bundler","html_url":"https://github.com/bundler","followers_url":"https://api.github.com/users/bundler/followers","following_url":"https://api.github.com/users/bundler/following{/other_user}","gists_url":"https://api.github.com/users/bundler/gists{/gist_id}","starred_url":"https://api.github.com/users/bundler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bundler/subscriptions","organizations_url":"https://api.github.com/users/bundler/orgs","repos_url":"https://api.github.com/users/bundler/repos","events_url":"https://api.github.com/users/bundler/events{/privacy}","received_events_url":"https://api.github.com/users/bundler/received_events","type":"Organization","site_admin":false},"repo":{"id":488514,"name":"bundler","full_name":"bundler/bundler","owner":{"login":"bundler","id":1137638,"avatar_url":"https://avatars.githubusercontent.com/u/1137638?v=3","gravatar_id":"","url":"https://api.github.com/users/bundler","html_url":"https://github.com/bundler","followers_url":"https://api.github.com/users/bundler/followers","following_url":"https://api.github.com/users/bundler/following{/other_user}","gists_url":"https://api.github.com/users/bundler/gists{/gist_id}","starred_url":"https://api.github.com/users/bundler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bundler/subscriptions","organizations_url":"https://api.github.com/users/bundler/orgs","repos_url":"https://api.github.com/users/bundler/repos","events_url":"https://api.github.com/users/bundler/events{/privacy}","received_events_url":"https://api.github.com/users/bundler/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bundler/bundler","description":"Manage your application's gem dependencies with less pain","fork":false,"url":"https://api.github.com/repos/bundler/bundler","forks_url":"https://api.github.com/repos/bundler/bundler/forks","keys_url":"https://api.github.com/repos/bundler/bundler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bundler/bundler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bundler/bundler/teams","hooks_url":"https://api.github.com/repos/bundler/bundler/hooks","issue_events_url":"https://api.github.com/repos/bundler/bundler/issues/events{/number}","events_url":"https://api.github.com/repos/bundler/bundler/events","assignees_url":"https://api.github.com/repos/bundler/bundler/assignees{/user}","branches_url":"https://api.github.com/repos/bundler/bundler/branches{/branch}","tags_url":"https://api.github.com/repos/bundler/bundler/tags","blobs_url":"https://api.github.com/repos/bundler/bundler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bundler/bundler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bundler/bundler/git/refs{/sha}","trees_url":"https://api.github.com/repos/bundler/bundler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bundler/bundler/statuses/{sha}","languages_url":"https://api.github.com/repos/bundler/bundler/languages","stargazers_url":"https://api.github.com/repos/bundler/bundler/stargazers","contributors_url":"https://api.github.com/repos/bundler/bundler/contributors","subscribers_url":"https://api.github.com/repos/bundler/bundler/subscribers","subscription_url":"https://api.github.com/repos/bundler/bundler/subscription","commits_url":"https://api.github.com/repos/bundler/bundler/commits{/sha}","git_commits_url":"https://api.github.com/repos/bundler/bundler/git/commits{/sha}","comments_url":"https://api.github.com/repos/bundler/bundler/comments{/number}","issue_comment_url":"https://api.github.com/repos/bundler/bundler/issues/comments{/number}","contents_url":"https://api.github.com/repos/bundler/bundler/contents/{+path}","compare_url":"https://api.github.com/repos/bundler/bundler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bundler/bundler/merges","archive_url":"https://api.github.com/repos/bundler/bundler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bundler/bundler/downloads","issues_url":"https://api.github.com/repos/bundler/bundler/issues{/number}","pulls_url":"https://api.github.com/repos/bundler/bundler/pulls{/number}","milestones_url":"https://api.github.com/repos/bundler/bundler/milestones{/number}","notifications_url":"https://api.github.com/repos/bundler/bundler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bundler/bundler/labels{/name}","releases_url":"https://api.github.com/repos/bundler/bundler/releases{/id}","created_at":"2010-01-26T00:46:38Z","updated_at":"2015-12-28T08:57:04Z","pushed_at":"2015-12-28T16:00:29Z","git_url":"git://github.com/bundler/bundler.git","ssh_url":"git@github.com:bundler/bundler.git","clone_url":"https://github.com/bundler/bundler.git","svn_url":"https://github.com/bundler/bundler","homepage":"http://bundler.io","size":24658,"stargazers_count":3166,"watchers_count":3166,"language":"Ruby","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":true,"forks_count":1451,"mirror_url":null,"open_issues_count":81,"forks":1451,"open_issues":81,"watchers":3166,"default_branch":"master"}},"base":{"label":"bundler:master","ref":"master","sha":"e2b14375c3ed2ef679fed1ca894dd346cbcefcf1","user":{"login":"bundler","id":1137638,"avatar_url":"https://avatars.githubusercontent.com/u/1137638?v=3","gravatar_id":"","url":"https://api.github.com/users/bundler","html_url":"https://github.com/bundler","followers_url":"https://api.github.com/users/bundler/followers","following_url":"https://api.github.com/users/bundler/following{/other_user}","gists_url":"https://api.github.com/users/bundler/gists{/gist_id}","starred_url":"https://api.github.com/users/bundler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bundler/subscriptions","organizations_url":"https://api.github.com/users/bundler/orgs","repos_url":"https://api.github.com/users/bundler/repos","events_url":"https://api.github.com/users/bundler/events{/privacy}","received_events_url":"https://api.github.com/users/bundler/received_events","type":"Organization","site_admin":false},"repo":{"id":488514,"name":"bundler","full_name":"bundler/bundler","owner":{"login":"bundler","id":1137638,"avatar_url":"https://avatars.githubusercontent.com/u/1137638?v=3","gravatar_id":"","url":"https://api.github.com/users/bundler","html_url":"https://github.com/bundler","followers_url":"https://api.github.com/users/bundler/followers","following_url":"https://api.github.com/users/bundler/following{/other_user}","gists_url":"https://api.github.com/users/bundler/gists{/gist_id}","starred_url":"https://api.github.com/users/bundler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bundler/subscriptions","organizations_url":"https://api.github.com/users/bundler/orgs","repos_url":"https://api.github.com/users/bundler/repos","events_url":"https://api.github.com/users/bundler/events{/privacy}","received_events_url":"https://api.github.com/users/bundler/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bundler/bundler","description":"Manage your application's gem dependencies with less pain","fork":false,"url":"https://api.github.com/repos/bundler/bundler","forks_url":"https://api.github.com/repos/bundler/bundler/forks","keys_url":"https://api.github.com/repos/bundler/bundler/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bundler/bundler/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bundler/bundler/teams","hooks_url":"https://api.github.com/repos/bundler/bundler/hooks","issue_events_url":"https://api.github.com/repos/bundler/bundler/issues/events{/number}","events_url":"https://api.github.com/repos/bundler/bundler/events","assignees_url":"https://api.github.com/repos/bundler/bundler/assignees{/user}","branches_url":"https://api.github.com/repos/bundler/bundler/branches{/branch}","tags_url":"https://api.github.com/repos/bundler/bundler/tags","blobs_url":"https://api.github.com/repos/bundler/bundler/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bundler/bundler/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bundler/bundler/git/refs{/sha}","trees_url":"https://api.github.com/repos/bundler/bundler/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bundler/bundler/statuses/{sha}","languages_url":"https://api.github.com/repos/bundler/bundler/languages","stargazers_url":"https://api.github.com/repos/bundler/bundler/stargazers","contributors_url":"https://api.github.com/repos/bundler/bundler/contributors","subscribers_url":"https://api.github.com/repos/bundler/bundler/subscribers","subscription_url":"https://api.github.com/repos/bundler/bundler/subscription","commits_url":"https://api.github.com/repos/bundler/bundler/commits{/sha}","git_commits_url":"https://api.github.com/repos/bundler/bundler/git/commits{/sha}","comments_url":"https://api.github.com/repos/bundler/bundler/comments{/number}","issue_comment_url":"https://api.github.com/repos/bundler/bundler/issues/comments{/number}","contents_url":"https://api.github.com/repos/bundler/bundler/contents/{+path}","compare_url":"https://api.github.com/repos/bundler/bundler/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bundler/bundler/merges","archive_url":"https://api.github.com/repos/bundler/bundler/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bundler/bundler/downloads","issues_url":"https://api.github.com/repos/bundler/bundler/issues{/number}","pulls_url":"https://api.github.com/repos/bundler/bundler/pulls{/number}","milestones_url":"https://api.github.com/repos/bundler/bundler/milestones{/number}","notifications_url":"https://api.github.com/repos/bundler/bundler/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bundler/bundler/labels{/name}","releases_url":"https://api.github.com/repos/bundler/bundler/releases{/id}","created_at":"2010-01-26T00:46:38Z","updated_at":"2015-12-28T08:57:04Z","pushed_at":"2015-12-28T16:00:29Z","git_url":"git://github.com/bundler/bundler.git","ssh_url":"git@github.com:bundler/bundler.git","clone_url":"https://github.com/bundler/bundler.git","svn_url":"https://github.com/bundler/bundler","homepage":"http://bundler.io","size":24658,"stargazers_count":3166,"watchers_count":3166,"language":"Ruby","has_issues":true,"has_downloads":false,"has_wiki":false,"has_pages":true,"forks_count":1451,"mirror_url":null,"open_issues_count":81,"forks":1451,"open_issues":81,"watchers":3166,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bundler/bundler/pulls/3556"},"html":{"href":"https://github.com/bundler/bundler/pull/3556"},"issue":{"href":"https://api.github.com/repos/bundler/bundler/issues/3556"},"comments":{"href":"https://api.github.com/repos/bundler/bundler/issues/3556/comments"},"review_comments":{"href":"https://api.github.com/repos/bundler/bundler/pulls/3556/comments"},"review_comment":{"href":"https://api.github.com/repos/bundler/bundler/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bundler/bundler/pulls/3556/commits"},"statuses":{"href":"https://api.github.com/repos/bundler/bundler/statuses/d50d6d2cf62fb04e61cdcf453044a16bc053d8a2"}}}}