xonecas.io
8447
Co

conveyor / commit a8f8765

Tickets start from and land on the branch you have checked out, and their work stays out of your branches

A ticket's work now lives in refs/conveyor/t-<id> rather than a t-<id> branch, so git branch,
git push --all and clones never see it. A code ticket's stack starts from the checked-out
branch, not main, and Done merges into that branch (a detached HEAD is refused). Merges
conveyor makes in the repo are titled with the ticket's title. The template's ticket and
branch widgets read the new ref.

Co-Authored-By: Claude Opus 5.5

conveyor2026-11-17 a8f8765b3959d97ede67524b9ab1369625124355 parent 4a00b12

8 files changed

crates/conveyor/src/agent.rs+20−14
@@ -1,5 +1,6 @@
11 //! Works one ticket: boots its VM, hands the agent the repo on the ticket's branch, runs the
2-//! agent headless with the verbs forwarded in, fetches the branch back and settles the state.
2+//! agent headless with the verbs forwarded in, fetches the branch back into the ticket's ref
3+//! (`store::branch`) and settles the state.
34 use crate::{library, store::{self, Project}, verbs::{Listener, Outcome}, vm::{self, Vm}};
45 use serde_json::json;
56 use std::{fs::File, io::Write, path::Path, process::{Command, Stdio}};
@@ -20,7 +21,8 @@ pub fn work(p: Project, id: u32) {
2021
2122 fn run(p: &Project, id: u32) -> Result<String, String> {
2223 let t = store::ticket(&p.slug, id).ok_or("no ticket")?;
23- let (name, branch) = (format!("{}-{id}", p.slug), format!("t-{id}"));
24+ // The guest's branch; on the host, the work is kept in `store::branch`, out of the user's branches.
25+ let (name, branch, kept) = (format!("{}-{id}", p.slug), format!("t-{id}"), store::branch(id));
2426 let note = |msg: &str| store::event(&p.slug, id, json!({"kind": "conveyor", "msg": msg}));
2527
2628 note("booting VM");
@@ -37,12 +39,13 @@ fn run(p: &Project, id: u32) -> Result<String, String> {
3739 && git config user.name conveyor && git config user.email conveyor@localhost", b"")?;
3840 let (url, git_ssh) = vm.git_remote("/home/sacenox/work");
3941 // A widget build starts from what the user sees: the library with every build on trial.
40- // A code ticket starts from main plus every branch in review: the stack.
42+ // A code ticket starts from the user's checked-out branch plus every ticket in review: the
43+ // stack. Either way, the guest calls it main.
4144 let base = if p.library { library::BASE.into() } else { format!("{}:refs/heads/main", stack(p, id)?) };
4245 git(&p.path, &git_ssh, &["push", "-q", &url, &base])?;
4346 // A ticket that ran before (it failed, or was parked) picks up its own branch.
44- let resumed = git(&p.path, "", &["rev-parse", "-q", "--verify", &branch]).is_ok();
45- if resumed { git(&p.path, &git_ssh, &["push", "-q", &url, &format!("{branch}:{branch}")])?; }
47+ let resumed = git(&p.path, "", &["rev-parse", "-q", "--verify", &kept]).is_ok();
48+ if resumed { git(&p.path, &git_ssh, &["push", "-q", &url, &format!("{kept}:refs/heads/{branch}")])?; }
4649 vm.sh(&format!("cd ~/work && git switch -q{} {branch}", if resumed { "" } else { "c" }), b"")?;
4750 let files = give_files(&vm, p, id)?;
4851
@@ -70,12 +73,12 @@ fn run(p: &Project, id: u32) -> Result<String, String> {
7073 note(&format!("agent exited {}: {}", out.status, String::from_utf8_lossy(&out.stderr).trim()));
7174 }
7275
73- git(&p.path, &git_ssh, &["fetch", "-q", &url, &format!("+{branch}:{branch}")])?;
76+ git(&p.path, &git_ssh, &["fetch", "-q", &url, &format!("+refs/heads/{branch}:{kept}")])?;
7477 drop(vm);
7578 Ok(match outcome {
7679 Outcome::Blocked => "parked".into(),
7780 Outcome::None => "failed".into(),
78- Outcome::Done(_) if p.library => { library::try_out(p, id, &branch)?; "review".into() }
81+ Outcome::Done(_) if p.library => { library::try_out(p, id, &kept)?; "review".into() }
7982 Outcome::Done(_) => "review".into(),
8083 })
8184 }
@@ -90,9 +93,10 @@ pub(crate) fn merges_onto(p: &Project, id: u32, url: &str, git_ssh: &str, branch
9093 // finish together can't both pass without seeing each other.
9194 static ONE: std::sync::Mutex<()> = std::sync::Mutex::new(());
9295 let _one = ONE.lock().unwrap_or_else(|e| e.into_inner());
93- git(&p.path, &git_ssh, &["fetch", "-q", &url, &format!("+{branch}:{branch}")])?;
96+ let kept = store::branch(id);
97+ git(&p.path, &git_ssh, &["fetch", "-q", &url, &format!("+refs/heads/{branch}:{kept}")])?;
9498 let (onto, name) = if p.library { ("trial".into(), "trial") } else { (stack(&p, id)?, "main") };
95- let Err(files) = library::merges(&p.path, &onto, &branch) else {
99+ let Err(files) = library::merges(&p.path, &onto, &kept) else {
96100 store::event(&p.slug, id, json!({"kind": "conveyor", "msg": "done: it merges onto the work in review", "checked": true}));
97101 return Ok(());
98102 };
@@ -102,13 +106,15 @@ pub(crate) fn merges_onto(p: &Project, id: u32, url: &str, git_ssh: &str, branch
102106 }
103107 }
104108
105-/// A code ticket's stack: main plus the branches of the project's other tickets in review, or
106-/// running with `done` passed.
109+/// A code ticket's stack: the user's checked-out branch plus the work of the project's other
110+/// tickets in review, or running with `done` passed.
107111 fn stack(p: &Project, id: u32) -> Result<String, String> {
108- let branches: Vec<String> = store::tickets(&p.slug).iter()
112+ let tickets = store::tickets(&p.slug);
113+ let on: Vec<(u32, &str)> = tickets.iter()
109114 .filter(|t| t.id != id && (t.state == "review" || t.state == "running" && checked(&p.slug, t.id)))
110- .map(|t| format!("t-{}", t.id)).filter(|b| git(&p.path, "", &["rev-parse", "-q", "--verify", b]).is_ok()).collect();
111- crate::land::stack(&p.path, &branches)
115+ .filter(|t| git(&p.path, "", &["rev-parse", "-q", "--verify", &store::branch(t.id)]).is_ok())
116+ .map(|t| (t.id, t.title.as_str())).collect();
117+ crate::land::stack(&p.path, &on)
112118 }
113119
114120 /// Whether this run of the ticket passed its `done` check.
crates/conveyor/src/land.rs+88−73
@@ -1,13 +1,17 @@
1-//! A code project's branches, as the widget library's trial does it: a ticket starts from main
2-//! plus every branch in review, and landing it merges into main what it was built on too.
3-use crate::{agent::git, library::merges};
1+//! A code project's tickets, as the widget library's trial does it: a ticket starts from the
2+//! user's checked-out branch plus every ticket in review, and landing it merges into the branch
3+//! checked out then what it was built on too. Each ticket's work is `store::branch`, never a
4+//! branch of the user's, so their branches and pushes stay their own.
5+use crate::{agent::git, library::merges, store::branch};
46 use std::path::Path;
57
6-/// What a code ticket starts from: main with `branches` (those in review, oldest first) merged
7-/// in, as one commit no branch points to. A branch that conflicts with those before it is left out.
8-pub fn stack(repo: &Path, branches: &[String]) -> Result<String, String> {
9- let mut head = git(repo, "", &["rev-parse", "main"])?.trim().to_owned();
10- for b in branches {
8+/// What a code ticket starts from: the checked-out commit with `tickets` (those in review,
9+/// oldest first, as id and title) merged in, as one commit no branch points to. Each merge is
10+/// titled as its ticket. A ticket that conflicts with those before it is left out.
11+pub fn stack(repo: &Path, tickets: &[(u32, &str)]) -> Result<String, String> {
12+ let mut head = git(repo, "", &["rev-parse", "HEAD"])?.trim().to_owned();
13+ for (id, title) in tickets {
14+ let b = &branch(*id);
1115 if git(repo, "", &["merge-base", "--is-ancestor", b, &head]).is_ok() { continue; }
1216 if git(repo, "", &["merge-base", "--is-ancestor", &head, b]).is_ok() {
1317 head = git(repo, "", &["rev-parse", b])?.trim().to_owned();
@@ -15,28 +19,28 @@ pub fn stack(repo: &Path, branches: &[String]) -> Result<String, String> {
1519 }
1620 let Ok(tree) = git(repo, "", &["merge-tree", "--write-tree", "--no-messages", &head, b]) else { continue };
1721 head = git(repo, "", &["-c", "user.name=conveyor", "-c", "user.email=conveyor@localhost", "commit-tree", tree.trim(),
18- "-p", &head, "-p", b, "-m", &format!("Merge branch '{b}'")])?.trim().to_owned();
22+ "-p", &head, "-p", b, "-m", title])?.trim().to_owned();
1923 }
2024 Ok(head)
2125 }
2226
23-/// Merges `branch` into `repo`'s main and deletes it. Leaves everything as it was, and says
24-/// why, when it conflicts with main or git won't touch the user's checkout.
25-pub fn land(repo: &Path, branch: &str) -> Result<(), String> {
26- merges(repo, "main", branch).map_err(|files| format!(
27- "{branch} conflicts with main in {files}. Move it to ready to have the agent merge main, or merge it yourself."))?;
28- let head = git(repo, "", &["symbolic-ref", "-q", "--short", "HEAD"]).unwrap_or_default();
29- if head.trim() == "main" {
30- // The user's checkout: git refuses to overwrite their uncommitted changes, and says so.
31- // It can't conflict (checked above), so there's never a merge of ours to abort.
32- git(repo, "", &["merge", "-q", "--no-edit", branch])
33- } else {
34- // main isn't checked out, so there's no worktree to merge in: fast-forward only.
35- git(repo, "", &["fetch", "-q", ".", &format!("{branch}:main")])
36- .map_err(|_| format!("{branch} doesn't fast-forward main, and main isn't checked out. Check out main, then move it to done again."))
37- }?;
38- // In main now, which may not be HEAD, so -d would refuse.
39- git(repo, "", &["branch", "-D", branch]).map(|_| ())
27+/// Merges ticket `id`'s work into the branch checked out in `repo`, a merge commit titled
28+/// `title` if it takes one, and deletes its ref. Says which branch it went into. Leaves
29+/// everything as it was, and says why, when no branch is checked out, it conflicts with it, or
30+/// git won't touch the user's checkout.
31+pub fn land(repo: &Path, id: u32, title: &str) -> Result<String, String> {
32+ let onto = git(repo, "", &["symbolic-ref", "-q", "--short", "HEAD"])
33+ .map_err(|_| "no branch is checked out to merge it into. Check one out, then move it to done again.".to_string())?;
34+ let (onto, b) = (onto.trim().to_owned(), branch(id));
35+ merges(repo, "HEAD", &b).map_err(|files| format!(
36+ "it conflicts with {onto} in {files}. Move it to ready to have the agent merge {onto}, or merge it yourself."))?;
37+ // git refuses to overwrite the user's uncommitted changes, and says so. It can't conflict
38+ // (checked above), and an empty title would leave it half done, so there's never a merge
39+ // of ours to abort.
40+ let title = if title.trim().is_empty() { format!("Ticket {id}") } else { title.into() };
41+ git(repo, "", &["merge", "-q", "-m", &title, &b])?;
42+ git(repo, "", &["update-ref", "-d", &b])?;
43+ Ok(onto)
4044 }
4145
4246 #[cfg(test)]
@@ -53,6 +57,20 @@ mod tests {
5357 run(repo, &["commit", "-qm", file]);
5458 }
5559
60+ /// Ticket `id`'s work, as its agent leaves it: `text` in `file`, on top of `from`. The
61+ /// checkout stays on its branch.
62+ fn work(repo: &Path, id: u32, from: &str, file: &str, text: &str) {
63+ let head = run(repo, &["symbolic-ref", "--short", "HEAD"]);
64+ run(repo, &["switch", "-q", "--detach", from]);
65+ commit(repo, file, text);
66+ run(repo, &["update-ref", &branch(id), "HEAD"]);
67+ run(repo, &["switch", "-q", head.trim()]);
68+ }
69+
70+ fn subject(repo: &Path, rev: &str) -> String {
71+ run(repo, &["log", "-1", "--format=%s", rev]).trim().to_owned()
72+ }
73+
5674 #[test]
5775 fn land_edges() {
5876 let repo = std::env::temp_dir().join(format!("conveyor-land-{}", std::process::id()));
@@ -63,74 +81,71 @@ mod tests {
6381 run(&repo, &["config", "user.email", "t@t"]);
6482 commit(&repo, "a", "1\n");
6583
66- // A fast-forward lands in the checkout and drops the branch; untracked files stay.
67- run(&repo, &["switch", "-qc", "t-1"]);
68- commit(&repo, "b", "b\n");
69- run(&repo, &["switch", "-q", "main"]);
84+ // A fast-forward lands in the checkout and drops the ref; untracked files stay. No
85+ // branch of the user's ever named the ticket.
86+ work(&repo, 1, "main", "b", "b\n");
7087 std::fs::write(repo.join("idea.md"), "mine").unwrap();
71- land(&repo, "t-1").unwrap();
88+ assert_eq!(run(&repo, &["branch", "--format=%(refname:short)"]).trim(), "main");
89+ assert_eq!(land(&repo, 1, "One").unwrap(), "main");
7290 assert!(repo.join("b").exists() && repo.join("idea.md").exists());
73- assert!(git(&repo, "", &["rev-parse", "-q", "--verify", "t-1"]).is_err());
91+ assert!(git(&repo, "", &["rev-parse", "-q", "--verify", &branch(1)]).is_err());
7492
75- // The stack: main, then t-a, then t-b built on t-a (no merge needed), and t-c, which
76- // conflicts with t-a and is left out. A ticket built on it lands all it was built on.
77- for (b, from, file, text) in [("t-a", "main", "x", "a\n"), ("t-b", "t-a", "y", "b\n"), ("t-c", "main", "x", "c\n")] {
78- run(&repo, &["switch", "-qc", b, from]);
79- commit(&repo, file, text);
93+ // The stack: the checkout, then 10, then 11 built on 10 (no merge needed), and 12, which
94+ // conflicts with 10 and is left out. A ticket built on it lands all it was built on.
95+ for (id, from, file, text) in [(10, "main".into(), "x", "a\n"), (11, branch(10), "y", "b\n"), (12, "main".into(), "x", "c\n")] {
96+ work(&repo, id, &from, file, text);
8097 }
81- run(&repo, &["switch", "-q", "main"]);
8298 commit(&repo, "z", "z\n");
83- let names = |v: &[&str]| v.iter().map(|s| s.to_string()).collect::<Vec<_>>();
84- let top = stack(&repo, &names(&["t-a", "t-b", "t-c"])).unwrap();
99+ let top = stack(&repo, &[(10, "Ten"), (11, "Eleven"), (12, "Twelve")]).unwrap();
85100 let files = run(&repo, &["ls-tree", "--name-only", &top]);
86101 assert!(files.contains('y') && files.contains('z') && run(&repo, &["show", &format!("{top}:x")]) == "a\n");
87- run(&repo, &["switch", "-qc", "t-d", &top]);
88- commit(&repo, "w", "w\n");
89- run(&repo, &["switch", "-q", "main"]);
90- land(&repo, "t-d").unwrap();
91- assert!(git(&repo, "", &["merge-base", "--is-ancestor", "t-b", "main"]).is_ok());
92- assert_eq!(stack(&repo, &names(&["t-a", "t-b"])).unwrap(), run(&repo, &["rev-parse", "main"]).trim());
93- run(&repo, &["branch", "-qD", "t-a", "t-b", "t-c"]);
102+ assert_eq!(subject(&repo, &format!("{top}^")), "Ten");
103+ work(&repo, 13, &top, "w", "w\n");
104+ land(&repo, 13, "Thirteen").unwrap();
105+ assert!(git(&repo, "", &["merge-base", "--is-ancestor", &branch(11), "main"]).is_ok());
106+ assert_eq!(stack(&repo, &[(10, "Ten"), (11, "Eleven")]).unwrap(), run(&repo, &["rev-parse", "main"]).trim());
107+ for id in [10, 11, 12] { run(&repo, &["update-ref", "-d", &branch(id)]); }
94108
95- // main moved meanwhile: a real merge.
96- run(&repo, &["switch", "-qc", "t-2"]);
97- commit(&repo, "c", "c\n");
98- run(&repo, &["switch", "-q", "main"]);
109+ // main moved meanwhile: a real merge, titled as the ticket.
110+ work(&repo, 2, "main", "c", "c\n");
99111 commit(&repo, "d", "d\n");
100- land(&repo, "t-2").unwrap();
112+ land(&repo, 2, "Two").unwrap();
101113 assert!(repo.join("c").exists() && repo.join("d").exists());
114+ assert_eq!(subject(&repo, "main"), "Two");
115+ work(&repo, 6, "main^", "g", "g\n");
116+ land(&repo, 6, " ").unwrap();
117+ assert_eq!(subject(&repo, "main"), "Ticket 6");
102118
103- // A conflict leaves main, the checkout and the branch alone.
104- run(&repo, &["switch", "-qc", "t-3"]);
105- commit(&repo, "a", "3\n");
106- run(&repo, &["switch", "-q", "main"]);
119+ // A conflict leaves the branch, the checkout and the ticket's ref alone.
120+ work(&repo, 3, "main", "a", "3\n");
107121 commit(&repo, "a", "main\n");
108122 let before = run(&repo, &["rev-parse", "main"]);
109- assert!(land(&repo, "t-3").unwrap_err().contains("conflicts with main in a"));
123+ assert!(land(&repo, 3, "Three").unwrap_err().contains("conflicts with main in a"));
110124 assert_eq!(run(&repo, &["rev-parse", "main"]), before);
125+ assert!(git(&repo, "", &["rev-parse", "-q", "--verify", &branch(3)]).is_ok());
111126 assert!(run(&repo, &["status", "--porcelain"]).lines().all(|l| l.starts_with("??")));
112127
113- // A file in the checkout the branch would overwrite: git refuses, nothing moves.
114- run(&repo, &["switch", "-qc", "t-4"]);
115- commit(&repo, "e", "e\n");
116- run(&repo, &["switch", "-q", "main"]);
128+ // A file in the checkout the work would overwrite: git refuses, nothing moves.
129+ work(&repo, 4, "main", "e", "e\n");
117130 std::fs::write(repo.join("e"), "dirty").unwrap();
118- let before = run(&repo, &["rev-parse", "main"]);
119- assert!(land(&repo, "t-4").is_err());
131+ assert!(land(&repo, 4, "Four").is_err());
120132 assert_eq!(run(&repo, &["rev-parse", "main"]), before);
121133 assert_eq!(std::fs::read_to_string(repo.join("e")).unwrap(), "dirty");
122134 std::fs::remove_file(repo.join("e")).unwrap();
123135
124- // main not checked out: a fast-forward lands, a real merge is refused.
125- run(&repo, &["switch", "-qc", "other"]);
126- land(&repo, "t-4").unwrap();
127- assert!(run(&repo, &["ls-tree", "--name-only", "main"]).contains('e'));
128- run(&repo, &["switch", "-qc", "t-5", "main"]);
129- commit(&repo, "f", "f\n");
130- run(&repo, &["switch", "-q", "main"]);
131- commit(&repo, "g", "g\n");
132- run(&repo, &["switch", "-q", "other"]);
133- assert!(land(&repo, "t-5").unwrap_err().contains("isn't checked out"));
136+ // Another branch checked out: tickets start from it, and land on it, not on main.
137+ run(&repo, &["switch", "-qc", "feature"]);
138+ commit(&repo, "h", "h\n");
139+ assert_eq!(stack(&repo, &[]).unwrap(), run(&repo, &["rev-parse", "feature"]).trim());
140+ assert_eq!(land(&repo, 4, "Four").unwrap(), "feature");
141+ let has_e = |rev| run(&repo, &["ls-tree", "--name-only", rev]).lines().any(|f| f == "e");
142+ assert!(has_e("feature") && !has_e("main"));
143+
144+ // No branch checked out: refused, the ref kept.
145+ work(&repo, 5, "main", "f", "f\n");
146+ run(&repo, &["switch", "-q", "--detach"]);
147+ assert!(land(&repo, 5, "Five").unwrap_err().contains("no branch is checked out"));
148+ assert!(git(&repo, "", &["rev-parse", "-q", "--verify", &branch(5)]).is_ok());
134149 let _ = std::fs::remove_dir_all(&repo);
135150 }
136151 }
crates/conveyor/src/library.rs+6−6
@@ -144,12 +144,12 @@ pub fn merges(repo: &Path, onto: &str, branch: &str) -> Result<(), String> {
144144 pub fn keep(id: u32) -> Result<(), String> {
145145 store::ticket(SLUG, id).filter(|t| t.state == "review").ok_or("that build isn't on trial")?;
146146 let lib = paths::library();
147- if let Err(e) = git(&lib, "", &[&COMMIT[..], &["merge", "-q", "--no-edit", &format!("t-{id}")]].concat()) {
147+ if let Err(e) = git(&lib, "", &[&COMMIT[..], &["merge", "-q", "--no-edit", &store::branch(id)]].concat()) {
148148 let _ = git(&lib, "", &["merge", "--abort"]);
149149 return Err(e);
150150 }
151- // Merged: main has it, so the branch is only clutter.
152- let _ = git(&lib, "", &["branch", "-d", &format!("t-{id}")]);
151+ // Merged: main has it, so the ref is only clutter.
152+ let _ = git(&lib, "", &["update-ref", "-d", &store::branch(id)]);
153153 store::set_state(SLUG, id, "done");
154154 store::event(SLUG, id, json!({"kind": "conveyor", "msg": "kept: merged into the library"}));
155155 trial(None)
@@ -161,7 +161,7 @@ pub fn discard(id: u32) -> Result<(), String> {
161161 store::set_state(SLUG, id, "draft");
162162 store::event(SLUG, id, json!({"kind": "conveyor", "msg": "discarded: back to draft"}));
163163 // Ready builds it again from scratch, not from the discarded attempt.
164- let _ = git(&paths::library(), "", &["branch", "-D", &format!("t-{id}")]);
164+ let _ = git(&paths::library(), "", &["update-ref", "-d", &store::branch(id)]);
165165 trial(None)
166166 }
167167
@@ -175,9 +175,9 @@ fn trial(fresh: Option<u32>) -> Result<(), String> {
175175 git(&dir, "", &["reset", "-q", "--hard", "main"])?;
176176 let ids: Vec<u32> = store::tickets(SLUG).iter().filter(|t| t.state == "review").map(|t| t.id).chain(fresh).collect();
177177 for id in ids {
178- if let Err(e) = git(&dir, "", &[&COMMIT[..], &["merge", "-q", "--no-edit", &format!("t-{id}")]].concat()) {
178+ if let Err(e) = git(&dir, "", &[&COMMIT[..], &["merge", "-q", "--no-edit", &store::branch(id)]].concat()) {
179179 let _ = git(&dir, "", &["merge", "--abort"]);
180- let why = match merges(&lib, "main", &format!("t-{id}")) {
180+ let why = match merges(&lib, "main", &store::branch(id)) {
181181 Err(files) => format!("it conflicts with builds you kept since it started, in {files}; Ctrl+click to have it merged"),
182182 Ok(()) => format!("it conflicts with the builds on trial before it; keep or discard those first\n{e}"),
183183 };
crates/conveyor/src/library_tests.rs+8−5
@@ -21,14 +21,15 @@ fn state(id: u32) -> String {
2121 store::ticket(SLUG, id).unwrap().state
2222 }
2323
24-/// A build ticket whose agent wrote `text` to widgets/`file` on branch t-<id>, from `from`.
24+/// A build ticket whose agent wrote `text` to widgets/`file` from `from`, fetched back into its ref.
2525 fn build(from: &str, file: &str, text: &str) -> (u32, String) {
2626 let id = store::create(SLUG, file, "", "running");
27- let (lib, w, branch) = (paths::library(), paths::data().join("author"), format!("t-{id}"));
28- run(&lib, &["worktree", "add", "-q", "-B", &branch, &w.to_string_lossy(), from]);
27+ let (lib, w, branch) = (paths::library(), paths::data().join("author"), store::branch(id));
28+ run(&lib, &["worktree", "add", "-q", "--detach", &w.to_string_lossy(), from]);
2929 fs::write(w.join("widgets").join(file), text).unwrap();
3030 run(&w, &["add", "-A"]);
3131 run(&w, &["commit", "-qm", file]);
32+ run(&w, &["update-ref", &branch, "HEAD"]);
3233 run(&lib, &["worktree", "remove", "--force", &w.to_string_lossy()]);
3334 (id, branch)
3435 }
@@ -78,8 +79,10 @@ fn trial_edges() {
7879 // merge, and passes once it has.
7980 assert!(try_out(&p, c, &branch_c).unwrap_err().contains("kept since it started"));
8081 let guest = paths::data().join("guest");
81- run(&paths::library(), &["clone", "-q", "-b", &branch_c, &paths::library().to_string_lossy(), &guest.to_string_lossy()]);
82- let check = crate::agent::merges_onto(&p, c, &guest.to_string_lossy(), "", &branch_c);
82+ run(&paths::library(), &["clone", "-q", &paths::library().to_string_lossy(), &guest.to_string_lossy()]);
83+ run(&guest, &["fetch", "-q", "origin", &format!("{branch_c}:refs/heads/t-{c}")]);
84+ run(&guest, &["switch", "-q", &format!("t-{c}")]);
85+ let check = crate::agent::merges_onto(&p, c, &guest.to_string_lossy(), "", &format!("t-{c}"));
8386 assert!(check().unwrap_err().contains("widgets/root.rs"));
8487 assert!(git(&guest, "", &[&COMMIT[..], &["merge", "-q", "trial"]].concat()).is_err());
8588 fs::write(guest.join("widgets/root.rs"), format!("{main_root}// b\n// c\n")).unwrap();
crates/conveyor/src/server.rs+9−9
@@ -62,21 +62,21 @@ fn set(project: &str, id: u32, state: &str) -> Result<Value, String> {
6262 return Err("running belongs to conveyor: move a ticket to ready to start it".into());
6363 }
6464 if !["draft", "ready", "review", "parked", "failed", "done"].contains(&state) { return Err(format!("no state {state}")); }
65- // Done from review lands the work: Keep for a widget build, a merge into main for code.
65+ // Done from review lands the work: Keep for a widget build, a merge into the user's
66+ // checked-out branch for code.
6667 if t.state == "review" && state == "done" {
6768 let p = store::project(project).ok_or("no such project")?;
6869 if p.library { return library::keep(id).map(|_| json!({"ok": true})); }
69- let branch = format!("t-{id}");
70- if crate::agent::git(&p.path, "", &["rev-parse", "-q", "--verify", &branch]).is_ok() {
71- crate::land::land(&p.path, &branch).inspect_err(|e| store::event(project, id, json!({"kind": "error", "msg": e})))?;
72- store::event(project, id, json!({"kind": "conveyor", "msg": format!("merged into main: {branch} is gone")}));
70+ if crate::agent::git(&p.path, "", &["rev-parse", "-q", "--verify", &store::branch(id)]).is_ok() {
71+ let onto = crate::land::land(&p.path, id, &t.title).inspect_err(|e| store::event(project, id, json!({"kind": "error", "msg": e})))?;
72+ store::event(project, id, json!({"kind": "conveyor", "msg": format!("merged into {onto}")}));
7373 // It was built on the others in review: those it carried in are done too.
7474 for o in store::tickets(project).into_iter().filter(|o| o.state == "review" && o.id != id) {
75- let b = format!("t-{}", o.id);
76- if crate::agent::git(&p.path, "", &["merge-base", "--is-ancestor", &b, "main"]).is_err() { continue; }
77- let _ = crate::agent::git(&p.path, "", &["branch", "-D", &b]);
75+ let b = store::branch(o.id);
76+ if crate::agent::git(&p.path, "", &["merge-base", "--is-ancestor", &b, "HEAD"]).is_err() { continue; }
77+ let _ = crate::agent::git(&p.path, "", &["update-ref", "-d", &b]);
7878 store::set_state(project, o.id, "done");
79- store::event(project, o.id, json!({"kind": "conveyor", "msg": format!("merged into main with #{id}: {b} is gone")}));
79+ store::event(project, o.id, json!({"kind": "conveyor", "msg": format!("merged into {onto} with #{id}")}));
8080 }
8181 }
8282 }
crates/conveyor/src/store.rs+6−0
@@ -66,6 +66,12 @@ pub fn with_context(words: &str, context: &str) -> String {
6666 if context.is_empty() { words.into() } else { format!("{}{RULE}{context}", words.trim_end()) }
6767 }
6868
69+/// Where a ticket's work is kept in its project's repo: a ref outside refs/heads, so it's no
70+/// branch of the user's, and no push or clone carries it.
71+pub fn branch(id: u32) -> String {
72+ format!("refs/conveyor/t-{id}")
73+}
74+
6975 pub fn dir(project: &str, id: u32) -> PathBuf {
7076 paths::projects().join(project).join("tickets").join(id.to_string())
7177 }
templates/library/widgets/branch.rs+2−2
@@ -1,4 +1,4 @@
1-//! A ticket's branch (`t-<id>`) of a project's repo as a folder to browse: the files at its tip
1+//! A ticket's branch (`refs/conveyor/t-<id>`) of a project's repo as a folder to browse: the files at its tip
22 //! (`git archive`), extracted again when the tip moves, and the files it changes against HEAD.
33 //! The repo and its checkout are left alone.
44 use std::{collections::BTreeSet, path::{Path, PathBuf}, process::{Command, Stdio}, sync::{Arc, Mutex}};
@@ -31,7 +31,7 @@ impl Snapshot {
3131 if s.rev != self.seen { self.seen = s.rev.clone(); return true }
3232 if s.busy || now - self.checked < EVERY { return false }
3333 (self.checked, s.busy) = (now, true);
34- let (state, repo, tree, branch) = (self.state.clone(), repo.to_owned(), self.tree.clone(), format!("t-{}", self.ticket));
34+ let (state, repo, tree, branch) = (self.state.clone(), repo.to_owned(), self.tree.clone(), format!("refs/conveyor/t-{}", self.ticket));
3535 std::thread::spawn(move || {
3636 let had = state.lock().unwrap().rev.clone();
3737 let r = refresh(&repo, &branch, &tree, &had);
templates/library/widgets/ticket.rs+2−2
@@ -66,7 +66,7 @@ impl View for TicketCard {
6666 let Some(k) = k else { return };
6767 if k.state == "review" && self.diff_for != k.since {
6868 self.diff_for = k.since;
69- let (out, path, branch) = (self.diff.clone(), cx.data.projects.iter().find(|p| p.slug == k.project).map(|p| p.path.clone()).unwrap_or_default(), format!("HEAD...t-{}", k.id));
69+ let (out, path, branch) = (self.diff.clone(), cx.data.projects.iter().find(|p| p.slug == k.project).map(|p| p.path.clone()).unwrap_or_default(), format!("HEAD...refs/conveyor/t-{}", k.id));
7070 *out.lock().unwrap() = None;
7171 std::thread::spawn(move || {
7272 let r = std::process::Command::new("git").args(["diff", "--stat", &branch]).current_dir(&path).output();
@@ -211,7 +211,7 @@ fn explore(cx: &Cx, ticket: u32) -> El {
211211 ui::button(&look::of(cx), "explore", "Explore in editor", true, move |h: &mut HostState, _: &mut Tx| {
212212 let Some((parent, key)) = id.rsplit_once('.') else { return };
213213 if let Some(c) = get::<canvas::Canvas>(h, parent) { c.open_beside("editor", &format!("branch-{ticket}"), super::editor::WIDGET.size, key) }
214- }).help(format!("Browse branch t-{ticket} read-only, its changed files lit"))
214+ }).help(format!("Browse #{ticket}'s work read-only, its changed files lit"))
215215 }
216216
217217 /// Opens the system's file dialog and attaches the chosen file to the new ticket.