Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
31702e03e3 |
@@ -102,11 +102,6 @@ pub struct SpawnArgs {
|
|||||||
/// there.
|
/// there.
|
||||||
#[arg(long)]
|
#[arg(long)]
|
||||||
pub existing_branch: bool,
|
pub existing_branch: bool,
|
||||||
/// Remove the worktree when the session is killed. Kept for wire
|
|
||||||
/// compatibility (#56): the daemon now always cleans up on kill, guarded
|
|
||||||
/// against unsaved work.
|
|
||||||
#[arg(long, default_value_t = true)]
|
|
||||||
pub cleanup_on_kill: bool,
|
|
||||||
/// After spawning, attach immediately.
|
/// After spawning, attach immediately.
|
||||||
#[arg(long, short = 'a')]
|
#[arg(long, short = 'a')]
|
||||||
pub attach: bool,
|
pub attach: bool,
|
||||||
@@ -168,7 +163,6 @@ mod tests {
|
|||||||
"/repos/foo",
|
"/repos/foo",
|
||||||
"--branch",
|
"--branch",
|
||||||
"feat/x",
|
"feat/x",
|
||||||
"--cleanup-on-kill",
|
|
||||||
"-e",
|
"-e",
|
||||||
"FOO=bar",
|
"FOO=bar",
|
||||||
"-e",
|
"-e",
|
||||||
@@ -179,7 +173,6 @@ mod tests {
|
|||||||
Command::Spawn(a) => {
|
Command::Spawn(a) => {
|
||||||
assert_eq!(a.command, "bash");
|
assert_eq!(a.command, "bash");
|
||||||
assert_eq!(a.branch.as_deref(), Some("feat/x"));
|
assert_eq!(a.branch.as_deref(), Some("feat/x"));
|
||||||
assert!(a.cleanup_on_kill);
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
a.env,
|
a.env,
|
||||||
vec![("FOO".into(), "bar".into()), ("BAZ".into(), "qux".into()),]
|
vec![("FOO".into(), "bar".into()), ("BAZ".into(), "qux".into()),]
|
||||||
@@ -189,27 +182,6 @@ mod tests {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn cleanup_on_kill_defaults_true_for_the_wire() {
|
|
||||||
let cli = Cli::try_parse_from([
|
|
||||||
"maestro",
|
|
||||||
"spawn",
|
|
||||||
"--cwd",
|
|
||||||
"/tmp",
|
|
||||||
"--command",
|
|
||||||
"bash",
|
|
||||||
"--worktree-from",
|
|
||||||
"/repos/foo",
|
|
||||||
"--branch",
|
|
||||||
"feat/x",
|
|
||||||
])
|
|
||||||
.unwrap();
|
|
||||||
match cli.command {
|
|
||||||
Command::Spawn(a) => assert!(a.cleanup_on_kill),
|
|
||||||
_ => panic!("wrong subcommand"),
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// Review fix: without a flag the CLI always sent `create_branch: true`,
|
/// Review fix: without a flag the CLI always sent `create_branch: true`,
|
||||||
/// so the daemon's existing-branch path was unreachable and spawning onto
|
/// so the daemon's existing-branch path was unreachable and spawning onto
|
||||||
/// a branch that already existed just failed.
|
/// a branch that already existed just failed.
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ pub async fn run_spawn(client: &DaemonClient, args: SpawnArgs) -> Result<Session
|
|||||||
(Some(repo), Some(branch)) => Some(WorktreeSpec {
|
(Some(repo), Some(branch)) => Some(WorktreeSpec {
|
||||||
base_repo: repo.clone(),
|
base_repo: repo.clone(),
|
||||||
branch: branch.clone(),
|
branch: branch.clone(),
|
||||||
cleanup_on_kill: args.cleanup_on_kill,
|
|
||||||
create_branch: !args.existing_branch,
|
create_branch: !args.existing_branch,
|
||||||
}),
|
}),
|
||||||
_ => None,
|
_ => None,
|
||||||
|
|||||||
@@ -363,7 +363,6 @@ async fn delete_a_session_whose_worktree_holds_unsaved_work_returns_409_with_the
|
|||||||
worktree: Some(WorktreeSpec {
|
worktree: Some(WorktreeSpec {
|
||||||
base_repo: repo.path().to_path_buf(),
|
base_repo: repo.path().to_path_buf(),
|
||||||
branch: "feat/guarded".into(),
|
branch: "feat/guarded".into(),
|
||||||
cleanup_on_kill: true,
|
|
||||||
create_branch: true,
|
create_branch: true,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
@@ -417,7 +416,6 @@ async fn delete_with_force_ends_the_session_and_answers_what_was_retained() {
|
|||||||
worktree: Some(WorktreeSpec {
|
worktree: Some(WorktreeSpec {
|
||||||
base_repo: repo.path().to_path_buf(),
|
base_repo: repo.path().to_path_buf(),
|
||||||
branch: "feat/guarded".into(),
|
branch: "feat/guarded".into(),
|
||||||
cleanup_on_kill: true,
|
|
||||||
create_branch: true,
|
create_branch: true,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -385,7 +385,6 @@ async fn kill_removes_worktree_even_when_spec_says_keep() {
|
|||||||
worktree: Some(WorktreeSpec {
|
worktree: Some(WorktreeSpec {
|
||||||
base_repo: repo.path().to_path_buf(),
|
base_repo: repo.path().to_path_buf(),
|
||||||
branch: "feat/keep".into(),
|
branch: "feat/keep".into(),
|
||||||
cleanup_on_kill: false,
|
|
||||||
create_branch: true,
|
create_branch: true,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
@@ -423,7 +422,6 @@ async fn killing_refuses_a_worktree_with_unsaved_work_and_keeps_the_session() {
|
|||||||
worktree: Some(WorktreeSpec {
|
worktree: Some(WorktreeSpec {
|
||||||
base_repo: repo.path().to_path_buf(),
|
base_repo: repo.path().to_path_buf(),
|
||||||
branch: "feat/guarded".into(),
|
branch: "feat/guarded".into(),
|
||||||
cleanup_on_kill: true,
|
|
||||||
create_branch: true,
|
create_branch: true,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
@@ -487,7 +485,6 @@ async fn killing_refuses_until_the_branch_is_pushed() {
|
|||||||
worktree: Some(WorktreeSpec {
|
worktree: Some(WorktreeSpec {
|
||||||
base_repo: repo.path().to_path_buf(),
|
base_repo: repo.path().to_path_buf(),
|
||||||
branch: "feat/pushed".into(),
|
branch: "feat/pushed".into(),
|
||||||
cleanup_on_kill: true,
|
|
||||||
create_branch: true,
|
create_branch: true,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
@@ -539,7 +536,6 @@ async fn force_killing_a_guarded_worktree_retains_it_in_the_store() {
|
|||||||
worktree: Some(WorktreeSpec {
|
worktree: Some(WorktreeSpec {
|
||||||
base_repo: repo.path().to_path_buf(),
|
base_repo: repo.path().to_path_buf(),
|
||||||
branch: "feat/forced".into(),
|
branch: "feat/forced".into(),
|
||||||
cleanup_on_kill: true,
|
|
||||||
create_branch: true,
|
create_branch: true,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
@@ -605,7 +601,6 @@ async fn force_on_a_clear_worktree_removes_it_as_usual() {
|
|||||||
worktree: Some(WorktreeSpec {
|
worktree: Some(WorktreeSpec {
|
||||||
base_repo: repo.path().to_path_buf(),
|
base_repo: repo.path().to_path_buf(),
|
||||||
branch: "feat/clear".into(),
|
branch: "feat/clear".into(),
|
||||||
cleanup_on_kill: true,
|
|
||||||
create_branch: true,
|
create_branch: true,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
@@ -648,7 +643,6 @@ async fn killing_an_ignored_only_worktree_succeeds() {
|
|||||||
worktree: Some(WorktreeSpec {
|
worktree: Some(WorktreeSpec {
|
||||||
base_repo: repo.path().to_path_buf(),
|
base_repo: repo.path().to_path_buf(),
|
||||||
branch: "feat/rusty".into(),
|
branch: "feat/rusty".into(),
|
||||||
cleanup_on_kill: true,
|
|
||||||
create_branch: true,
|
create_branch: true,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -119,11 +119,6 @@ pub enum ActivityState {
|
|||||||
pub struct WorktreeSpec {
|
pub struct WorktreeSpec {
|
||||||
pub base_repo: PathBuf,
|
pub base_repo: PathBuf,
|
||||||
pub branch: String,
|
pub branch: String,
|
||||||
/// Kept on the wire for CLI compatibility (#56) but no longer a
|
|
||||||
/// user-facing choice: the daemon always cleans up on kill, guarded
|
|
||||||
/// against unsaved work. Defaults to `true`.
|
|
||||||
#[serde(default = "default_true")]
|
|
||||||
pub cleanup_on_kill: bool,
|
|
||||||
/// When false, `branch` must already exist and is checked out as-is
|
/// When false, `branch` must already exist and is checked out as-is
|
||||||
/// (#56); when true (the default, and what every payload meant before
|
/// (#56); when true (the default, and what every payload meant before
|
||||||
/// the field existed) the daemon creates it with `worktree add -b`.
|
/// the field existed) the daemon creates it with `worktree add -b`.
|
||||||
@@ -594,7 +589,6 @@ mod tests {
|
|||||||
worktree: Some(WorktreeSpec {
|
worktree: Some(WorktreeSpec {
|
||||||
base_repo: PathBuf::from("/home/naps62/projects/maestro"),
|
base_repo: PathBuf::from("/home/naps62/projects/maestro"),
|
||||||
branch: "feat/foo".into(),
|
branch: "feat/foo".into(),
|
||||||
cleanup_on_kill: true,
|
|
||||||
create_branch: true,
|
create_branch: true,
|
||||||
}),
|
}),
|
||||||
};
|
};
|
||||||
@@ -624,7 +618,6 @@ mod tests {
|
|||||||
});
|
});
|
||||||
let spec: WorktreeSpec = serde_json::from_value(json).unwrap();
|
let spec: WorktreeSpec = serde_json::from_value(json).unwrap();
|
||||||
assert!(spec.create_branch);
|
assert!(spec.create_branch);
|
||||||
assert!(spec.cleanup_on_kill);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
@@ -632,7 +625,6 @@ mod tests {
|
|||||||
let spec = WorktreeSpec {
|
let spec = WorktreeSpec {
|
||||||
base_repo: PathBuf::from("/work"),
|
base_repo: PathBuf::from("/work"),
|
||||||
branch: "feat/foo".into(),
|
branch: "feat/foo".into(),
|
||||||
cleanup_on_kill: true,
|
|
||||||
create_branch: false,
|
create_branch: false,
|
||||||
};
|
};
|
||||||
assert_eq!(spec, round_trip(&spec));
|
assert_eq!(spec, round_trip(&spec));
|
||||||
|
|||||||
@@ -549,7 +549,6 @@ impl DraftPane {
|
|||||||
WorktreeSpec {
|
WorktreeSpec {
|
||||||
base_repo,
|
base_repo,
|
||||||
branch: branch.to_string(),
|
branch: branch.to_string(),
|
||||||
cleanup_on_kill: true,
|
|
||||||
create_branch: true,
|
create_branch: true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -562,7 +561,6 @@ impl DraftPane {
|
|||||||
WorktreeSpec {
|
WorktreeSpec {
|
||||||
base_repo,
|
base_repo,
|
||||||
branch: name,
|
branch: name,
|
||||||
cleanup_on_kill: true,
|
|
||||||
create_branch: false,
|
create_branch: false,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1689,7 +1687,6 @@ mod tests {
|
|||||||
assert_eq!(wt.base_repo, PathBuf::from("/repos/maestro"));
|
assert_eq!(wt.base_repo, PathBuf::from("/repos/maestro"));
|
||||||
assert_eq!(wt.branch, "crimson-otter", "branch defaults to the name");
|
assert_eq!(wt.branch, "crimson-otter", "branch defaults to the name");
|
||||||
assert!(wt.create_branch);
|
assert!(wt.create_branch);
|
||||||
assert!(wt.cleanup_on_kill);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
|||||||
@@ -80,7 +80,6 @@ impl FastForwardDefaults {
|
|||||||
.clone()
|
.clone()
|
||||||
.unwrap_or_else(|| project.path.clone()),
|
.unwrap_or_else(|| project.path.clone()),
|
||||||
branch: name.to_string(),
|
branch: name.to_string(),
|
||||||
cleanup_on_kill: true,
|
|
||||||
create_branch: true,
|
create_branch: true,
|
||||||
}),
|
}),
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -43,7 +43,6 @@ describe("resolveFastForward (#67)", () => {
|
|||||||
expect(req.worktree).toEqual({
|
expect(req.worktree).toEqual({
|
||||||
base_repo: "/repos/fresh",
|
base_repo: "/repos/fresh",
|
||||||
branch: "amber-falcon",
|
branch: "amber-falcon",
|
||||||
cleanup_on_kill: true,
|
|
||||||
create_branch: true,
|
create_branch: true,
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -42,7 +42,6 @@ export function buildFastForwardRequest(
|
|||||||
worktree: {
|
worktree: {
|
||||||
base_repo: project.base_repo ?? project.path,
|
base_repo: project.base_repo ?? project.path,
|
||||||
branch: name,
|
branch: name,
|
||||||
cleanup_on_kill: true,
|
|
||||||
create_branch: true,
|
create_branch: true,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -38,7 +38,6 @@ describe("buildSpawnRequest", () => {
|
|||||||
worktree: {
|
worktree: {
|
||||||
base_repo: "/home/user/project",
|
base_repo: "/home/user/project",
|
||||||
branch: "feat/foo",
|
branch: "feat/foo",
|
||||||
cleanup_on_kill: true,
|
|
||||||
create_branch: true,
|
create_branch: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
@@ -63,7 +62,6 @@ describe("buildSpawnRequest", () => {
|
|||||||
worktree: {
|
worktree: {
|
||||||
base_repo: "/home/user/project",
|
base_repo: "/home/user/project",
|
||||||
branch: "spawn-v2",
|
branch: "spawn-v2",
|
||||||
cleanup_on_kill: true,
|
|
||||||
create_branch: false,
|
create_branch: false,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -75,9 +75,6 @@ export function buildSpawnRequest(
|
|||||||
req.worktree = {
|
req.worktree = {
|
||||||
base_repo: baseRepo,
|
base_repo: baseRepo,
|
||||||
branch,
|
branch,
|
||||||
// The daemon always cleans up, guarded against unsaved work (#56);
|
|
||||||
// the wire field stays for older daemons.
|
|
||||||
cleanup_on_kill: true,
|
|
||||||
// Existing-mode picks must check out as-is; the daemon creates
|
// Existing-mode picks must check out as-is; the daemon creates
|
||||||
// anything else with `worktree add -b` (#56/#61).
|
// anything else with `worktree add -b` (#56/#61).
|
||||||
create_branch: mode !== "existing",
|
create_branch: mode !== "existing",
|
||||||
|
|||||||
@@ -113,7 +113,6 @@ export type Projects = Project[];
|
|||||||
export interface WorktreeSpec {
|
export interface WorktreeSpec {
|
||||||
base_repo: string;
|
base_repo: string;
|
||||||
branch: string;
|
branch: string;
|
||||||
cleanup_on_kill?: boolean;
|
|
||||||
/** When false, `branch` already exists and is checked out as-is (#61).
|
/** When false, `branch` already exists and is checked out as-is (#61).
|
||||||
* Defaults to true (create a new branch) on older daemons. */
|
* Defaults to true (create a new branch) on older daemons. */
|
||||||
create_branch?: boolean;
|
create_branch?: boolean;
|
||||||
|
|||||||
Reference in New Issue
Block a user