{"action":"created","issue":{"url":"https://api.github.com/repos/bower/bower/issues/1628","labels_url":"https://api.github.com/repos/bower/bower/issues/1628/labels{/name}","comments_url":"https://api.github.com/repos/bower/bower/issues/1628/comments","events_url":"https://api.github.com/repos/bower/bower/issues/1628/events","html_url":"https://github.com/bower/bower/pull/1628","id":51971052,"number":1628,"title":"Automatically detecting smart Git hosts","user":{"login":"nwinkler","id":907063,"avatar_url":"https://avatars.githubusercontent.com/u/907063?v=3","gravatar_id":"","url":"https://api.github.com/users/nwinkler","html_url":"https://github.com/nwinkler","followers_url":"https://api.github.com/users/nwinkler/followers","following_url":"https://api.github.com/users/nwinkler/following{/other_user}","gists_url":"https://api.github.com/users/nwinkler/gists{/gist_id}","starred_url":"https://api.github.com/users/nwinkler/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nwinkler/subscriptions","organizations_url":"https://api.github.com/users/nwinkler/orgs","repos_url":"https://api.github.com/users/nwinkler/repos","events_url":"https://api.github.com/users/nwinkler/events{/privacy}","received_events_url":"https://api.github.com/users/nwinkler/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/bower/bower/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":9,"created_at":"2014-12-15T10:38:42Z","updated_at":"2015-03-23T15:59:02Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/bower/bower/pulls/1628","html_url":"https://github.com/bower/bower/pull/1628","diff_url":"https://github.com/bower/bower/pull/1628.diff","patch_url":"https://github.com/bower/bower/pull/1628.patch"},"body":"Added logic to automatically detect smart Git hosts that allow shallow cloning. This is done by sending an `ls-remote` request to the server and then evaluating the returned HTTP header fields. For this, Curl\r\nverbose logging is enabled for the `ls-remote` request, since Curl verbose logging sends the returned HTTP headers to `stderr`.\r\n\r\nIf the `stderr` output contains the desired header\r\n\r\n    Content-Type: application/x-git-upload-pack-advertisement\r\n\r\nthen the server supports shallow cloning.\r\n\r\nThis approach uses Git and Curl for the heavy lifting. Instead of implementing the request to the server using a simple HTTP client, Git is used, since it takes care of authentication using stored credentials.\r\n\r\nThe used approach should also work for BitBucket, which only sends the Content-Type header when a specific user agent is used. Using Git to make the request enables this behavior.\r\n\r\nThe function to detect the smart Git host (`GitRemoteResolver.prototype._supportsShallowCloning`) returns a promise that is resolved when the server's request is evaluated. The promise handling required an addition to `GitHubResolver.js` - to always resolve the promise to `true`, since GitHub supports shallow cloning.\r\n\r\nThis should fix the issues #1558, #1559 and #1568 - and provide a better solution than #1393, which disabled shallow cloning for everyone.\r\n\r\nI don't have an instance of GitHub Enterprise that I could test this with - but I'm pretty confident that it is working. It would be great if someone with access to a GitHub Enterprise instance could verify this.\r\n\r\nIf you run Bower with `-V` (for verbose logging), you should see a message indicating whether the host in question (for non-GitHub hosts) supports shallow cloning, i.e. is a  _smart_ host.\r\n\r\nThe code could be optimized to cache information about the hosts - I haven't added this yet since I wanted to get feedback on whether the approach I've taken is sensible/acceptable."},"comment":{"url":"https://api.github.com/repos/bower/bower/issues/comments/85064998","html_url":"https://github.com/bower/bower/pull/1628#issuecomment-85064998","issue_url":"https://api.github.com/repos/bower/bower/issues/1628","id":85064998,"user":{"login":"sheerun","id":292365,"avatar_url":"https://avatars.githubusercontent.com/u/292365?v=3","gravatar_id":"","url":"https://api.github.com/users/sheerun","html_url":"https://github.com/sheerun","followers_url":"https://api.github.com/users/sheerun/followers","following_url":"https://api.github.com/users/sheerun/following{/other_user}","gists_url":"https://api.github.com/users/sheerun/gists{/gist_id}","starred_url":"https://api.github.com/users/sheerun/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sheerun/subscriptions","organizations_url":"https://api.github.com/users/sheerun/orgs","repos_url":"https://api.github.com/users/sheerun/repos","events_url":"https://api.github.com/users/sheerun/events{/privacy}","received_events_url":"https://api.github.com/users/sheerun/received_events","type":"User","site_admin":false},"created_at":"2015-03-23T15:59:02Z","updated_at":"2015-03-23T15:59:02Z","body":"@nwinkler After I rebase it on master, the tests are failing :( Could you look at it?"}}