Skip to content

Add unit tests and fix preserve-paths, brew -v, and man page - #44

Merged
davidnewhall merged 1 commit into
mainfrom
dn2_tests
Aug 25, 2026
Merged

Add unit tests and fix preserve-paths, brew -v, and man page#44
davidnewhall merged 1 commit into
mainfrom
dn2_tests

Conversation

@davidnewhall

Copy link
Copy Markdown
Contributor

Summary

  • Add tests for FileMode, ParseJobs, fixModes, getArchives (file/dir, include/exclude, missing path), preserve-paths extract layout, and SquashRoot.
  • Join preserve-paths onto --output with filepath.Rel so a leading slash from TrimPrefix is not treated as an absolute path.
  • Homebrew xt -v now expects exit 0; MANUAL documents -P for passwords and that --preserve-paths still uses --output as the base; README uses go install golift.io/xt@latest.

Test plan

  • go test -race ./... on the CI matrix
  • Confirm brew formula test would match xt -v exit 0
  • Confirm MANUAL -P vs -p wording

Made with Cursor

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>
@davidnewhall
davidnewhall merged commit e9ad3ff into main Aug 25, 2026
7 checks passed
@davidnewhall
davidnewhall deleted the dn2_tests branch August 25, 2026 07:06
@golift-bot
golift-bot requested a lite review from Copilot August 25, 2026 07:18

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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, and SquashRoot.
  • 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.

Comment thread README.md
cd /tmp
go get github.com/Unpackerr/xt
go install github.com/Unpackerr/xt
go install golift.io/xt@latest
Comment thread pkg/xt/xt.go
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))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

2 participants