@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
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve error messages for running `git clone` against a Mercurial repository

Summary:
Fixes T11938.

Note that there's a subcase here: if you `hg clone` or `svn checkout` a short `/source/` URI that ends in `.git`, we miss the lookup and don't get this far, so you still get a generic error message.

Hopefully it is clear enough on its own that `proto://.../blah.git` is, in fact, a Git repository, since it says ".git" at the end.

If that doesn't prove to be true, we can be more surgical about this.

Test Plan:
```
$ git clone ssh://local@localvault.phacility.com/source/quack.notgit/
Cloning into 'quack.notgit'...
phabricator-ssh-exec: This repository ("quack.notgit") is not a Git repository. Use "hg" to interact with this repository.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
```

```
$ hg clone ssh://local@localvault.phacility.com/source/phabx
remote: phabricator-ssh-exec: This repository ("phabx") is not a Mercurial repository. Use "git" to interact with this repository.
abort: no suitable response from remote hg!
```

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T11938

Differential Revision: https://secure.phabricator.com/D16976

+36
+10
src/applications/diffusion/ssh/DiffusionGitSSHWorkflow.php
··· 35 35 } 36 36 } 37 37 38 + protected function raiseWrongVCSException( 39 + PhabricatorRepository $repository) { 40 + throw new Exception( 41 + pht( 42 + 'This repository ("%s") is not a Git repository. Use "%s" to '. 43 + 'interact with this repository.', 44 + $repository->getDisplayName(), 45 + $repository->getVersionControlSystem())); 46 + } 47 + 38 48 }
+10
src/applications/diffusion/ssh/DiffusionMercurialServeSSHWorkflow.php
··· 119 119 return $raw_message; 120 120 } 121 121 122 + protected function raiseWrongVCSException( 123 + PhabricatorRepository $repository) { 124 + throw new Exception( 125 + pht( 126 + 'This repository ("%s") is not a Mercurial repository. Use "%s" to '. 127 + 'interact with this repository.', 128 + $repository->getDisplayName(), 129 + $repository->getVersionControlSystem())); 130 + } 131 + 122 132 }
+6
src/applications/diffusion/ssh/DiffusionSSHWorkflow.php
··· 43 43 */ 44 44 abstract protected function identifyRepository(); 45 45 abstract protected function executeRepositoryOperations(); 46 + abstract protected function raiseWrongVCSException( 47 + PhabricatorRepository $repository); 46 48 47 49 protected function getBaseRequestPath() { 48 50 return $this->baseRequestPath; ··· 197 199 pht( 198 200 'This repository ("%s") is not available over SSH.', 199 201 $repository->getDisplayName())); 202 + } 203 + 204 + if ($repository->getVersionControlSystem() != $vcs) { 205 + $this->raiseWrongVCSException($repository); 200 206 } 201 207 202 208 return $repository;
+10
src/applications/diffusion/ssh/DiffusionSubversionServeSSHWorkflow.php
··· 449 449 return $path; 450 450 } 451 451 452 + protected function raiseWrongVCSException( 453 + PhabricatorRepository $repository) { 454 + throw new Exception( 455 + pht( 456 + 'This repository ("%s") is not a Subversion repository. Use "%s" to '. 457 + 'interact with this repository.', 458 + $repository->getDisplayName(), 459 + $repository->getVersionControlSystem())); 460 + } 461 + 452 462 }