Changeset View
Changeset View
Standalone View
Standalone View
src/applications/repository/query/PhabricatorRepositoryQuery.php
Show First 20 Lines • Show All 644 Lines • ▼ Show 20 Lines | protected function buildWhereClauseParts(AphrontDatabaseConnection $conn) { | ||||
if ($this->slugs !== null) { | if ($this->slugs !== null) { | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'r.repositorySlug IN (%Ls)', | 'r.repositorySlug IN (%Ls)', | ||||
$this->slugs); | $this->slugs); | ||||
} | } | ||||
if ($this->uris !== null) { | if ($this->uris !== null) { | ||||
$try_uris = $this->getNormalizedPaths(); | $try_uris = $this->getNormalizedURIs(); | ||||
$try_uris = array_fuse($try_uris); | $try_uris = array_fuse($try_uris); | ||||
$where[] = qsprintf( | $where[] = qsprintf( | ||||
$conn, | $conn, | ||||
'uri.repositoryURI IN (%Ls)', | 'uri.repositoryURI IN (%Ls)', | ||||
$try_uris); | $try_uris); | ||||
} | } | ||||
return $where; | return $where; | ||||
} | } | ||||
public function getQueryApplicationClass() { | public function getQueryApplicationClass() { | ||||
return 'PhabricatorDiffusionApplication'; | return 'PhabricatorDiffusionApplication'; | ||||
} | } | ||||
private function getNormalizedPaths() { | private function getNormalizedURIs() { | ||||
$normalized_uris = array(); | $normalized_uris = array(); | ||||
// Since we don't know which type of repository this URI is in the general | // Since we don't know which type of repository this URI is in the general | ||||
// case, just generate all the normalizations. We could refine this in some | // case, just generate all the normalizations. We could refine this in some | ||||
// cases: if the query specifies VCS types, or the URI is a git-style URI | // cases: if the query specifies VCS types, or the URI is a git-style URI | ||||
// or an `svn+ssh` URI, we could deduce how to normalize it. However, this | // or an `svn+ssh` URI, we could deduce how to normalize it. However, this | ||||
// would be more complicated and it's not clear if it matters in practice. | // would be more complicated and it's not clear if it matters in practice. | ||||
$types = PhabricatorRepositoryURINormalizer::getAllURITypes(); | |||||
foreach ($this->uris as $uri) { | foreach ($this->uris as $uri) { | ||||
$normalized_uris[] = new PhabricatorRepositoryURINormalizer( | foreach ($types as $type) { | ||||
PhabricatorRepositoryURINormalizer::TYPE_GIT, | $normalized_uri = new PhabricatorRepositoryURINormalizer($type, $uri); | ||||
$uri); | $normalized_uris[] = $normalized_uri->getNormalizedURI(); | ||||
$normalized_uris[] = new PhabricatorRepositoryURINormalizer( | } | ||||
PhabricatorRepositoryURINormalizer::TYPE_SVN, | |||||
$uri); | |||||
$normalized_uris[] = new PhabricatorRepositoryURINormalizer( | |||||
PhabricatorRepositoryURINormalizer::TYPE_MERCURIAL, | |||||
$uri); | |||||
} | } | ||||
return array_unique(mpull($normalized_uris, 'getNormalizedPath')); | return array_unique($normalized_uris); | ||||
} | } | ||||
} | } |