Add unit tests and fix preserve-paths, brew -v, and man page - #44
Merged
Conversation
Fix preserve-paths joining onto --output, brew -v exit, and the man page mix-up between -P and -p. Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Pull request overview
This PR adds unit tests around job parsing, file modes, archive discovery, and extraction behaviors, while also adjusting documentation and release packaging expectations. It also changes preserve-path extraction output layout by computing a relative path under --output (instead of accidentally treating a leading separator as an absolute path).
Changes:
- Add unit tests for
FileMode,ParseJobs,fixModes,getArchives, preserve-path extraction layout, andSquashRoot. - Update preserve-path output directory calculation to use
filepath.Rel(folder, archive)(with fallback). - Refresh user-facing docs and packaging configs (README install command, MANUAL wording, Homebrew formula test exit code).
Reviewed changes
Copilot reviewed 7 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| README.md | Updates install instructions to a single go install command. |
| pkg/xt/xt.go | Adjusts preserve-path output directory computation using filepath.Rel. |
| pkg/xt/xt_test.go | Adds tests covering archive discovery and extraction behaviors (preserve-paths, squash-root, include/exclude). |
| pkg/xt/job_test.go | Adds tests for job-file parsing, default modes, and string formatting. |
| pkg/xt/filemode_test.go | Adds tests for FileMode marshal/unmarshal behavior. |
| MANUAL.md | Clarifies password flag and preserve-paths behavior relative to --output. |
| .goreleaser.yaml | Updates Homebrew formula test to expect xt -v exit code 0. |
| .gitignore | Adds /o/ and normalizes MANUAL.gz ignore entry. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| cd /tmp | ||
| go get github.com/Unpackerr/xt | ||
| go install github.com/Unpackerr/xt | ||
| go install golift.io/xt@latest |
Comment on lines
+113
to
+120
| // Rel(search folder, archive) then join that directory onto job.Output. | ||
| // TrimPrefix leaves a leading separator, and Join treats that as absolute. | ||
| rel, err := filepath.Rel(folder, archive) | ||
| if err != nil { | ||
| rel = strings.TrimPrefix(archive, folder) | ||
| } | ||
|
|
||
| file.OutputDir = filepath.Join(j.Output, filepath.Dir(rel)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
--outputwithfilepath.Relso a leading slash from TrimPrefix is not treated as an absolute path.xt -vnow expects exit 0; MANUAL documents-Pfor passwords and that--preserve-pathsstill uses--outputas the base; README usesgo install golift.io/xt@latest.Test plan
go test -race ./...on the CI matrixxt -vexit 0-Pvs-pwordingMade with Cursor