Page MenuHomePhabricator

In the repository URI index, store Phabricator's own URIs as tokens

Authored by epriestley on Oct 28 2019, 9:35 PM.



Fixes T13435. If you move Phabricator or copy data from one environment to another, the repository URI index currently still references the old URI, since it writes the URI as a plain string. This may make "arc which" and similar workflows have difficulty identifying repositories.

Instead, store the "phabricator.base-uri" domain and the "diffusion.ssh-host" domain as tokens, so lookups continue to work correctly even after these values change.

Test Plan
  • Added unit tests to cover the normalization.
  • Ran migration, ran daemons, inspected repository_uriindex table, saw a mixture of sensible tokens (for local domains) and static domains (like "").
  • Ran this thing:
$ echo '{"remoteURIs": ["ssh://"]}' | ./bin/conduit call --method repository.query --trace --input -
Reading input from stdin...
>>> [2] (+0) <conduit> repository.query()
>>> [3] (+3) <connect> local_repository
<<< [3] (+3) <connect> 555 us
>>> [4] (+5) <query> SELECT `r`.* FROM `repository` `r` LEFT JOIN `local_repository`.`repository_uriindex` uri ON r.phid = uri.repositoryPHID WHERE (uri.repositoryURI IN ('<base-uri>/diffusion/P')) GROUP BY `r`.phid ORDER BY `r`.`id` DESC LIMIT 101
<<< [4] (+5) <query> 596 us
<<< [2] (+6) <conduit> 6,108 us
  "result": [
      "id": "1",
      "name": "Phabricator",
      "phid": "PHID-REPO-2psrynlauicce7d3q7g2",
      "callsign": "P",
      "monogram": "rP",
      "vcs": "git",
      "uri": "",
      "remoteURI": "",
      "description": "asdf",
      "isActive": true,
      "isHosted": false,
      "isImporting": false,
      "encoding": "UTF-8",
      "staging": {
        "supported": true,
        "prefix": "phabricator",
        "uri": null

Note the WHERE clause in the query normalizes the URI into "<base-uri>", and the lookup succeeds.

Diff Detail

rP Phabricator
Automatic diff as part of commit; lint not applicable.
Automatic diff as part of commit; unit tests not applicable.

Event Timeline

epriestley created this revision.Oct 28 2019, 9:35 PM
Owners added a subscriber: Restricted Owners Package.Oct 28 2019, 9:35 PM
epriestley requested review of this revision.Oct 28 2019, 9:37 PM
This revision was not accepted when it landed; it landed in state Needs Review.Oct 28 2019, 9:44 PM
This revision was automatically updated to reflect the committed changes.