Fallout-build / Fallout-build/Fallout
fallout-migrate: absolute path argument silently ignored on macOS/Linux (migrates the wrong directory in place)
- Dominant language
- C#
- Stars
- 154
- Forks
- 19
- Avg merge
- 1d 22h
- Merged PRs (30d)
- 15
Description
### Usage Information
`fallout-migrate` built from `main` (@ `f072c9de`), .NET SDK 10.0.203, macOS (Darwin / Unix). Reproducible on any Unix-like OS.
### Description
The CLI's positional `path` argument is silently discarded whenever it starts with `/`, because the argument parser treats any `/`-prefixed token as an option (the Windows `/?`-switch convention). On macOS/Linux every absolute path starts with `/`, so `fallout-migrate /abs/path/to/repo` ignores the path entirely and falls back to `ResolveRootDirectory(null)`. That walks up from the current working directory and migrates whatever NUKE repo the CWD happens to be under, in place, with no confirmation, printing a misleading `Migration complete.`
This is a data-safety issue: the tool can rewrite a repository the user never pointed it at.
Root cause (`src/Fallout.Migrate/Program.cs`):
```csharp
var rootArg = Array.Find(args, a => !a.StartsWith('-') && !a.StartsWith('/'));
```
The `!a.StartsWith('/')` clause excludes all Unix absolute paths from being recognised as the root argument.
### Reproduction Steps
1. Have two NUKE consumer repos, e.g. `~/work/repoA` (has `build/`, `build.sh`) and `/tmp/repoB`.
2. `cd ~/work/repoA`
3. Run `fallout-migrate /tmp/repoB` (intending to migrate repoB).
4. Observe that the summary reports files under repoA, and that repoA (not `/tmp/repoB`) was modified in place. `git status` in repoA shows the migration; repoB is untouched.
### Expected Behavior
An absolute path argument is honoured as the repository root, especially on Unix, where absolute paths necessarily start with `/`. `fallout-migrate /tmp/repoB` migrates `/tmp/repoB`.
### Actual Behavior
The absolute path is treated as an option and ignored; the tool migrates the CWD-derived root instead, in place, and reports success.
### Regression?
Unknown. Present in current `main`.
### Known Workarounds
- `cd` into the target repo and run `fallout-migrate` with no path argument, or
- pass a relative path (which does not start with `/`).
Suggested fix: restrict the option check to actual switches (`/?`, `-h`, etc.) rather than any `/`-prefixed token, and/or prefer `Path.IsPathRooted(arg) && Directory.Exists(arg)` when classifying the argument. A confirmation prompt before an in-place rewrite would also help.
### Could you help with a pull-request?
Yes.
Contributor guide
Assessment
This issue has not been assessed yet.