8000 feat(minimald): add debug log on workspace unpack error by twitchyliquid64 · Pull Request #883 · gominimal/minimal · GitHub
[go: up one dir, main page]

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions crates/minimal/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1090,10 +1090,11 @@ pub async fn cmd_activate(global: &GlobalArgs, args: ActivateArgs) -> Result<(),
// Guard against accidentally uploading a non-VCS directory
// (e.g. `~`): if the resolved project root is not a recognized
// VCS root, warn and ask for confirmation before the recursive
// upload. On non-interactive stdin (CI, pipes, agents) we
// proceed without prompting — `--sync none` remains available
// for explicit opt-out (#770).
// upload. On non-interactive stdin (CI, pipes, agents) and under
// `--no-prompt` we proceed without prompting — `--sync none`
// remains available for explicit opt-out (#770).
let should_upload = file_upload::is_vcs_root(upload_root.as_std_path())
|| args.no_prompt
|| !can_prompt_interactively()
|| confirm(
&format!(
Expand Down Expand Up @@ -2100,9 +2101,18 @@ mod tests {

/// With no mfile anywhere up the tree, `resolve_upload_root` returns the
/// input directory unchanged — the original activate behaviour.
///
/// The temp dir is rooted directly in `$HOME` rather than `$TMPDIR`: the
/// upward walk stops at `$HOME`, so this is the only placement where "no
/// mfile up the tree" is guaranteed. Under `$TMPDIR` the walk escapes to
/// whatever encloses it — with `TMPDIR` inside a checkout of this repo it
/// finds the repo's own `minimal.toml` and the test fails.
#[test]
fn resolve_upload_root_returns_input_when_no_mfile() {
let dir = tempfile::tempdir().unwrap();
let Some(home) = std::env::home_dir() else {
return; // no HOME: no walk boundary to anchor the test to
};
let dir = tempfile::tempdir_in(&home).unwrap();
let path = camino::Utf8Path::from_path(dir.path()).expect("temp path is UTF-8");
assert_eq!(resolve_upload_root(path).unwrap(), path);
}
Expand Down
9 changes: 8 additions & 1 deletion crates/minimal/tests/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,8 +204,11 @@ async fn activate_creates_session() {
let (daemon, args) = setup().await;

// Create a temp project dir with a minimal.toml so the
// missing-mfile prompt doesn't fire.
// missing-mfile prompt doesn't fire. Mark it as a VCS root so
// the non-VCS upload confirmation (#790) short-circuits instead
// of blocking on stdin when the test binary is attached to a TTY.
let project = tempfile::TempDir::new().unwrap();
std::fs::create_dir(project.path().join(".git")).unwrap();
std::fs::write(
project.path().join("minimal.toml"),
"# test minimal.toml\n[upstream]\nrepo = \"https://github.com/gominimal/pkgs\"\nbranch = \"main\"\n\n[stack]\nuse = \"shell\"\n",
Expand Down Expand Up @@ -240,7 +243,11 @@ async fn activate_uploads_project_files() {
let (daemon, args) = setup().await;

// Create a temp project dir with a minimal.toml and some files.
// Mark it as a VCS root so the non-VCS upload confirmation (#790)
// short-circuits instead of blocking on stdin when the test
// binary is attached to a TTY.
let project = tempfile::TempDir::new().unwrap();
std::fs::create_dir(project.path().join(".git")).unwrap();
std::fs::write(
project.path().join("minimal.toml"),
"# test\n[upstream]\nrepo = \"https://github.com/gominimal/pkgs\"\nbranch = \"main\"\n\n[stack]\nuse = \"shell\"\n",
Expand Down
1 change: 1 addition & 0 deletions crates/minimald/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,7 @@ async fn serve_stream_workspace_files(
mut c: RuChannel<Msg>,
) {
if let Err(msg) = unpack_workspace_files(&s, &config, &mut c).await {
tracing::debug!(error = %msg, "workspace unpack failed");
let _ = c.extended_data_bytes(1, msg).await;
}
let _ = c.close().await;
Expand Down
0