@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.)
hq.recaptime.dev/wiki/Phorge
phorge
phabricator
1<?php
2
3final class DiffusionRepositoryDefaultController extends DiffusionController {
4
5 public function shouldAllowPublic() {
6 // NOTE: We allow public access to this controller because it handles
7 // redirecting paths that are missing a trailing "/". We need to manually
8 // redirect these instead of relying on the automatic redirect because
9 // some VCS requests may omit the slashes. See T12035, and below, for some
10 // discussion.
11 return true;
12 }
13
14 public function handleRequest(AphrontRequest $request) {
15 $response = $this->loadDiffusionContext();
16 if ($response) {
17 return $response;
18 }
19
20 // NOTE: This controller is just here to make sure we call
21 // willBeginExecution() on any /diffusion/X/ URI, so we can intercept
22 // `git`, `hg` and `svn` HTTP protocol requests.
23
24 // If we made it here, it's probably because the user copy-pasted a
25 // clone URI with "/anything.git" at the end into their web browser.
26 // Send them to the canonical repository URI.
27
28 $drequest = $this->getDiffusionRequest();
29 $repository = $drequest->getRepository();
30
31 return id(new AphrontRedirectResponse())
32 ->setURI($repository->getURI());
33 }
34}