@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Add "short name", "id", and "phid" variables for external editor URIs

Summary: Ref T13515. External editor URIs currently depend on repositories having callsigns, but callsigns are no longer required. Add some variables to support configuring this feature for repositories that do not have callsigns.

Test Plan: Changed settings to use new variables, saw links generate appropriately.

Maniphest Tasks: T13515

Differential Revision: https://secure.phabricator.com/D21147

+72 -23
+2 -2
src/applications/settings/setting/PhabricatorEditorSetting.php
··· 26 26 "\n\n". 27 27 "Provide a URI pattern for building external editor URIs in your ". 28 28 "environment. For example, if you use TextMate on macOS, the pattern ". 29 - "for your machine look like this:". 29 + "for your machine may look something like this:". 30 30 "\n\n". 31 31 "```name=\"Example: TextMate on macOS\"\n". 32 32 "%s\n". ··· 36 36 "see **[[ %s | %s ]]**.". 37 37 "\n\n". 38 38 "See the tables below for a list of supported variables and protocols.", 39 - 'txmt://open/?url=file:///Users/alincoln/editor_links/%r/%f&line=%l', 39 + 'txmt://open/?url=file:///Users/alincoln/editor_links/%n/%f&line=%l', 40 40 PhabricatorEnv::getDoclink('User Guide: Configuring an External Editor'), 41 41 pht('User Guide: Configuring an External Editor')); 42 42 }
+47 -13
src/docs/user/userguide/external_editor.diviner
··· 6 6 Overview 7 7 ======== 8 8 9 - You can configure a URI handler to allow you to open files from Differential 10 - and Diffusion in your preferred text editor. 9 + You can configure a URI handler to allow you to open files referenced in 10 + Differential and Diffusion in your preferred text editor on your local 11 + machine. 12 + 11 13 12 14 Configuring Editors 13 15 =================== ··· 17 19 will enable an "Open in Editor" link in Differential, and an "Edit" button in 18 20 Diffusion. 19 21 20 - In general, you'll set this field to something like: 22 + In general, you'll set this field to something like this, although the 23 + particular pattern to use depends on your editor and environment: 21 24 22 25 ```lang=uri 23 26 editor://open/?file=%f 24 27 ``` 25 28 29 + 30 + Mapping Repositories 31 + ==================== 32 + 33 + When you open a file in an external editor, Phabricator needs to be able to 34 + build a URI which includes the correct absolute path on disk to the local 35 + version of the file, including the repository directory. 36 + 37 + If all your repositories are named consistently in a single directory, you 38 + may be able to use the `%n` (repository short name) variable to do this. 39 + For example: 40 + 41 + ```lang=uri 42 + editor://open/?file=/Users/alice/repositories/%n/%f 43 + ``` 44 + 45 + If your repositories aren't named consistently or aren't in a single location, 46 + you can build a local directory of symlinks which map a repositoriy identifier 47 + to the right location on disk: 48 + 49 + ``` 50 + /Users/alice/editor_links/ $ ls -l 51 + ... search-service/ -> /Users/alice/backend/search/ 52 + ... site-templates/ -> /Users/alice/frontend/site/ 53 + ``` 54 + 55 + Then use this directory in your editor URI: 56 + 57 + ```lang=uri 58 + editor://open/?file=/Users/alice/editor_links/%n/%f 59 + ``` 60 + 61 + Instead of `%n` (repository short name), you can also use `%d` (repository ID) 62 + or `%p` (repository PHID). These identifiers are immutable and all repositories 63 + always have both identifiers, but they're less human-readable. 64 + 65 + 26 66 Configuring: TextMate on macOS 27 67 ============================== 28 68 29 69 TextMate installs a `txmt://` handler by default, so it's easy to configure 30 70 this feature if you use TextMate. 31 71 32 - First, create a local directory with symlinks for each repository callsign. For 33 - example, if you're developing Phabricator, it might look like this: 34 - 35 - /Users/alincoln/editor_links/ $ ls -l 36 - ... ARC -> /Users/alincoln/workspace/arcanist/ 37 - ... P -> /Users/alincoln/workspace/phabricator/ 38 - ... PHU -> /Users/alincoln/workspace/libphutil/ 39 - 40 - Then set your "Editor Link" to: 72 + First, identify the parent directory where your repositories are stored 73 + (for example, `/Users/alice/repositories/`). Then, configure your editor 74 + pattern like this: 41 75 42 76 ```lang=uri 43 - txmt://open/?url=file:///Users/alincoln/editor_links/%r/%f&line=%l 77 + txmt://open/?url=file:///Users/alice/repositories/%n/%f&line=%l 44 78 ```
+23 -8
src/infrastructure/editor/PhabricatorEditorURIEngine.php
··· 90 90 91 91 public static function getVariableDefinitions() { 92 92 return array( 93 - '%' => array( 94 - 'name' => pht('Literal Percent Symbol'), 95 - 'example' => '%', 96 - ), 97 - 'r' => array( 98 - 'name' => pht('Repository Callsign'), 99 - 'example' => 'XYZ', 100 - ), 101 93 'f' => array( 102 94 'name' => pht('File Name'), 103 95 'example' => pht('path/to/source.c'), ··· 106 98 'name' => pht('Line Number'), 107 99 'example' => '777', 108 100 ), 101 + 'n' => array( 102 + 'name' => pht('Repository Short Name'), 103 + 'example' => 'arcanist', 104 + ), 105 + 'd' => array( 106 + 'name' => pht('Repository ID'), 107 + 'example' => '42', 108 + ), 109 + 'p' => array( 110 + 'name' => pht('Repository PHID'), 111 + 'example' => 'PHID-REPO-abcdefghijklmnopqrst', 112 + ), 113 + 'r' => array( 114 + 'name' => pht('Repository Callsign'), 115 + 'example' => 'XYZ', 116 + ), 117 + '%' => array( 118 + 'name' => pht('Literal Percent Symbol'), 119 + 'example' => '%', 120 + ), 109 121 ); 110 122 } 111 123 ··· 119 131 120 132 $variables = array( 121 133 'r' => $this->escapeToken($repository->getCallsign()), 134 + 'n' => $this->escapeToken($repository->getRepositorySlug()), 135 + 'd' => $this->escapeToken($repository->getID()), 136 + 'p' => $this->escapeToken($repository->getPHID()), 122 137 ); 123 138 124 139 return $this->newTokensWithVariables($tokens, $variables);