Pick any line to see why it is the way it is: the commit, the pull request and issue it came from, and what the agent was thinking.
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 1 | //! A workspace renamed: rows kept under its old slug move to the one it |
| 2 | //! has now. See `g1t_kit::rename`. | |
| 3 | ||
| 4 | /// `?1` is the current slug, `?2` a stale one. | |
| 5 | pub const STATEMENTS: &[&str] = &[ | |
| 6 | "UPDATE settings SET owner = ?1 WHERE scope = 'workspace' AND owner = ?2", | |
| 7 | "UPDATE jobs SET namespace = ?1 WHERE namespace = ?2", | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 8 | "UPDATE cache_entries SET namespace = ?1 WHERE namespace = ?2", |
| 9 | "UPDATE cache_days SET namespace = ?1 WHERE namespace = ?2", | |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 10 | "UPDATE workflows SET repo = ?1 || substr(repo, length(?2) + 1) WHERE substr(repo, 1, length(?2) + 1) = ?2 || '/'", |
| 11 | "UPDATE runs SET repo = ?1 || substr(repo, length(?2) + 1) WHERE substr(repo, 1, length(?2) + 1) = ?2 || '/'", | |
| 12 | ]; | |
| 13 | ||
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 14 | /// A repository renamed or transferred (see `g1t_kit::transfer`): its |
| 15 | /// workflows, its runs and their jobs go with it. Its own secrets and | |
| 16 | /// variables are kept by its id (or its project's), so they go with it | |
| 17 | /// too; the old workspace's stop reaching it. A workspace's rows name the | |
| 18 | /// projects they reach by slug, not repositories, so a rename leaves them. | |
| 19 | pub const TRANSFERRED: &[&str] = &[ | |
| 20 | "UPDATE workflows SET repo = ?1 WHERE repo_id = ?5 AND repo = ?2", | |
| 21 | "UPDATE runs SET repo = ?1 WHERE repo_id = ?5 AND repo = ?2", | |
| 22 | "UPDATE jobs SET namespace = ?3 WHERE repo_id = ?5 AND namespace = ?4", | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 23 | "UPDATE cache_entries SET namespace = ?3 WHERE repo_id = ?5 AND namespace = ?4", |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 24 | ]; |
| 25 | ||
| 26 | /// A repository purged (see `g1t_kit::lifecycle`): its workflows, runs, | |
| 27 | /// jobs and their logs go, and secrets and variables still kept under its | |
| 28 | /// id (from before projects held them). `?1` its id. A project's own rows | |
| 29 | /// stay with the project. | |
| 30 | pub const PURGED: &[&str] = &[ | |
| 31 | "DELETE FROM logs WHERE job_id IN (SELECT id FROM jobs WHERE repo_id = ?1)", | |
| 32 | "DELETE FROM jobs WHERE repo_id = ?1", | |
| 33 | "DELETE FROM runs WHERE repo_id = ?1", | |
| 34 | "DELETE FROM workflows WHERE repo_id = ?1", | |
| 35 | "DELETE FROM synced WHERE repo_id = ?1", | |
| 36 | "DELETE FROM settings WHERE scope <> 'workspace' AND owner = ?1", | |
| Fast pages, required checks on the branch, self-hosted runners, honest incidents | 37 | // Its cache's objects are deleted from R2 by the next sweep, then the rows. |
| 38 | "UPDATE cache_entries SET status = 'expired' WHERE repo_id = ?1", | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 39 | ]; |
| 40 | ||
| 41 | /// A workspace deleted: its own secrets and variables go. `?1` its slug. | |
| 42 | pub const DELETED: &[&str] = &["DELETE FROM settings WHERE scope = 'workspace' AND owner = ?1"]; | |
| 43 | ||
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 44 | #[cfg(test)] |
| 45 | mod tests { | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 46 | use super::{DELETED, PURGED, STATEMENTS, TRANSFERRED}; |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 47 | |
| 48 | #[test] | |
| 49 | fn every_statement_takes_the_two_slugs() { | |
| 50 | for sql in STATEMENTS { | |
| 51 | assert_eq!(g1t_kit::rename::parameters(sql), 2, "{sql}"); | |
| 52 | } | |
| 53 | } | |
| Invite-only launch: sign in with GitHub, repository access and lifecycle, many emails, a new look | 54 | |
| 55 | #[test] | |
| 56 | fn transfer_and_deletion_statements_take_what_they_name() { | |
| 57 | for sql in TRANSFERRED { | |
| 58 | assert!((1..=5).contains(&g1t_kit::transfer::parameters(sql)), "{sql}"); | |
| 59 | } | |
| 60 | for sql in DELETED { | |
| 61 | assert_eq!(g1t_kit::rename::parameters(sql), 1, "{sql}"); | |
| 62 | } | |
| 63 | for sql in PURGED { | |
| 64 | assert_eq!(g1t_kit::transfer::parameters(sql), 1, "{sql}"); | |
| 65 | } | |
| 66 | } | |
| Agents and memory, checks and conflicts, profiles, slug renames, custom domains | 67 | } |