fix: Avoid panic for unanchorable/non-UTF8 git paths (#11106)
### What
Prevent a runtime panic in `crates/turborepo-scm/src/git.rs` when git
emits paths that cannot be anchored to the turbo root (e.g. corrupted
filenames, non-parent paths) or when git stdout contains non-UTF8 bytes.
Instead of `unwrap()` → crash, errors propagate through the existing
`Result` chain and the change detector falls back to treating all
packages as changed.
### Why
GitHub Actions CI was failing for repositories that contain unusual
filenames (Cyrillic / corrupted / non-UTF8). The panic originated in
`add_files_from_stdout`'s `.unwrap()` calls and caused `--affected` CI
runs to crash.
### How
**`crates/turborepo-scm/src/git.rs`**
- `add_files_from_stdout` now returns `Result<(), Error>` — replaced
`.unwrap()` on `RelativeUnixPath::new()` and
`reanchor_path_from_git_root_to_turbo_root()` with `?` propagation
- All 3 call sites in `changed_files` updated to propagate with `?`
**`crates/turborepo-scope/src/change_detector.rs`**
- Replaced `process::exit(1)` + `eprintln!` with a fail-safe fallback:
on any SCM error, log via `tracing::warn!` and return all packages as
changed (same pattern as the existing `InvalidRange` handler)
- Removed `std::process` and `Error as ScmError` imports — the library
crate no longer terminates the process or couples to specific SCM error
variant internals
**`crates/turborepo-repository/src/change_mapper/mod.rs`**
- Added `AllPackageChangeReason::ScmError { error: String }` variant for
downstream consumers to understand why all packages were selected
**`crates/turborepo-query/src/lib.rs` + `affected_tasks.rs`**
- Added match arms for the new `ScmError` variant in the GraphQL query
layer
### Behavior
When git emits unprocessable paths, instead of panicking:
1. The error propagates from `add_files_from_stdout` through
`changed_files` to `changed_packages`
2. `changed_packages` catches it, logs a warning via `tracing::warn!`,
and conservatively treats all packages as changed
3. CI runs everything rather than crashing — run summaries, telemetry,
and TUI teardown all execute normally
Fix #10403
---------
Co-authored-by: Anthony Shew <anthonyshew@gmail.com>
Co-authored-by: vercel[bot] <35613825+vercel[bot]@users.noreply.github.com>