BREAKING CHANGE: set default git ref to HEAD#142
Conversation
|
One thing we should add to this is the ability to differentiate between directing to files vs directories. This change works great if we only point to directories: curl -sSL -D - https://github.com/npm/cli/tree/latest/lib | grep -e HTTP -e 'location: http'
HTTP/2 200
curl -sSL -D - https://github.com/npm/cli/tree/HEAD/lib | grep -e HTTP -e 'location: http'
HTTP/2 200But if point to files and use curl -sSL -D - https://github.com/npm/cli/tree/latest/lib/npm.js | grep -e HTTP -e 'location: http'
HTTP/2 301
location: https://github.com/npm/cli/blob/latest/lib/npm.js
HTTP/2 200
curl -sSL -D - https://github.com/npm/cli/tree/HEAD/lib/npm.js | grep -e HTTP -e 'location: http'
HTTP/2 301
location: https://github.com/npm/cli/blob/f281ec8a1aec43439281a8fca4c255b0d94a0c94/lib/npm.js
HTTP/2 200But if we use curl -sSL -D - https://github.com/npm/cli/blob/HEAD/lib/npm.js | grep -e HTTP -e 'location: http'
HTTP/2 200What to do?I think we should land another breaking change with this:
|
lukekarrys
left a comment
There was a problem hiding this comment.
Requesting changes in order to discuss my additional proposal.
|
@lukekarrys it should be noted that introducing a blob path does not eliminate redirects. Example: If the ref that is provided does not exist but did at some point (ex. was renamed - which is the case for most curl -sSL -D - https://github.com/npm/cli/blob/master/lib/npm.js | grep -e HTTP -e 'location: http'
HTTP/2 302
location: https://github.com/npm/cli/blob/latest/lib/npm.js
HTTP/2 200Looking into GitLab, it seems as though they use a curl -sSL -D - https://gitlab.com/eBay/ebay/-/tree/HEAD/README.md | grep -e HTTP -e 'location: http'
HTTP/2 302
location: https://gitlab.com/eBay/ebay/-/blob/HEAD/README.md
HTTP/2 200I personally don't think redirects are inherently bad here & introducing a new differentiator for file vs. directory links doesn't change if/when you might get redirected. That said, if you feel strongly it's a better user experience to introduce |
This also adds a `browseFile` method for browsing directly to a blob as separate from a git tree. This is useful for hosts that serve blobs and trees differently. BREAKING CHANGE: `GitHost` now has a static `addHost` method to use instead of manually editing the object from `lib/git-host-info.js`.
69e586d to
314e782
Compare
My goal was not to completely eliminate redirects, but to try and stop redirects that redirect to a different url such as |
Why/What
HEAD(instead of themasterbranch)Links & References
masterbranch cli#4867