Skip to content

Where people and agents ship software together. The open-source git platform for the whole job: issues, agents, checks and deploys to the edge.

g1t.sh

Commit

Merge branch 'rm-mirroring'

# Conflicts: # apps/docs/src/content/docs/guides/projects.md # apps/web/app/components/shell.tsx # apps/web/app/lib/checklist.ts # apps/web/app/routes/repo/overview.tsx

syntaqxcommitted Parents4d0236b8e9f25cBrowse files
136 files+25−907120 files not counted0/136 viewed
+1−1
7777 | Packages: npm, Cargo, Composer, Maven, NuGet, RubyGems, Go modules, container images | Live |
7878 | Secret push protection, history scanning, dependency upgrade pull requests | Live |
7979 | A preview of every pull request on `g1t.page`, production on merge, custom domains | Live |
80−| GitHub import, mirroring and pushing back | Live |
80+| GitHub import: every branch and tag, and issues | Live |
8181 | A copy of the data for every preview, instant rollback, container apps kept warm | Coming |
8282 | Git over SSH (waits on inbound TCP on Workers; use HTTPS) | Coming |
8383
+0−1
1919 mod deploy_keys;
2020 mod limits;
2121 mod logs;
22−mod mirrors;
2322 mod mcp;
2423 mod notifications;
2524 mod oauth;
+0−376
1−//! Mirroring over REST and MCP: a repository's links to copies of it on
2−//! other hosts (see `g1t_contracts::mirrors`), at
3−//! `/repos/{owner}/{name}/mirror…`, and as the MCP `mirror` tool.
4−//!
5−//! The integrations service keeps the links and decides who may change
6−//! them: the Admin role on the repository; syncing needs push. Agents never
7−//! move a repository to g1t or handle a remote's token.
8−
9−use g1t_contracts::mirrors::{
10− MirrorActArgs, MirrorAddArgs, MirrorCiArgs, MirrorHandBackArgs, MirrorMoveInArgs, MirrorRemoveArgs, MirrorSettings,
11− MirrorSettingsArgs, MirrorViewArgs, RefDecision, RemoteProvider, RemoteRole,
12−};
13−use g1t_contracts::repos::{GetArgs, Repo};
14−use g1t_contracts::{FailureCode, Outcome, Viewer};
15−use serde_json::{Value, json};
16−use std::collections::BTreeMap;
17−use worker::Result;
18−
19−use crate::operations::{Services, repo_path};
20−
21−/// One operation on a repository's mirroring.
22−#[derive(Clone, Copy, Debug, PartialEq, Eq)]
23−pub enum MirrorsOp {
24− GetMirror,
25− GetHandBackPlan,
26− TakeOver,
27− SetCiFailover,
28− HandBack,
29− MoveToG1t,
30− SyncMirror,
31− AddRemote,
32− UpdateRemote,
33− RemoveRemote,
34−}
35−
36−impl MirrorsOp {
37− /// Every one: `Op::ALL` lists each as `Op::Mirrors(…)`, which a test
38− /// checks against this.
39− #[cfg(test)]
40− pub const ALL: [MirrorsOp; 10] = [
41− MirrorsOp::GetMirror,
42− MirrorsOp::GetHandBackPlan,
43− MirrorsOp::TakeOver,
44− MirrorsOp::SetCiFailover,
45− MirrorsOp::HandBack,
46− MirrorsOp::MoveToG1t,
47− MirrorsOp::SyncMirror,
48− MirrorsOp::AddRemote,
49− MirrorsOp::UpdateRemote,
50− MirrorsOp::RemoveRemote,
51− ];
52−
53− pub fn name(self) -> &'static str {
54− match self {
55− MirrorsOp::GetMirror => "get_mirror",
56− MirrorsOp::GetHandBackPlan => "get_hand_back_plan",
57− MirrorsOp::TakeOver => "take_over_mirror",
58− MirrorsOp::SetCiFailover => "set_ci_failover",
59− MirrorsOp::HandBack => "hand_back_mirror",
60− MirrorsOp::MoveToG1t => "move_mirror_to_g1t",
61− MirrorsOp::SyncMirror => "sync_mirror",
62− MirrorsOp::AddRemote => "add_mirror_remote",
63− MirrorsOp::UpdateRemote => "update_mirror_remote",
64− MirrorsOp::RemoveRemote => "remove_mirror_remote",
65− }
66− }
67−
68− /// For the API reference.
69− pub fn title(self) -> &'static str {
70− match self {
71− MirrorsOp::GetMirror => "Get a repository's mirroring",
72− MirrorsOp::GetHandBackPlan => "Get the hand-back plan",
73− MirrorsOp::TakeOver => "Take over a mirror",
74− MirrorsOp::SetCiFailover => "Start or end CI failover",
75− MirrorsOp::HandBack => "Hand a takeover back",
76− MirrorsOp::MoveToG1t => "Move a mirror to g1t",
77− MirrorsOp::SyncMirror => "Sync a repository's remotes",
78− MirrorsOp::AddRemote => "Add a remote",
79− MirrorsOp::UpdateRemote => "Update a remote's settings",
80− MirrorsOp::RemoveRemote => "Remove a remote",
81− }
82− }
83−
84− pub fn description(self) -> &'static str {
85− match self {
86− MirrorsOp::GetMirror => "A repository's links to other hosts. `remotes` lists each with its `role` (`leader`: the remote leads and this repository is its mirror; `follower`: g1t leads and the remote is kept in step), `provider` (`github`, `g1t` or `git`), `name` (`github.com/acme/web`), `state` (a mirror is `standby`, `ci`, `takeover` or `handing_back`; a follower is `following` or `stuck`), `reachable` and `unreachable_since`, `synced_at`, `last_error`, `checks_problem` (why g1t could not report checks to the remote, such as the GitHub App lacking the Commit statuses permission; null once a report goes through) and its `settings`. `can_manage` says whether you may change them. A mirror standing by is read-only on g1t and runs nothing. Needs read access.",
87− MirrorsOp::GetHandBackPlan => "What handing a takeover back would do, ref by ref, in `plan.refs`: each with `base` (where it was when the takeover began), `ours`, `theirs` and `action`: `push` (only g1t moved), `fetch` (only the remote moved), `pull_request` (the remote protects the branch: g1t's commits go to `g1t/handback/<branch>` there as a pull request, and g1t follows the remote's branch) or `diverged` (both moved: it needs a decision). `plan.reachable` is false while the remote does not answer; `plan.ready` once it answers and every diverged ref has a decision. Asks the remote, so it takes a moment. Needs the Admin role.",
88− MirrorsOp::TakeOver => "Take over a mirror: g1t leads it for now, so pushes, pull requests, issues, agents and workflows work on g1t, whether or not the remote is answering. Each ref's commit is recorded as where the takeover began. Workflows that deploy wait for approval, unless the link's settings say otherwise. End it with hand_back_mirror, or keep it with move_mirror_to_g1t. Needs the Admin role.",
89− MirrorsOp::SetCiFailover => "Start (`on: true`) or end (`on: false`) CI failover on a mirror standing by: the remote keeps the code, and g1t runs its workflows, `.github/workflows` as well as `.g1t/workflows`, on each push copied in. Workflows that deploy wait for approval unless the link's settings say otherwise. Needs the Admin role.",
90− MirrorsOp::HandBack => "Hand a takeover back to the remote, as get_hand_back_plan describes, with `decisions` for diverged refs: an object from ref (`refs/heads/docs`) to `keep_ours` (g1t's commit is pushed over the remote's), `keep_theirs` (the remote's is taken; g1t's is kept under `refs/g1t/replaced/`) or `pull_request`. Refused while the remote does not answer or a diverged ref has no decision. The repository is read-only while it goes back; if anything is refused, g1t keeps the lead and says why. On success the mirror stands by again, and `notes` lists the pull requests opened. Needs the Admin role.",
91− MirrorsOp::MoveToG1t => "Move a mirror to g1t for good: it stops being a mirror and g1t no longer tracks the remote, so pushes made there no longer come here. Allowed while it stands by, in CI failover, or during a takeover, whose work stays as it is. With `keep_remote_updated: true` the remote becomes a follower instead of being unlinked, and g1t pushes to it from then on. Needs the Admin role; agents' tokens are refused.",
92− MirrorsOp::SyncMirror => "Bring a repository's remotes in step now: a mirror standing by or in CI failover copies the remote's branches and tags in; each follower is pushed g1t's (which also clears a follower that was stuck by pushing over what changed there). Needs push access.",
93− MirrorsOp::AddRemote => "Link a repository to a remote on another g1t or any git host over HTTPS (GitHub repositories are linked by importing them through g1t's GitHub App). `role` `follower`: g1t leads and pushes to it. `role` `leader`: this repository becomes its mirror; only an empty repository can, and it is filled from the remote. `url` is its https clone address, `token` a token that can read and push (kept sealed, never returned), `username` the user it is sent as. Needs the Admin role; agents' tokens are refused.",
94− MirrorsOp::UpdateRemote => "Change a remote's `settings`, all optional: `notify` (`banner`, or `inbox` to also tell the workspace's owners), `take_over_after` (minutes, 5 to 1440, after which g1t takes over on its own while the remote does not answer; null for never), `hand_back` (`when_clean`: an automatic takeover goes back on its own once every ref goes back without a decision; `ask`), `keep_ci_warm` (run `.g1t/workflows` on pushes copied in while standing by), `github_workflows` (run `.github/workflows` in CI failover and takeovers), `hold_deploys`, `report_checks` (a GitHub mirror: report the statuses g1t sets on a commit, such as workflow runs and deploys, to the commit on GitHub as `g1t / <context>` while g1t runs its workflows; on by default), and for a follower `remote_pushes` (`adopt` fast-forwards made there, or `overwrite` them). Needs the Admin role; agents' tokens are refused.",
95− MirrorsOp::RemoveRemote => "Unlink a remote. A mirror becomes an ordinary repository with what it has; a follower is no longer pushed to. Refused during a takeover: hand it back or move it to g1t first. Needs the Admin role; agents' tokens are refused.",
96− }
97− }
98−
99− pub fn input(self) -> Value {
100− let repo = json!({ "type": "string", "description": "Repository as \"owner/name\", e.g. \"flagon-io/hello\"." });
101− let id = json!({ "type": "string", "description": "The remote's id (rmt_…), from get_mirror." });
102− let (properties, required): (Value, &[&str]) = match self {
103− MirrorsOp::GetMirror | MirrorsOp::GetHandBackPlan | MirrorsOp::TakeOver | MirrorsOp::SyncMirror => {
104− (json!({ "repo": repo }), &["repo"])
105− }
106− MirrorsOp::SetCiFailover => (
107− json!({ "repo": repo, "on": { "type": "boolean", "description": "True to start CI failover, false to end it." } }),
108− &["repo", "on"],
109− ),
110− MirrorsOp::HandBack => (
111− json!({
112− "repo": repo,
113− "decisions": {
114− "type": "object",
115− "description": "For each diverged ref, by its full name: keep_ours, keep_theirs or pull_request.",
116− "additionalProperties": { "type": "string", "enum": ["keep_ours", "keep_theirs", "pull_request"] },
117− },
118− }),
119− &["repo"],
120− ),
121− MirrorsOp::MoveToG1t => (
122− json!({
123− "repo": repo,
124− "keep_remote_updated": { "type": "boolean", "description": "True to keep pushing to the remote from g1t; false (the default) to stop tracking it." },
125− }),
126− &["repo"],
127− ),
128− MirrorsOp::AddRemote => (
129− json!({
130− "repo": repo,
131− "provider": { "type": "string", "enum": ["g1t", "git"], "description": "Another g1t (g1t.sh or your own), or any git host." },
132− "role": { "type": "string", "enum": ["follower", "leader"], "description": "follower: g1t leads and pushes to it. leader: this empty repository becomes its mirror." },
133− "url": { "type": "string", "description": "Its https clone address, such as https://g1t.sh/acme/web.git." },
134− "username": { "type": "string", "description": "The user the token is sent as. x-access-token when left out." },
135− "token": { "type": "string", "description": "A token that can read and push. Kept sealed; never returned." },
136− }),
137− &["repo", "provider", "role", "url", "token"],
138− ),
139− MirrorsOp::UpdateRemote => (
140− json!({
141− "repo": repo,
142− "id": id,
143− "notify": { "type": "string", "enum": ["banner", "inbox"] },
144− "take_over_after": { "type": ["integer", "null"], "minimum": 5, "maximum": 1440 },
145− "hand_back": { "type": "string", "enum": ["when_clean", "ask"] },
146− "keep_ci_warm": { "type": "boolean" },
147− "github_workflows": { "type": "boolean" },
148− "hold_deploys": { "type": "boolean" },
149− "report_checks": { "type": "boolean" },
150− "remote_pushes": { "type": "string", "enum": ["adopt", "overwrite"] },
151− }),
152− &["repo", "id"],
153− ),
154− MirrorsOp::RemoveRemote => (json!({ "repo": repo, "id": id }), &["repo", "id"]),
155− };
156− json!({ "type": "object", "properties": properties, "required": required })
157− }
158−}
159−
160−fn text(input: &Value, key: &str) -> String {
161− input[key].as_str().map(str::trim).unwrap_or_default().to_owned()
162−}
163−
164−/// A boolean as sent: JSON, or a word from a form.
165−fn flag(value: &Value) -> Option<bool> {
166− match value {
167− Value::Bool(flag) => Some(*flag),
168− Value::String(word) => match word.trim().to_ascii_lowercase().as_str() {
169− "true" | "1" => Some(true),
170− "false" | "0" => Some(false),
171− _ => None,
172− },
173− _ => None,
174− }
175−}
176−
177−/// `settings` with what `input` changes, in `snake_case` as sent.
178−pub fn settings_from(mut settings: MirrorSettings, input: &Value) -> std::result::Result<MirrorSettings, String> {
179− let word = |key: &str| input.get(key).filter(|value| !value.is_null()).map(|value| value.as_str().unwrap_or_default());
180− if let Some(notify) = word("notify") {
181− settings.notify = serde_json::from_value(json!(notify)).map_err(|_| "notify is banner or inbox.")?;
182− }
183− if let Some(value) = input.get("take_over_after") {
184− settings.take_over_after = match value {
185− Value::Null => None,
186− value => Some(value.as_u64().map(|minutes| minutes as u32).ok_or("take_over_after is a number of minutes, or null.")?),
187− };
188− }
189− if let Some(hand_back) = word("hand_back") {
190− settings.hand_back = serde_json::from_value(json!(hand_back)).map_err(|_| "hand_back is when_clean or ask.")?;
191− }
192− if let Some(remote_pushes) = word("remote_pushes") {
193− settings.remote_pushes = serde_json::from_value(json!(remote_pushes)).map_err(|_| "remote_pushes is adopt or overwrite.")?;
194− }
195− for (key, field) in [
196− ("keep_ci_warm", &mut settings.keep_ci_warm),
197− ("github_workflows", &mut settings.github_workflows),
198− ("hold_deploys", &mut settings.hold_deploys),
199− ("report_checks", &mut settings.report_checks),
200− ] {
201− if let Some(value) = input.get(key).filter(|value| !value.is_null()) {
202− *field = flag(value).ok_or_else(|| format!("{key} is true or false."))?;
203− }
204− }
205− Ok(settings)
206−}
207−
208−/// `decisions` as sent: ref to `keep_ours`, `keep_theirs` or `pull_request`.
209−pub fn decisions_from(input: &Value) -> std::result::Result<BTreeMap<String, RefDecision>, String> {
210− let Some(decisions) = input.get("decisions").filter(|value| !value.is_null()) else {
211− return Ok(BTreeMap::new());
212− };
213− let Some(decisions) = decisions.as_object() else {
214− return Err("decisions is an object from ref to keep_ours, keep_theirs or pull_request.".to_owned());
215− };
216− decisions
217− .iter()
218− .map(|(git_ref, decision)| {
219− let decision = serde_json::from_value(decision.clone())
220− .map_err(|_| format!("{git_ref}: say keep_ours, keep_theirs or pull_request."))?;
221− let git_ref = if git_ref.starts_with("refs/") { git_ref.clone() } else { format!("refs/heads/{git_ref}") };
222− Ok((git_ref, decision))
223− })
224− .collect()
225−}
226−
227−pub async fn run(op: MirrorsOp, services: &Services, viewer: &Viewer, input: &Value) -> Result<Outcome<Value>> {
228− let Some(path) = repo_path(input) else {
229− return Ok(Outcome::fail(FailureCode::Invalid, "Give the repository as \"owner/name\"."));
230− };
231− let found: Outcome<Repo> = g1t_kit::call(&services.repos, "get", &GetArgs { path, viewer: viewer.clone() }).await?;
232− let repo = match found {
233− Outcome::Ok(repo) => repo,
234− Outcome::Fail(failure) => return Ok(Outcome::Fail(failure)),
235− };
236− let integrations = &services.integrations;
237− if op == MirrorsOp::GetMirror {
238− return g1t_kit::call(integrations, "mirror_view", &MirrorViewArgs { viewer: viewer.clone(), repo_id: repo.id }).await;
239− }
240− let Some(actor) = viewer.clone() else {
241− return Ok(Outcome::fail(FailureCode::Unauthenticated, "Sign in to change a repository's mirroring."));
242− };
243− let act = || MirrorActArgs { actor: actor.clone(), repo_id: repo.id.clone() };
244− let id = text(input, "id");
245− if matches!(op, MirrorsOp::UpdateRemote | MirrorsOp::RemoveRemote) && id.is_empty() {
246− return Ok(Outcome::fail(FailureCode::Invalid, "Name the remote by its id (rmt_…), from get_mirror."));
247− }
248− match op {
249− MirrorsOp::GetMirror => unreachable!("answered above"),
250− MirrorsOp::GetHandBackPlan => g1t_kit::call(integrations, "mirror_hand_back_plan", &act()).await,
251− MirrorsOp::TakeOver => g1t_kit::call(integrations, "mirror_take_over", &act()).await,
252− MirrorsOp::SyncMirror => g1t_kit::call(integrations, "mirror_sync", &act()).await,
253− MirrorsOp::SetCiFailover => {
254− let Some(on) = flag(&input["on"]) else {
255− return Ok(Outcome::fail(FailureCode::Invalid, "Say on: true to start CI failover, or false to end it."));
256− };
257− g1t_kit::call(integrations, "mirror_ci", &MirrorCiArgs { actor, repo_id: repo.id, on }).await
258− }
259− MirrorsOp::HandBack => {
260− let decisions = match decisions_from(input) {
261− Ok(decisions) => decisions,
262− Err(problem) => return Ok(Outcome::fail(FailureCode::Invalid, problem)),
263− };
264− g1t_kit::call(integrations, "mirror_hand_back", &MirrorHandBackArgs { actor, repo_id: repo.id, decisions }).await
265− }
266− MirrorsOp::MoveToG1t => {
267− let keep_remote_updated = match &input["keep_remote_updated"] {
268− Value::Null => false,
269− value => match flag(value) {
270− Some(keep) => keep,
271− None => return Ok(Outcome::fail(FailureCode::Invalid, "keep_remote_updated is true or false.")),
272− },
273− };
274− g1t_kit::call(integrations, "mirror_move_in", &MirrorMoveInArgs { actor, repo_id: repo.id, keep_remote_updated }).await
275− }
276− MirrorsOp::AddRemote => {
277− let provider = match text(input, "provider").as_str() {
278− "g1t" => RemoteProvider::G1t,
279− "git" => RemoteProvider::Git,
280− "github" => {
281− return Ok(Outcome::fail(
282− FailureCode::Invalid,
283− "GitHub repositories are linked by importing them through g1t's GitHub App.",
284− ));
285− }
286− _ => return Ok(Outcome::fail(FailureCode::Invalid, "provider is g1t or git.")),
287− };
288− let role = match text(input, "role").as_str() {
289− "leader" => RemoteRole::Leader,
290− "follower" => RemoteRole::Follower,
291− _ => return Ok(Outcome::fail(FailureCode::Invalid, "role is follower (g1t leads) or leader (the remote leads).")),
292− };
293− let username = Some(text(input, "username")).filter(|name| !name.is_empty());
294− let token = Some(text(input, "token")).filter(|token| !token.is_empty());
295− let args = MirrorAddArgs { actor, repo_id: repo.id, provider, role, url: text(input, "url"), username, token };
296− g1t_kit::call(integrations, "mirror_add", &args).await
297− }
298− MirrorsOp::UpdateRemote => {
299− let view: Outcome<g1t_contracts::mirrors::MirrorView> =
300− g1t_kit::call(integrations, "mirror_view", &MirrorViewArgs { viewer: viewer.clone(), repo_id: repo.id }).await?;
301− let view = match view {
302− Outcome::Ok(view) => view,
303− Outcome::Fail(failure) => return Ok(Outcome::Fail(failure)),
304− };
305− let Some(remote) = view.remotes.into_iter().find(|remote| remote.id == id) else {
306− return Ok(Outcome::fail(FailureCode::NotFound, "That remote is not one of this repository's."));
307− };
308− let settings = match settings_from(remote.settings, input) {
309− Ok(settings) => settings,
310− Err(problem) => return Ok(Outcome::fail(FailureCode::Invalid, problem)),
311− };
312− g1t_kit::call(integrations, "mirror_settings", &MirrorSettingsArgs { actor, remote_id: id, settings }).await
313− }
314− MirrorsOp::RemoveRemote => {
315− let view: Outcome<g1t_contracts::mirrors::MirrorView> =
316− g1t_kit::call(integrations, "mirror_view", &MirrorViewArgs { viewer: viewer.clone(), repo_id: repo.id }).await?;
317− if !matches!(&view, Outcome::Ok(view) if view.remotes.iter().any(|remote| remote.id == id)) {
318− return Ok(Outcome::fail(FailureCode::NotFound, "That remote is not one of this repository's."));
319− }
320− g1t_kit::call(integrations, "mirror_remove", &MirrorRemoveArgs { actor, remote_id: id }).await
321− }
322− }
323−}
324−
325−#[cfg(test)]
326−mod tests {
327− use super::*;
328− use g1t_contracts::credentials::NEVER;
329− use g1t_contracts::mirrors::{HandBack, Notify, RemotePushes};
330− use g1t_contracts::scopes::{Level, scope_for};
331−
332− #[test]
333− fn each_operation_is_described_and_scoped() {
334− for op in MirrorsOp::ALL {
335− assert!(crate::operations::Op::ALL.contains(&crate::operations::Op::Mirrors(op)), "{}", op.name());
336− assert!(!op.title().is_empty() && op.description().len() > 40, "{}", op.name());
337− assert!(op.input()["required"].as_array().unwrap().contains(&json!("repo")), "{}", op.name());
338− let level = scope_for(op.name()).unwrap_or_else(|| panic!("{} has no scope", op.name())).level();
339− let expected = match op {
340− MirrorsOp::GetMirror => Level::Read,
341− MirrorsOp::SyncMirror => Level::Write,
342− _ => Level::Admin,
343− };
344− assert_eq!(level, expected, "{}", op.name());
345− }
346− for op in [MirrorsOp::MoveToG1t, MirrorsOp::AddRemote, MirrorsOp::UpdateRemote, MirrorsOp::RemoveRemote] {
347− assert!(NEVER.contains(&op.name()), "agents never {}", op.name());
348− }
349− }
350−
351− #[test]
352− fn settings_change_only_what_is_sent() {
353− let base = MirrorSettings::default();
354− let changed = settings_from(base.clone(), &json!({ "notify": "inbox", "take_over_after": 30, "keep_ci_warm": "true" })).unwrap();
355− assert_eq!(changed.notify, Notify::Inbox);
356− assert_eq!(changed.take_over_after, Some(30));
357− assert!(changed.keep_ci_warm);
358− assert_eq!(changed.hand_back, HandBack::WhenClean);
359− assert_eq!(changed.remote_pushes, RemotePushes::Adopt);
360− assert!(changed.report_checks, "checks go to GitHub unless turned off");
361− assert!(!settings_from(base.clone(), &json!({ "report_checks": false })).unwrap().report_checks);
362− let cleared = settings_from(changed, &json!({ "take_over_after": null })).unwrap();
363− assert_eq!(cleared.take_over_after, None);
364− assert!(settings_from(base.clone(), &json!({ "notify": "pager" })).is_err());
365− assert!(settings_from(base, &json!({ "hold_deploys": "maybe" })).is_err());
366− }
367−
368− #[test]
369− fn decisions_name_refs_or_branches() {
370− let decisions = decisions_from(&json!({ "decisions": { "docs": "keep_theirs", "refs/tags/v1": "keep_ours" } })).unwrap();
371− assert_eq!(decisions.get("refs/heads/docs"), Some(&RefDecision::KeepTheirs));
372− assert_eq!(decisions.get("refs/tags/v1"), Some(&RefDecision::KeepOurs));
373− assert!(decisions_from(&json!({ "decisions": { "docs": "merge" } })).is_err());
374− assert!(decisions_from(&json!({})).unwrap().is_empty());
375− }
376−}
+0−18
1212 use crate::archives::ArchiveOp;
1313 use crate::customize::CustomizeOp;
1414 use crate::deploy_keys::DeployKeysOp;
15−use crate::mirrors::MirrorsOp;
1615 use crate::deployments::DeploymentsOp;
1716 use crate::telemetry::TelemetryOp;
1817 use crate::packages::PackagesOp;
192191 Op::DeployKeys(DeployKeysOp::GetDeployKey),
193192 Op::DeployKeys(DeployKeysOp::CreateDeployKey),
194193 Op::DeployKeys(DeployKeysOp::DeleteDeployKey),
195− ],
196− ),
197− (
198− "Mirroring",
199− "A repository's links to copies of it on other hosts: a mirror stands by as a read-only copy of a remote that leads, until someone takes over on g1t and later hands back, or moves it to g1t for good. A repository g1t leads can be mirrored to other hosts.",
200− &[
201− Op::Mirrors(MirrorsOp::GetMirror),
202− Op::Mirrors(MirrorsOp::GetHandBackPlan),
203− Op::Mirrors(MirrorsOp::TakeOver),
204− Op::Mirrors(MirrorsOp::SetCiFailover),
205− Op::Mirrors(MirrorsOp::HandBack),
206− Op::Mirrors(MirrorsOp::MoveToG1t),
207− Op::Mirrors(MirrorsOp::SyncMirror),
208− Op::Mirrors(MirrorsOp::AddRemote),
209− Op::Mirrors(MirrorsOp::UpdateRemote),
210− Op::Mirrors(MirrorsOp::RemoveRemote),
211194 ],
212195 ),
213196 (
873856 Op::Artifacts(op) => op.title(),
874857 Op::Archives(op) => op.title(),
875858 Op::DeployKeys(op) => op.title(),
876− Op::Mirrors(op) => op.title(),
877859 Op::Packages(op) => op.title(),
878860 Op::Folios(op) => op.title(),
879861 Op::Customize(op) => op.title(),
+1−20
3232 use crate::archives::ArchiveOp;
3333 use crate::customize::CustomizeOp;
3434 use crate::deploy_keys::DeployKeysOp;
35−use crate::mirrors::MirrorsOp;
3635 use crate::deployments::DeploymentsOp;
3736 use crate::telemetry::TelemetryOp;
3837 use crate::packages::PackagesOp;
343342 Archives(ArchiveOp),
344343 /// A repository's deploy keys: deploy_keys.rs.
345344 DeployKeys(DeployKeysOp),
346− /// A repository's mirroring: its remotes, takeovers and hand-backs:
347− /// mirrors.rs.
348− Mirrors(MirrorsOp),
349345 /// A workspace's packages, their versions, deleting and restoring
350346 /// them, and who may use them: packages.rs.
351347 Packages(PackagesOp),
724720 }
725721
726722 impl Op {
727− pub const ALL: [Op; 408] = [
723+ pub const ALL: [Op; 398] = [
728724 Op::Whoami,
729725 Op::GetWorkspace,
730726 Op::CreateWorkspace,
10651061 Op::Customize(CustomizeOp::GrantConnector),
10661062 Op::Customize(CustomizeOp::RevokeConnector),
10671063 Op::Customize(CustomizeOp::Bundle),
1068− Op::Mirrors(MirrorsOp::GetMirror),
1069− Op::Mirrors(MirrorsOp::GetHandBackPlan),
1070− Op::Mirrors(MirrorsOp::TakeOver),
1071− Op::Mirrors(MirrorsOp::SetCiFailover),
1072− Op::Mirrors(MirrorsOp::HandBack),
1073− Op::Mirrors(MirrorsOp::MoveToG1t),
1074− Op::Mirrors(MirrorsOp::SyncMirror),
1075− Op::Mirrors(MirrorsOp::AddRemote),
1076− Op::Mirrors(MirrorsOp::UpdateRemote),
1077− Op::Mirrors(MirrorsOp::RemoveRemote),
10781064 Op::Protection(ProtectionOp::UpdateEnvironment),
10791065 Op::Protection(ProtectionOp::DeleteEnvironment),
10801066 Op::Protection(ProtectionOp::GetPendingDeployments),
13521338 Op::Artifacts(op) => op.name(),
13531339 Op::Archives(op) => op.name(),
13541340 Op::DeployKeys(op) => op.name(),
1355− Op::Mirrors(op) => op.name(),
13561341 Op::Packages(op) => op.name(),
13571342 Op::Folios(op) => op.name(),
13581343 Op::Customize(op) => op.name(),
19331918 Op::Artifacts(op) => op.description(),
19341919 Op::Archives(op) => op.description(),
19351920 Op::DeployKeys(op) => op.description(),
1936− Op::Mirrors(op) => op.description(),
19371921 Op::Packages(op) => op.description(),
19381922 Op::Folios(op) => op.description(),
19391923 Op::Customize(op) => op.description(),
34623446 Op::Artifacts(op) => op.input(),
34633447 Op::Archives(op) => op.input(),
34643448 Op::DeployKeys(op) => op.input(),
3465− Op::Mirrors(op) => op.input(),
34663449 Op::Packages(op) => op.input(),
34673450 Op::Folios(op) => op.input(),
34683451 Op::Customize(op) => op.input(),
46314614 is_private: input["private"].as_bool() == Some(true),
46324615 import_url: optional_text(input, "import_url"),
46334616 import_token: None,
4634− mirror: None,
46354617 },
46364618 )
46374619 .await
58835865 Op::Artifacts(op) => crate::run_artifacts::run(op, services, viewer, input).await,
58845866 Op::Archives(op) => crate::archives::run(op, services, viewer, input).await,
58855867 Op::DeployKeys(op) => crate::deploy_keys::run(op, services, viewer, input).await,
5886− Op::Mirrors(op) => crate::mirrors::run(op, services, viewer, input).await,
58875868 Op::Packages(op) => crate::packages::run(op, services, viewer, input).await,
58885869 Op::Folios(op) => crate::folios::run(op, services, viewer, input).await,
58895870 Op::Customize(op) => crate::customize::run(op, services, viewer, input).await,
+0−388
1387513875 ]
1387613876 }
1387713877 },
13878− "get_mirror": {
13879− "params": {
13880− "owner": "acme",
13881− "name": "web"
13882− },
13883− "response": {
13884− "remotes": [
13885− {
13886− "id": "rmt_01kp4a2b3c4d5e6f7g8h9j0k1m",
13887− "repo_id": "rep_01kp49z8y7x6w5v4t3s2r1q0pn",
13888− "repo": "acme/web",
13889− "provider": "github",
13890− "role": "leader",
13891− "name": "github.com/acme/web",
13892− "url": "https://github.com/acme/web",
13893− "state": "standby",
13894− "state_since": "2026-10-08T13:58:00.000Z",
13895− "state_by": "syntaqx",
13896− "reachable": true,
13897− "unreachable_since": null,
13898− "synced_at": "2026-10-08T13:57:42.000Z",
13899− "last_error": null,
13900− "checks_problem": null,
13901− "settings": {
13902− "notify": "banner",
13903− "take_over_after": null,
13904− "hand_back": "when_clean",
13905− "keep_ci_warm": false,
13906− "github_workflows": true,
13907− "hold_deploys": true,
13908− "report_checks": true,
13909− "remote_pushes": "adopt"
13910− },
13911− "created_at": "2026-10-05T10:00:00.000Z"
13912− }
13913− ],
13914− "plan": null,
13915− "can_manage": true
13916− },
13917− "notes": "A repository that leads lists its followers instead, each `role: follower` with `state` `following` or `stuck`. A mirror standing by is read-only on g1t: pushes, merges, issues, pull requests and agents are refused, and nothing runs. `reachable` is false once the remote's host has failed three checks over two minutes; by default that is only shown, and nothing happens on its own."
13918− },
13919− "get_hand_back_plan": {
13920− "params": {
13921− "owner": "acme",
13922− "name": "web"
13923− },
13924− "response": {
13925− "remotes": [
13926− {
13927− "id": "rmt_01kp4a2b3c4d5e6f7g8h9j0k1m",
13928− "repo_id": "rep_01kp49z8y7x6w5v4t3s2r1q0pn",
13929− "repo": "acme/web",
13930− "provider": "github",
13931− "role": "leader",
13932− "name": "github.com/acme/web",
13933− "url": "https://github.com/acme/web",
13934− "state": "takeover",
13935− "state_since": "2026-10-08T13:58:00.000Z",
13936− "state_by": "syntaqx",
13937− "reachable": true,
13938− "unreachable_since": null,
13939− "synced_at": "2026-10-08T13:57:42.000Z",
13940− "last_error": null,
13941− "checks_problem": null,
13942− "settings": {
13943− "notify": "banner",
13944− "take_over_after": null,
13945− "hand_back": "when_clean",
13946− "keep_ci_warm": false,
13947− "github_workflows": true,
13948− "hold_deploys": true,
13949− "report_checks": true,
13950− "remote_pushes": "adopt"
13951− },
13952− "created_at": "2026-10-05T10:00:00.000Z"
13953− }
13954− ],
13955− "plan": {
13956− "refs": [
13957− {
13958− "ref": "refs/heads/fix/login-timeout",
13959− "base": "9d0e1aa4c8f2b7e6d5a4c3b2a1f0e9d8c7b6a5f4",
13960− "ours": "c47f2b8e1d0c9b8a7f6e5d4c3b2a1f0e9d8c7b6a",
13961− "theirs": "9d0e1aa4c8f2b7e6d5a4c3b2a1f0e9d8c7b6a5f4",
13962− "action": "push",
13963− "decision": null
13964− },
13965− {
13966− "ref": "refs/heads/main",
13967− "base": "41c9e02b7a6f5e4d3c2b1a0f9e8d7c6b5a4f3e2d",
13968− "ours": "e01d9a37f6e5d4c3b2a1f0e9d8c7b6a5f4e3d2c1",
13969− "theirs": "41c9e02b7a6f5e4d3c2b1a0f9e8d7c6b5a4f3e2d",
13970− "action": "pull_request",
13971− "decision": null
13972− },
13973− {
13974− "ref": "refs/heads/docs/readme",
13975− "base": "7f3a1c2d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b",
13976− "ours": "5b6c7d8e9f0a1b2c3d4e5f6a7b8c9d0e1f2a3b4c",
13977− "theirs": "a1b2c3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8a9b0",
13978− "action": "diverged",
13979− "decision": null
13980− }
13981− ],
13982− "reachable": true,
13983− "ready": false
13984− },
13985− "can_manage": true
13986− },
13987− "notes": "Refs that did not move on either side are left out. `ready` stays false until `docs/readme` has a decision."
13988− },
13989− "take_over_mirror": {
13990− "params": {
13991− "owner": "acme",
13992− "name": "web"
13993− },
13994− "response": {
13995− "remotes": [
13996− {
13997− "id": "rmt_01kp4a2b3c4d5e6f7g8h9j0k1m",
13998− "repo_id": "rep_01kp49z8y7x6w5v4t3s2r1q0pn",
13999− "repo": "acme/web",
14000− "provider": "github",
14001− "role": "leader",
14002− "name": "github.com/acme/web",
14003− "url": "https://github.com/acme/web",
14004− "state": "takeover",
14005− "state_since": "2026-10-08T13:58:00.000Z",
14006− "state_by": "syntaqx",
14007− "reachable": false,
14008− "unreachable_since": "2026-10-08T14:04:00.000Z",
14009− "synced_at": "2026-10-08T13:57:42.000Z",
14010− "last_error": null,
14011− "checks_problem": null,
14012− "settings": {
14013− "notify": "banner",
14014− "take_over_after": null,
14015− "hand_back": "when_clean",
14016− "keep_ci_warm": false,
14017− "github_workflows": true,
14018− "hold_deploys": true,
14019− "report_checks": true,
14020− "remote_pushes": "adopt"
14021− },
14022− "created_at": "2026-10-05T10:00:00.000Z"
14023− }
14024− ],
14025− "plan": null,
14026− "can_manage": true
14027− }
14028− },
14029− "set_ci_failover": {
14030− "params": {
14031− "owner": "acme",
14032− "name": "web"
14033− },
14034− "request": {
14035− "on": true
14036− },
14037− "response": {
14038− "remotes": [
14039− {
14040− "id": "rmt_01kp4a2b3c4d5e6f7g8h9j0k1m",
14041− "repo_id": "rep_01kp49z8y7x6w5v4t3s2r1q0pn",
14042− "repo": "acme/web",
14043− "provider": "github",
14044− "role": "leader",
14045− "name": "github.com/acme/web",
14046− "url": "https://github.com/acme/web",
14047− "state": "ci",
14048− "state_since": "2026-10-08T13:58:00.000Z",
14049− "state_by": "syntaqx",
14050− "reachable": true,
14051− "unreachable_since": null,
14052− "synced_at": "2026-10-08T13:57:42.000Z",
14053− "last_error": null,
14054− "checks_problem": null,
14055− "settings": {
14056− "notify": "banner",
14057− "take_over_after": null,
14058− "hand_back": "when_clean",
14059− "keep_ci_warm": false,
14060− "github_workflows": true,
14061− "hold_deploys": true,
14062− "report_checks": true,
14063− "remote_pushes": "adopt"
14064− },
14065− "created_at": "2026-10-05T10:00:00.000Z"
14066− }
14067− ],
14068− "plan": null,
14069− "can_manage": true
14070− }
14071− },
14072− "hand_back_mirror": {
14073− "params": {
14074− "owner": "acme",
14075− "name": "web"
14076− },
14077− "request": {
14078− "decisions": {
14079− "refs/heads/docs/readme": "pull_request"
14080− }
14081− },
14082− "response": {
14083− "remotes": [
14084− {
14085− "id": "rmt_01kp4a2b3c4d5e6f7g8h9j0k1m",
14086− "repo_id": "rep_01kp49z8y7x6w5v4t3s2r1q0pn",
14087− "repo": "acme/web",
14088− "provider": "github",
14089− "role": "leader",
14090− "name": "github.com/acme/web",
14091− "url": "https://github.com/acme/web",
14092− "state": "standby",
14093− "state_since": "2026-10-08T13:58:00.000Z",
14094− "state_by": "syntaqx",
14095− "reachable": true,
14096− "unreachable_since": null,
14097− "synced_at": "2026-10-08T13:57:42.000Z",
14098− "last_error": null,
14099− "checks_problem": null,
14100− "settings": {
14101− "notify": "banner",
14102− "take_over_after": null,
14103− "hand_back": "when_clean",
14104− "keep_ci_warm": false,
14105− "github_workflows": true,
14106− "hold_deploys": true,
14107− "report_checks": true,
14108− "remote_pushes": "adopt"
14109− },
14110− "created_at": "2026-10-05T10:00:00.000Z"
14111− }
14112− ],
14113− "plan": null,
14114− "can_manage": true,
14115− "notes": [
14116− "main: opened https://github.com/acme/web/pull/1290",
14117− "docs/readme: opened https://github.com/acme/web/pull/1291"
14118− ]
14119− },
14120− "notes": "Branch names work as keys too: `{ \"docs/readme\": \"keep_theirs\" }`."
14121− },
14122− "move_mirror_to_g1t": {
14123− "params": {
14124− "owner": "acme",
14125− "name": "web"
14126− },
14127− "request": {
14128− "keep_remote_updated": false
14129− },
14130− "response": {
14131− "remotes": [],
14132− "plan": null,
14133− "can_manage": true
14134− },
14135− "notes": "With `keep_remote_updated: true` the remote stays in `remotes` as a follower, and g1t pushes to it from then on."
14136− },
14137− "sync_mirror": {
14138− "params": {
14139− "owner": "acme",
14140− "name": "web"
14141− },
14142− "response": {
14143− "remotes": [
14144− {
14145− "id": "rmt_01kp4a2b3c4d5e6f7g8h9j0k1m",
14146− "repo_id": "rep_01kp49z8y7x6w5v4t3s2r1q0pn",
14147− "repo": "acme/web",
14148− "provider": "github",
14149− "role": "leader",
14150− "name": "github.com/acme/web",
14151− "url": "https://github.com/acme/web",
14152− "state": "standby",
14153− "state_since": "2026-10-08T13:58:00.000Z",
14154− "state_by": "syntaqx",
14155− "reachable": true,
14156− "unreachable_since": null,
14157− "synced_at": "2026-10-08T13:57:42.000Z",
14158− "last_error": null,
14159− "checks_problem": null,
14160− "settings": {
14161− "notify": "banner",
14162− "take_over_after": null,
14163− "hand_back": "when_clean",
14164− "keep_ci_warm": false,
14165− "github_workflows": true,
14166− "hold_deploys": true,
14167− "report_checks": true,
14168− "remote_pushes": "adopt"
14169− },
14170− "created_at": "2026-10-05T10:00:00.000Z"
14171− }
14172− ],
14173− "plan": null,
14174− "can_manage": true
14175− }
14176− },
14177− "add_mirror_remote": {
14178− "params": {
14179− "owner": "acme",
14180− "name": "web"
14181− },
14182− "request": {
14183− "provider": "g1t",
14184− "role": "follower",
14185− "url": "https://git.acme.internal/acme/web.git",
14186− "username": "deploy",
14187− "token": "g1t_…"
14188− },
14189− "response": {
14190− "id": "rmt_01kp4b3c4d5e6f7g8h9j0k1m2n",
14191− "repo_id": "rep_01kp49z8y7x6w5v4t3s2r1q0pn",
14192− "repo": "acme/web",
14193− "provider": "g1t",
14194− "role": "follower",
14195− "name": "git.acme.internal/acme/web",
14196− "url": "https://git.acme.internal/acme/web",
14197− "state": "following",
14198− "state_since": "2026-10-08T13:58:00.000Z",
14199− "state_by": "syntaqx",
14200− "reachable": true,
14201− "unreachable_since": null,
14202− "synced_at": "2026-10-08T13:57:42.000Z",
14203− "last_error": null,
14204− "checks_problem": null,
14205− "settings": {
14206− "notify": "banner",
14207− "take_over_after": null,
14208− "hand_back": "when_clean",
14209− "keep_ci_warm": false,
14210− "github_workflows": true,
14211− "hold_deploys": true,
14212− "report_checks": true,
14213− "remote_pushes": "adopt"
14214− },
14215− "created_at": "2026-10-05T10:00:00.000Z"
14216− },
14217− "notes": "The token is never returned. A remote that refused it, or could not be reached, is still added, with `last_error` saying why."
14218− },
14219− "update_mirror_remote": {
14220− "params": {
14221− "owner": "acme",
14222− "name": "web",
14223− "id": "rmt_01kp4a2b3c4d5e6f7g8h9j0k1m"
14224− },
14225− "request": {
14226− "notify": "inbox",
14227− "take_over_after": 30
14228− },
14229− "response": {
14230− "id": "rmt_01kp4a2b3c4d5e6f7g8h9j0k1m",
14231− "repo_id": "rep_01kp49z8y7x6w5v4t3s2r1q0pn",
14232− "repo": "acme/web",
14233− "provider": "github",
14234− "role": "leader",
14235− "name": "github.com/acme/web",
14236− "url": "https://github.com/acme/web",
14237− "state": "standby",
14238− "state_since": "2026-10-08T13:58:00.000Z",
14239− "state_by": "syntaqx",
14240− "reachable": true,
14241− "unreachable_since": null,
14242− "synced_at": "2026-10-08T13:57:42.000Z",
14243− "last_error": null,
14244− "checks_problem": null,
14245− "settings": {
14246− "notify": "inbox",
14247− "take_over_after": 30,
14248− "hand_back": "when_clean",
14249− "keep_ci_warm": false,
14250− "github_workflows": true,
14251− "hold_deploys": true,
14252− "report_checks": true,
14253− "remote_pushes": "adopt"
14254− },
14255− "created_at": "2026-10-05T10:00:00.000Z"
14256− }
14257− },
14258− "remove_mirror_remote": {
14259− "params": {
14260− "owner": "acme",
14261− "name": "web",
14262− "id": "rmt_01kp4b3c4d5e6f7g8h9j0k1m2n"
14263− },
14264− "response": true
14265− },
1426613878 "list_workspace_artifacts": {
1426713879 "params": {
1426813880 "workspace": "acme"
+0−12
77 use crate::archives::ArchiveOp;
88 use crate::customize::CustomizeOp;
99 use crate::deploy_keys::DeployKeysOp;
10−use crate::mirrors::MirrorsOp;
1110 use crate::deployments::DeploymentsOp;
1211 use crate::telemetry::TelemetryOp;
1312 use crate::packages::PackagesOp;
8988 route("POST", "/repos/:owner/:name/keys", Op::DeployKeys(DeployKeysOp::CreateDeployKey), &[]),
9089 route("GET", "/repos/:owner/:name/keys/:id", Op::DeployKeys(DeployKeysOp::GetDeployKey), &[]),
9190 route("DELETE", "/repos/:owner/:name/keys/:id", Op::DeployKeys(DeployKeysOp::DeleteDeployKey), &[]),
92− // Mirroring: a repository's remotes, takeovers and hand-backs.
93− route("GET", "/repos/:owner/:name/mirror", Op::Mirrors(MirrorsOp::GetMirror), &[]),
94− route("GET", "/repos/:owner/:name/mirror/hand-back", Op::Mirrors(MirrorsOp::GetHandBackPlan), &[]),
95− route("POST", "/repos/:owner/:name/mirror/take-over", Op::Mirrors(MirrorsOp::TakeOver), &[]),
96− route("POST", "/repos/:owner/:name/mirror/ci", Op::Mirrors(MirrorsOp::SetCiFailover), &[]),
97− route("POST", "/repos/:owner/:name/mirror/hand-back", Op::Mirrors(MirrorsOp::HandBack), &[]),
98− route("POST", "/repos/:owner/:name/mirror/move-to-g1t", Op::Mirrors(MirrorsOp::MoveToG1t), &[]),
99− route("POST", "/repos/:owner/:name/mirror/sync", Op::Mirrors(MirrorsOp::SyncMirror), &[]),
100− route("POST", "/repos/:owner/:name/mirror/remotes", Op::Mirrors(MirrorsOp::AddRemote), &[]),
101− route("PATCH", "/repos/:owner/:name/mirror/remotes/:id", Op::Mirrors(MirrorsOp::UpdateRemote), &[]),
102− route("DELETE", "/repos/:owner/:name/mirror/remotes/:id", Op::Mirrors(MirrorsOp::RemoveRemote), &[]),
10391 // Your notifications: threads, marking them, and what you subscribe
10492 // to and watch. GitHub's addresses, with g1t's saved and snoozed.
10593 route("GET", "/notifications", Op::ListNotifications, &[("all", "all"), ("participating", "participating"), ("view", "view"), ("reason", "reason"), ("severity", "severity"), ("since", "since"), ("before", "before"), ("cursor", "cursor"), ("per_page", "per_page")]),
+2−2
625625 }
626626
627627 /// The repository a project's permission comes from, as the deployments
628−/// service reads it: a mirrored project has none, and its workspace's base
629−/// permission decides.
628+/// service reads it: a project without a hosted source has none, and its
629+/// workspace's base permission decides.
630630 fn repo_of(project: &Value) -> (String, String, bool) {
631631 let source = &project["source"];
632632 let private = project["private"].as_bool().unwrap_or(true);
+1−12
2323 use crate::archives::ArchiveOp;
2424 use crate::customize::CustomizeOp;
2525 use crate::deploy_keys::DeployKeysOp;
26−use crate::mirrors::MirrorsOp;
2726 use crate::deployments::DeploymentsOp;
2827 use crate::telemetry::TelemetryOp;
2928 use crate::packages::PackagesOp;
7271 Tool {
7372 name: "repository",
7473 title: "Repositories",
75− description: "Repositories: find, read and create them, change their settings and rulesets (what may happen to branches and tags, and what a pull request needs to merge), check their CODEOWNERS file, manage their labels and milestones, see and dismiss their security alerts (secrets and vulnerable dependencies), read what their default branch says (languages, contributors, license), star them, publish releases, and look after their mirroring (take a mirror over, hand it back, or move it to g1t for good). Name one as \"owner/name\". Deleting, transferring and changing visibility need `confirm`.",
74+ description: "Repositories: find, read and create them, change their settings and rulesets (what may happen to branches and tags, and what a pull request needs to merge), check their CODEOWNERS file, manage their labels and milestones, see and dismiss their security alerts (secrets and vulnerable dependencies), read what their default branch says (languages, contributors, license), star them and publish releases. Name one as \"owner/name\". Deleting, transferring and changing visibility need `confirm`.",
7675 default_action: None,
7776 actions: &[
7877 a("list", Op::ListRepos, "Repositories you can see"),
123122 a("delete_branch", Op::DeleteBranch, "Delete a branch; make it again at its commit to restore it"),
124123 a("rename", Op::RenameRepo, "Rename it; old addresses redirect"),
125124 a("transfer", Op::TransferRepo, "Move it to another workspace you own"),
126− a("mirror", Op::Mirrors(MirrorsOp::GetMirror), "Its remotes: what it mirrors or is mirrored to"),
127− a("mirror_hand_back_plan", Op::Mirrors(MirrorsOp::GetHandBackPlan), "What handing a takeover back would do, ref by ref"),
128− a("mirror_take_over", Op::Mirrors(MirrorsOp::TakeOver), "Make g1t lead a mirror for now"),
129− a("mirror_ci", Op::Mirrors(MirrorsOp::SetCiFailover), "Run a mirror's workflows on g1t (on), or stop (off)"),
130− a("mirror_hand_back", Op::Mirrors(MirrorsOp::HandBack), "Send a takeover back, deciding diverged refs"),
131− a("mirror_move_to_g1t", Op::Mirrors(MirrorsOp::MoveToG1t), "Stop tracking the remote; g1t leads for good"),
132− a("mirror_sync", Op::Mirrors(MirrorsOp::SyncMirror), "Bring its remotes in step now"),
133− a("mirror_add_remote", Op::Mirrors(MirrorsOp::AddRemote), "Link another g1t or git host"),
134− a("mirror_update_remote", Op::Mirrors(MirrorsOp::UpdateRemote), "Change a remote's settings"),
135− a("mirror_remove_remote", Op::Mirrors(MirrorsOp::RemoveRemote), "Unlink a remote"),
136125 a("archive", Op::ArchiveRepo, "Make it read-only"),
137126 a("unarchive", Op::UnarchiveRepo, "Make it writable again"),
138127 a("set_visibility", Op::SetRepoVisibility, "Make it public or private"),
+1−1
1414 '/guides/g1t-agents/': '/guides/working-with-g1t/',
1515 '/guides/inbox/': '/guides/notifications/',
1616 '/guides/marketplace/': '/guides/customize/',
17+ '/guides/mirroring/': '/guides/github/',
1718 '/guides/today/': '/guides/home/',
1819 },
1920 integrations: [
181182 items: [
182183 { label: 'Accounts and sign-in', slug: 'guides/authentication' },
183184 { label: 'GitHub', slug: 'guides/github' },
184− { label: 'Mirroring', slug: 'guides/mirroring' },
185185 { label: 'Workspaces and tokens', slug: 'guides/workspaces' },
186186 { label: 'Access and roles', slug: 'guides/access-and-roles' },
187187 { label: 'Permissions', slug: 'guides/permissions' },
+4−4
5959 `main`. Each push sends only what the last did not.
6060 - **Status.** Depends on Cloudflare.
6161
62−### Imports and mirrors up to 40 MB
62+### Imports up to 40 MB
6363
64−Importing or mirroring a repository copies it in one piece of at most
65−40 MB, after compression.
64+Importing a repository copies it in one piece of at most 40 MB, after
65+compression.
6666
6767 - **Why.** The copy is held in memory while it moves, and a Worker has
6868 128 MB for everything it is doing at once.
6969 - **Instead.** Clone the repository yourself and push it to g1t, in steps if
70− it is over 100 MB. See [Import, mirror or move a repository](/guides/github/#what-comes-across).
70+ it is over 100 MB. See [Import a repository](/guides/github/#what-comes-across).
7171 - **Status.** Streaming the copy, so size stops mattering, is planned.
7272
7373 ### Partial clone works, but is not promised
+1−1
110110
111111 A per-workspace operation counter that is our best guess at your invoice. A
112112 smart HTTP
113−client inside a Worker for landing, catch-up, mirrors and imports. Our own
113+client inside a Worker for landing, catch-up and imports. Our own
114114 push policy in front of Artifacts. A versioned ref cache with a test that
115115 guards it. Two layers of credential caching. A bookmark protocol for D1.
116116 A probe that deploys throwaway Workers to measure placement, and a
+0−26
2222 Otherwise g1t doesn't read `.github`, so a repository that lives in both
2323 places can keep `.github` for GitHub and `.g1t` for g1t, side by side.
2424
25−### On a mirror
26−
27−A [mirror](/guides/mirroring/) of a GitHub repository runs nothing while it
28−stands by: its workflows run on GitHub. Its owners can change that:
29−
30−- **CI failover** runs its workflows on g1t for each push copied in from
31− GitHub, `.github/workflows` as well as `.g1t/workflows`. Use it when
32− GitHub's workflows aren't running.
33−- **Taking over** runs them for everything pushed to g1t, until it's handed
34− back.
35−- **Keep CI warm** runs `.g1t/workflows`, and only those, on each push
36− copied in while it stands by.
37−
38−When both folders have a workflow of the same `name:`, the one in `.g1t`
39−runs. A workflow that deploys (any job names an `environment:`) waits for
40−approval during CI failover and takeovers, so it doesn't deploy from two
41−places, unless the mirror's settings say otherwise. A push copied in from
42−GitHub that changes workflows or local actions waits for approval before
43−it can use the repository's secrets.
44−
45−Whenever g1t runs a mirror's workflows, their results show on the commit on
46−GitHub too, as commit statuses named `g1t / <workflow> / <event>`, such as
47−`g1t / CI / push`. This needs the Commit statuses permission on g1t's GitHub
48−App; turn it off with **Report checks to GitHub** in the mirror's settings.
49−See [Checks on GitHub](/guides/mirroring/#checks-on-github).
50−
5125 Then add your [secrets and variables](#secrets-and-variables): GitHub never
5226 gives their values out, so they cannot be copied across.
5327
+1−3
77 for every project until you turn them on. Once they are on, every branch
88 with a pull request gets its own live preview, linked on the pull request,
99 and the default branch goes to production on every push. Reviewers, and the agents reviewing for you,
10−click through the change instead of reading a diff. A [mirror](/guides/mirroring/)
11−deploys nothing while the remote leads it: pushes copied in from the remote
12−don't build, and its **Deployments** page comes with a takeover.
10+click through the change instead of reading a diff.
1311
1412 Apps run on Cloudflare Workers, on `g1t.page`, and a project with a
1513 `Dockerfile` (or a server g1t can write one for) runs as a container on
+3−4
230230 people with the Admin role see a note saying so, with **Protect this
231231 branch**, which starts a [ruleset](/guides/rules/), and **Dismiss**, which
232232 this browser remembers for them and that repository. An archived
233−repository, or a mirror that g1t has not taken over, offers none of these
234−changes.
233+repository offers none of these changes.
235234
236235 From the API, a person's token with `repo:write` can do the same:
237236
342341 ### Pushes of many branches or tags
343342
344343 Every branch and tag in a push is stored. Each one is also announced as a
345−`git.push` event, which starts workflows, mirrors the repository and
346−calls webhooks, except in a push of many:
344+`git.push` event, which starts workflows and calls webhooks, except in a
345+push of many:
347346
348347 | A push of | What is announced |
349348 | --- | --- |
+10−38
11 ---
22 title: GitHub
3−description: Sign in with GitHub, link your account, and import, mirror or move repositories from GitHub through g1t's GitHub App.
3+description: Sign in with GitHub, link your account, and import repositories from GitHub through g1t's GitHub App.
44 ---
55
66 g1t has one GitHub App, [g1t-sh](https://github.com/apps/g1t-sh). It does two
6767 workspace you belong to, as `github.sign_in`, `github.linked` and
6868 `github.unlinked`.
6969
70−## Import, mirror or move a repository
70+## Import a repository
7171
7272 1. Choose **New project**, then **Import from GitHub**. You can also go to
7373 `g1t.sh/new/github`.
8080 [already installed the app on GitHub](#already-installed-the-app-on-github).
8181 4. Tick the repositories to bring across. You see only repositories that
8282 both you and the app can reach.
83−5. Choose how they come across, and whether to copy their issues.
83+5. Choose whether to copy their issues.
8484 6. Choose **Bring to g1t**.
8585
8686 Each repository becomes a repository on g1t with the same name, private if
87−it is private on GitHub, and a [project](/guides/projects/) of its own.
88−
89−| Choice | What happens | Where you push |
90−| --- | --- | --- |
91−| **Import** | Copied once. The g1t repository is then its own. | g1t |
92−| **Standby mirror** | Copied, then every push to GitHub is copied in within seconds. On g1t it's a read-only copy that runs nothing, until you take over. | GitHub |
93−| **Move to g1t** | Copied, then g1t leads: every push to g1t is pushed to GitHub, so people still working there see it. Branches that exist only on GitHub are left alone. | g1t |
94−
95−A standby mirror is a backup you can switch to: if GitHub is down, or
96−whenever you want to work on g1t for a while, **take over** in its
97−**Settings → Mirroring**, and **hand back** when you're done. You can also
98−run its GitHub workflows on g1t while GitHub's don't run, or move it to g1t
99−for good. See [mirroring](/guides/mirroring/).
87+it is private on GitHub, and a [project](/guides/projects/) of its own. It
88+is copied once: the g1t repository is then its own, and you push to g1t.
89+Nothing on GitHub changes.
10090
10191 ### Already installed the app on GitHub?
10292
131121 | Issue numbers | New numbers on g1t; each issue links to the original |
132122 | Comments on issues | No |
133123 | Pull requests | No. Their branches come across; open pull requests stay on GitHub. |
134−| GitHub Actions workflows | Yes, as files. A mirror runs them on g1t in CI failover and when taken over; otherwise rename `.github` to `.g1t` to run them on g1t: see [GitHub Actions](/guides/actions/). |
124+| GitHub Actions workflows | Yes, as files. Rename `.github` to `.g1t` to run them on g1t: see [GitHub Actions](/guides/actions/). |
135125 | Releases, wikis, Git LFS objects | No |
136126
137127 A repository is copied in one piece of at most 40 MB, after compression.
138128 Push a larger one with git instead: see [git](/guides/git/).
139129
140−### Keep a mirror in step
141−
142−The repository's **Settings → Mirroring** shows the link: its state,
143−whether GitHub is answering, and when it last synced. **Sync now** copies
144−at once. **Take over**, **Hand back**, **Move to g1t** and **Remove** are
145−there too: see [mirroring](/guides/mirroring/). A standby mirror stops,
146−keeping its copy, when:
147−
148−- the repository is deleted on GitHub,
149−- the app is uninstalled from its GitHub account, or
150−- a workspace owner removes that GitHub account from the workspace.
151−
152−If GitHub stops letting the app see a repository, its settings say so; add
153−it back to the installation on GitHub to carry on. Renaming or
154−transferring a repository on GitHub keeps the mirror working.
155−
156130 ## What g1t's GitHub App can do
157131
158132 | Permission | Access | Why |
159133 | --- | --- | --- |
160−| Contents | Read and write | Read: clone the repositories you choose. Write: to push for **Move to g1t**, and to hand a takeover back. |
134+| Contents | Read | Clone the repositories you choose. |
161135 | Metadata | Read | Required by GitHub for every app: names, visibility, and whether a branch is protected. |
162136 | Issues | Read | Copy issues when you ask. |
163−| Pull requests | Read and write | When a takeover is handed back, open a pull request for a branch GitHub protects. Without it, g1t pushes the commits to `g1t/handback/<branch>` and tells you to open the pull request yourself. |
164−| Commit statuses | Read and write | While g1t runs a mirror's workflows, report each run and deploy on the commit on GitHub. Without it, the mirror's settings say so and nothing is reported. See [Checks on GitHub](/guides/mirroring/#checks-on-github). |
165137 | Email addresses (account) | Read | Find your verified email when you sign in. |
166138
167139 The app only ever sees the repositories you or your organization's owners
178150 GitHub afterwards, which authorizes g1t again.
179151 - **Stop g1t reading repositories**: uninstall the app in GitHub under
180152 **Settings → Applications → Installed GitHub Apps** (for an organization,
181− its settings). Mirrors stop; the copies on g1t stay.
153+ its settings). Repositories already imported stay on g1t.
182154 - **Change which repositories it sees**: **Choose repositories on GitHub**
183155 beside the account on the import page.
184156
185157 ## The webhook
186158
187−GitHub tells g1t about pushes, installations and repository changes at
159+GitHub tells g1t about installations and repository changes at
188160 `POST https://api.g1t.sh/hooks/github`. g1t checks each delivery's
189161 `X-Hub-Signature-256` against the app's webhook secret, ignores a delivery
190162 id it has already seen (`X-GitHub-Delivery`), and answers `202` before
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…
Loading the diff…