Page MenuHomePhabricator
Diviner libphutil Tech Docs ArcanistRepositoryURINormalizer

final class ArcanistRepositoryURINormalizer
libphutil Technical Documentation ()

Normalize repository URIs. For example, these URIs are generally equivalent and all point at the same repository:

ssh://user@host/repo
ssh://user@host/repo/
ssh://user@host:22/repo
user@host:/repo
ssh://user@host/repo.git

This class can be used to normalize URIs like this, in order to detect alternate spellings of the same repository URI. In particular, the getNormalizedPath() method will return:

repo

...for all of these URIs. Generally, usage looks like this:

$norm_a = new ArcanistRepositoryURINormalizer($type, $uri_a);
$norm_b = new ArcanistRepositoryURINormalizer($type, $uri_b);

if ($norm_a->getNormalizedPath() === $norm_b->getNormalizedPath()) {
  // URIs appear to point at the same repository.
} else {
  // URIs are very unlikely to be the same repository.
}

Because a repository can be hosted at arbitrarily many arbitrary URIs, there is no way to completely prevent false negatives by only examining URIs (that is, repositories with totally different URIs could really be the same). However, normalization is relatively aggressive and false negatives should be rare: if normalization says two URIs are different repositories, they probably are.

Tasks

Normalizing URIs

Other Methods

Methods

public function __construct($type, $uri)

This method is not documented.
Parameters
$type
$uri
Return
this//Implicit.//

public static function getAllURITypes()

This method is not documented.
Return
wild

public function setDomainMap($domain_map)

This method is not documented.
Parameters
array$domain_map
Return
wild

public function getPath()

This method is not documented.
Return
wild

public function getNormalizedURI()

This method is not documented.
Return
wild

public function getNormalizedPath()

This method is not documented.
Return
wild

public function getNormalizedDomain()

This method is not documented.
Return
wild