-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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 200 But 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 200 But if we use curl -sSL -D - https://github.com/npm/cli/blob/HEAD/lib/npm.js | grep -e HTTP -e 'location: http'
HTTP/2 200 What to do?I think we should land another breaking change with this:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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 200 ref. https://github.com/npm/cli/blob/master/lib/npm.js Looking 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 200 I 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 themaster
branch)Links & References
master
branch cli#4867