Skip to content

SC-4: file enumeration and recursive directory traversal engine - #2

Merged
iampryce merged 2 commits into
mainfrom
sc-4-file-enumeration
Jul 31, 2026
Merged

iampryce merged 2 commits into
mainfrom
sc-4-file-enumeration

Conversation

@iampryce

Copy link
Copy Markdown
Contributor
  • sync.Walk: recursive traversal via filepath.WalkDir
  • FileEntry metadata (path, size, mtime, mode, uid/gid, symlink target)
  • Symlinks captured via Lstat, never followed
  • Deterministic path-sorted output
  • -r/-d flag semantics wired into CLI
  • Cross-platform UID/GID handling (build-tag split, Windows returns 0)
  • .gitattributes fixing CRLF/gofmt friction
  • README updated: file enumeration section, flag table, platform caveat

- sync.Walk: recursive traversal via filepath.WalkDir
- FileEntry metadata (path, size, mtime, mode, uid/gid, symlink target)
- Symlinks captured via Lstat, never followed
- Deterministic path-sorted output
- -r/-d flag semantics wired into CLI
- Cross-platform UID/GID handling (build-tag split, Windows returns 0)
- .gitattributes fixing CRLF/gofmt friction
- README updated: file enumeration section, flag table, platform caveat

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 the initial file-enumeration (“flist”) engine to internal/sync, including recursive directory traversal and richer per-entry metadata, and wires the -d/--dirs flag into the CLI flag parser. It also updates the README to document enumeration behavior and adds .gitattributes to normalize LF endings.

Changes:

  • Implement internal/sync.Walk (filepath-based recursive traversal) returning deterministic path-sorted []FileEntry with metadata (mode, mtime, size, uid/gid, symlink target).
  • Add unit tests covering recursion/dirs semantics, symlink behavior, and deterministic ordering.
  • Wire --dirs/-d into CLI parsing and update README documentation accordingly; add .gitattributes for LF normalization.

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 project status and documents new file-enumeration behavior and -r/-d semantics.
internal/sync/walk.go Introduces the traversal + metadata collection implementation and deterministic sorting.
internal/sync/walk_test.go Adds tests for traversal depth rules, symlink handling, file sizes, and ordering.
internal/sync/uidgid_unix.go Adds POSIX UID/GID extraction via syscall.Stat_t behind build tags.
internal/sync/uidgid_windows.go Adds Windows stub returning “unavailable” ownership metadata.
internal/cli/root.go Adds --dirs/-d flag and prints it in the CLI echo output.
.gitattributes Forces LF line endings to reduce CRLF/gofmt friction.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread internal/sync/walk.go Outdated
Comment on lines +93 to +97
// lookupUIDGID is platform-specific (see uidgid_unix.go /
// uidgid_windows.go): on Windows it always reports unavailable,
// leaving UID/GID at their zero value. That zero must not be read
// as "owned by root" — see uidgid_windows.go for why.
entry.UID, entry.GID, _ = lookupUIDGID(info)
Comment thread README.md Outdated
Comment on lines +53 to +55
`internal/sync.Walk` recursively lists a source tree into a sorted
`[]FileEntry` (path, size, mtime, mode, uid/gid, symlink target). Symlinks
are captured via `Lstat`, never followed.
…README syntax

FileEntry now carries OwnershipAvailable so a real uid/gid of 0 can't be
confused with "ownership unavailable" on Windows. Also fixes an invalid
internal/sync.Walk package-selector reference in the README.
@iampryce
iampryce merged commit 483c5de into main Jul 31, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants