1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-12-21 13:00:56 +01:00

Consider identifier types when sorting clone URIs

Summary:
Fixes T11082. Currently, the `/123/` and `/CALLSIGN/` versions of the URI get the same score.

Also the scores are backwards.

Test Plan:
  - Added `getPublicCloneURI()` output to repository listing.
  - Before patch, saw a repository with a callsign list a less-preferred ID-based URI.
  - After patch, saw the repository list the more-preferred callsign-based URI.

Reviewers: chad

Reviewed By: chad

Subscribers: nikolay.metchev

Maniphest Tasks: T11082

Differential Revision: https://secure.phabricator.com/D16008
This commit is contained in:
epriestley 2016-06-02 06:41:12 -07:00
parent ebd8f3c987
commit 24acac117b
2 changed files with 16 additions and 6 deletions

View file

@ -2061,7 +2061,10 @@ final class PhabricatorRepository extends PhabricatorRepositoryDAO
$clone[] = $uri;
}
return msort($clone, 'getURIScore');
$clone = msort($clone, 'getURIScore');
$clone = array_reverse($clone);
return $clone;
}

View file

@ -598,18 +598,25 @@ final class PhabricatorRepositoryURI
$score = 0;
$io_points = array(
self::IO_READWRITE => 20,
self::IO_READ => 10,
self::IO_READWRITE => 200,
self::IO_READ => 100,
);
$score += idx($io_points, $this->getEffectiveIoType(), 0);
$protocol_points = array(
self::BUILTIN_PROTOCOL_SSH => 3,
self::BUILTIN_PROTOCOL_HTTPS => 2,
self::BUILTIN_PROTOCOL_HTTP => 1,
self::BUILTIN_PROTOCOL_SSH => 30,
self::BUILTIN_PROTOCOL_HTTPS => 20,
self::BUILTIN_PROTOCOL_HTTP => 10,
);
$score += idx($protocol_points, $this->getBuiltinProtocol(), 0);
$identifier_points = array(
self::BUILTIN_IDENTIFIER_SHORTNAME => 3,
self::BUILTIN_IDENTIFIER_CALLSIGN => 2,
self::BUILTIN_IDENTIFIER_ID => 1,
);
$score += idx($identifier_points, $this->getBuiltinIdentifier(), 0);
return $score;
}