Swap Repository Edit UI to new code

Summary:
Ref T10748. This needs more extensive testing and is sure to have some rough edges, but seems to basically work so far.

Throwing this up so I can work through it more deliberately and make notes.

Test Plan:
- Ran migration.
- Used `bin/repository list` to list existing repositories.
- Used `bin/repository update <repository>` to update various repositories.
- Updated a migrated, hosted Git repository.
- Updated a migrated, observed Git repository.
- Converted an observed repository into a hosted repository by toggling the I/O mode of the URI.
- Conveted a hosted repository into an observed repository by toggling it back.
- Created and activated a new empty hosted Git repository.
- Created and activated an observed Git repository.
- Updated a mirrored repository.
- Cloned and pushed over HTTP.
- Tried to HTTP push a read-only repository.
- Cloned and pushed over SSH.
- Tried to SSH push a read-only repository.
- Updated several Mercurial repositories.
- Updated several Subversion repositories.
- Created and edited repositories via the API.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10748

Differential Revision: https://secure.phabricator.com/D15842
This commit is contained in:
epriestley
2016-05-03 14:26:09 -07:00
parent 42eaa88f80
commit 29d1115037
27 changed files with 328 additions and 3897 deletions

View File

@@ -219,6 +219,7 @@ final class DiffusionServeController extends DiffusionController {
$repository = id(new PhabricatorRepositoryQuery())
->setViewer($viewer)
->withIdentifiers(array($identifier))
->needURIs(true)
->executeOne();
if (!$repository) {
return new PhabricatorVCSResponse(
@@ -266,22 +267,25 @@ final class DiffusionServeController extends DiffusionController {
// token from SSH. If they're using HTTP username + password auth, they
// have to obey the normal HTTP rules.
} else {
switch ($repository->getServeOverHTTP()) {
case PhabricatorRepository::SERVE_READONLY:
if ($is_push) {
return new PhabricatorVCSResponse(
403,
pht('This repository is read-only over HTTP.'));
}
break;
case PhabricatorRepository::SERVE_READWRITE:
// We'll check for push capability below.
break;
case PhabricatorRepository::SERVE_OFF:
default:
if ($request->isHTTPS()) {
$protocol = PhabricatorRepositoryURI::BUILTIN_PROTOCOL_HTTPS;
} else {
$protocol = PhabricatorRepositoryURI::BUILTIN_PROTOCOL_HTTP;
}
if (!$repository->canServeProtocol($protocol, false)) {
return new PhabricatorVCSResponse(
403,
pht('This repository is not available over HTTP.'));
}
if ($is_push) {
$can_write = $repository->canServeProtocol($protocol, true);
if (!$can_write) {
return new PhabricatorVCSResponse(
403,
pht('This repository is not available over HTTP.'));
pht('This repository is read-only over HTTP.'));
}
}
}