@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
at upstream/main 182 lines 4.5 kB view raw
1@title Diffusion User Guide: Repositories API 2@group userguide 3 4Managing repositories with the API. 5 6Overview 7======== 8 9You can create and update Diffusion repositories using the Conduit API. This 10may be useful if you have a large number of existing repositories you want 11to import or apply bulk actions to. 12 13For an introduction to Conduit, see @{article:Conduit API Overview}. 14 15In general, you'll use these API methods: 16 17 - `diffusion.repository.edit`: Create and edit repositories. 18 - `diffusion.uri.edit`: Create and edit repository URIs to configure 19 observation, mirroring, and cloning. 20 21To create a repository, you'll generally do this: 22 23 - Call `diffusion.repository.edit` to create a new object and configure 24 basic information. 25 - Optionally, call `diffusion.uri.edit` to add URIs to observe or mirror. 26 - Call `diffusion.repository.edit` to activate the repository. 27 28This workflow mirrors the workflow from the web UI. The remainder of this 29document walks through this workflow in greater detail. 30 31 32Create a Repository 33=================== 34 35To create a repository, call `diffusion.repository.edit`, providing any 36properties you want to set. For simplicity these examples will use the 37builtin `arc call-conduit` client, but you can use whatever Conduit client 38you prefer. 39 40When creating a repository, you must provide a `vcs` transaction to choose 41a repository type, one of: `git`, `hg` or `svn`. 42 43You must also provide a `name`. 44 45Other properties are optional. Review the Conduit method documentation from the 46web UI for an exhaustive list. 47 48``` 49$ echo '{ 50 "transactions": [ 51 { 52 "type": "vcs", 53 "value": "git" 54 }, 55 { 56 "type": "name", 57 "value": "Poetry" 58 } 59 ] 60}' | arc call-conduit diffusion.repository.edit -- 61``` 62 63If things work, you should get a result that looks something like this: 64 65```lang=json 66{ 67 ... 68 "response": { 69 "object": { 70 "id": 1, 71 "phid": "PHID-REPO-7vm42oayez2rxcmpwhuv" 72 }, 73 ... 74 } 75 ... 76} 77``` 78 79If so, your new repository has been created. It hasn't been activated yet so 80it will not show up in the default repository list, but you can find it in the 81web UI by browsing to {nav Diffusion > All Repositories}. 82 83Continue to the next step to configure URIs. 84 85 86Configure URIs 87============== 88 89Now that the repository exists, you can add URIs to it. This is optional, 90and if you're creating a //hosted// repository you may be able to skip this 91step. 92 93However, if you want Phorge to observe an existing remote, you'll 94configure it here by adding a URI in "Observe" mode. Use the PHID from the 95previous step to identify the repository you want to add a URI to, and call 96`diffusion.uri.edit` to create a new URI in Observe mode for the repository. 97 98You need to provide a `repository` to add the URI to, and the `uri` itself. 99 100To add the URI in Observe mode, provide an `io` transaction selecting 101`observe` mode. 102 103You may also want to provide a `credential`. 104 105``` 106$ echo '{ 107 "transactions": [ 108 { 109 "type": "repository", 110 "value": "PHID-REPO-7vm42oayez2rxcmpwhuv" 111 }, 112 { 113 "type": "uri", 114 "value": "https://github.com/epriestley/poems.git" 115 }, 116 { 117 "type": "io", 118 "value": "observe" 119 } 120 ] 121}' | arc call-conduit diffusion.uri.edit -- 122``` 123 124You should get a response that looks something like this: 125 126```lang=json 127{ 128 ... 129 "response": { 130 "object": { 131 "id": 1, 132 "phid": "PHID-RURI-zwtho5o7h3m6rjzgsgrh" 133 }, 134 ... 135 } 136 ... 137} 138``` 139 140If so, your URI has been created. You can review it in the web UI, under 141{nav Manage Repository > URIs}. 142 143When satisfied, continue to the next step to activate the repository. 144 145 146Activate the Repository 147======================= 148 149Now that any URIs have been configured, activate the repository with another 150call to `diffusion.repository.edit`. This time, modify the existing repository 151instead of creating a new one: 152 153``` 154$ echo '{ 155 "objectIdentifier": "PHID-REPO-7vm42oayez2rxcmpwhuv", 156 "transactions": [ 157 { 158 "type": "status", 159 "value": "active" 160 } 161 ] 162}' | arc call-conduit diffusion.repository.edit 163``` 164 165If that goes through cleanly, you should be all set. You can review the 166repository from the web UI. 167 168 169Editing Repositories 170==================== 171 172To edit an existing repository, apply changes normally with 173`diffusion.repository.edit`. For more details on using edit endpoints, see 174@{article:Conduit API: Using Edit Endpoints}. 175 176 177Next Steps 178========== 179 180Continue by: 181 182 - returning to the @{article:Diffusion User Guide}.