jupyterhub / binderhub

Run your code in the cloud, with technology so advanced, it feels like magic!
https://binderhub.readthedocs.io
BSD 3-Clause "New" or "Revised" License
2.54k stars 388 forks source link

Long-term fix for deleted default branches #1570

Closed minrk closed 1 year ago

minrk commented 1 year ago

Proposed change

Redirect builds where unresolved_ref=master and that ref doesn't resolve to the same spec with unresolved_ref=HEAD.

As discussed in #1145 (cc @bryevdv), there are likely a lot of old links that can't easily be updated after a default branch rename. We've fixed this for new default URLs in #1186, but not in a way that keeps old links working.

Alternative options

Let old links break.

Who would use this feature?

Anyone with old Binder links in documentation, across the web who has renamed their default branch in the past few years, prior to the adoption of 'HEAD' as the default ref. We know folks are keeping an unused 'master' branch up-to-date just to avoid breaking links. This would allow them to stop doing that.

(Optional): Suggest a solution

Two possible solutions:

  1. (better, IMO, but more complex): I think the 'right' behavior would be for master builds to redirect the browser to HEAD, rather that keeping the resolution of dead links behind the scenes. That's a little tricky, since the resolution occurs in the event stream, not in the regular page handler, and event streams can't redirect in the middle. So we'd actually need to do the redirect in javascript on the page in response to a new event type.

  2. Retrying with unresolved_ref=HEAD within the event stream handler would be a lot simpler to implement, but would keep broken links canonically working instead of redirecting. But since it's not a 'true' redirect (page load succeeds before the redirect is discovered), there's little difference, I think.