Skip to content

Commit

API and MCP: a call under a workspace alias runs under the workspace

resolve_slug resolves aliases, so /repos/g1t/<repo> and /workspaces/g1t run again under flagon-io, and responses name the workspace by its own slug.

syntaqxcommitted Parent6403011Browse files
2 files+21−50/2 viewed
+4−4
29822982 }
29832983
29842984 /// Runs the operation. One that found nothing, or was refused, under a
2985− /// workspace slug that has since been renamed runs again under the
2986− /// workspace's current slug, and one naming a repository by a path it
2987− /// was transferred away from runs again at its path now; neither
2988− /// outcome changed anything.
2985+ /// workspace slug that has since been renamed, or under an alias staff
2986+ /// set, runs again under the workspace's current slug, and one naming a
2987+ /// repository by a path it was transferred away from runs again at its
2988+ /// path now; neither outcome changed anything.
29892989 pub async fn run(
29902990 self,
29912991 services: &Services,
+17−1
55 //! repository (`owner/name`) or a workspace by a slug the workspace has
66 //! since been renamed from is run again under the slug it has now, so
77 //! scripts and agents written against the old address keep working while
8−//! it redirects.
8+//! it redirects. A workspace alias g1t's staff set (identity's aliases.rs:
9+//! `g1t` for `flagon-io`) resolves the same way, for good, so responses
10+//! name the workspace by its own slug.
911
1012 use g1t_contracts::identity::SlugArgs;
1113 use serde_json::Value;
107109 }
108110
109111 #[test]
112+ fn an_alias_is_run_again_under_its_workspace() {
113+ let input = json!({ "repo": "g1t/g1t", "number": 7 });
114+ assert_eq!(named_slug(&input), Some("g1t"));
115+ assert_eq!(
116+ rewrite(&input, "g1t", "flagon-io"),
117+ json!({ "repo": "flagon-io/g1t", "number": 7 })
118+ );
119+ assert_eq!(
120+ rewrite(&json!({ "workspace": "G1T" }), "g1t", "flagon-io"),
121+ json!({ "workspace": "flagon-io" })
122+ );
123+ }
124+
125+ #[test]
110126 fn rewrites_only_the_old_slug() {
111127 let input = json!({ "repo": "Acme/rocket", "workspace": "acme", "title": "acme/x" });
112128 assert_eq!(