Page MenuHomePhabricator

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

Authored by epriestley on Oct 28 2019, 9:35 PM.
Tags
None
Referenced Files
Unknown Object (File)
Tue, Apr 2, 4:09 PM
Unknown Object (File)
Fri, Mar 29, 4:13 PM
Unknown Object (File)
Feb 24 2024, 4:58 PM
Unknown Object (File)
Feb 14 2024, 10:59 PM
Unknown Object (File)
Jan 23 2024, 9:24 AM
Unknown Object (File)
Jan 1 2024, 4:59 PM
Unknown Object (File)
Dec 28 2023, 5:08 PM
Unknown Object (File)
Dec 24 2023, 4:52 PM
Subscribers
Restricted Owners Package

Details

Summary

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 "github.com").
  • Ran this thing:
$ echo '{"remoteURIs": ["ssh://git@local.phacility.com/diffusion/P"]}' | ./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": "http://local.phacility.com/source/phabricator/",
      "remoteURI": "https://github.com/phacility/phabricator.git",
      "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

Repository
rP Phabricator
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

Owners added a subscriber: Restricted Owners Package.Oct 28 2019, 9:35 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.