Skip to content

chore: migrate utility.FindFileInAppDir to v2 (STEP-2171)#334

Open
Badlazzor wants to merge 1 commit into
masterfrom
STEP-2171-utility-v2
Open

chore: migrate utility.FindFileInAppDir to v2 (STEP-2171)#334
Badlazzor wants to merge 1 commit into
masterfrom
STEP-2171-utility-v2

Conversation

@Badlazzor

@Badlazzor Badlazzor commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Summary

Adds utility/ as a v2 package with FindFileInAppDir ported from v1. GetXcodeVersion is intentionally not migrated — xcodeversion.Reader.GetVersion already covers the same surface in v2.

Jira: STEP-2171

What changed

utility/path.go

  • New file. FindFileInAppDir(appDir, fileName) (string, error) with v1-equivalent behavior:
    1. If appDir/fileName exists → return it.
    2. Otherwise walk every *.app bundle under appDir and return the first basename match.
    3. Else error.

v1 → v2 API swaps inside the function:

  • pathutil.IsPathExists(pth)pathutil.NewPathChecker().IsPathExists(pth)
  • pathutil.ListEntries(dir, filter)pathutil.FilterFS(os.DirFS(dir), filter)

The filter constructors (ExtensionFilter, BaseFilter) are reused verbatim from v2 — same names, slightly different FilterFunc signature (now takes fs.DirEntry).

utility/path_test.go

Five subtests covering: direct match at root, match inside .app, match inside a nested directory within a .app, not-found error, and direct-match-takes-precedence-over-bundle-search.

Drive-by: go-utils/v2 dependency bump

Bumped go-utils/v2 from alpha.34.0-pseudo to v2.0.0-alpha.35. FilterFS, ExtensionFilter, and BaseFilter landed in that tag via STEP-2135 / go-utils#224.

Drive-by: regenerate mocks/FileManager.go + extend devportalservice/mock_filemanager.go

The bump added CopyFileFS to fileutil.FileManager. Regenerated the mockery mock for mocks/FileManager.go, and added a hand-written CopyFileFS panic stub to the hand-rolled devportalservice/mock_filemanager.go to keep both internal mocks satisfying the interface.

Test plan

  • go test ./utility/... — all 5 subtests pass.
  • go test ./... — whole repo green (xcarchive + xcodecache exercises take a couple of minutes; both pass).
  • go build ./... — clean.
  • gofmt -l utility/ devportalservice/mock_filemanager.go — clean.

🤖 Generated with Claude Code

Adds utility/ as a v2 package containing FindFileInAppDir, with five
unit tests covering direct-match, .app-bundle search, nested directory
match, not-found, and precedence-over-bundle-search.

v1 used the package-level pathutil helpers; v2 uses the interface-based
API:
- pathutil.IsPathExists(pth) → pathutil.NewPathChecker().IsPathExists(pth)
- pathutil.ListEntries(dir, filter) → pathutil.FilterFS(os.DirFS(dir), filter)

GetXcodeVersion is intentionally not migrated; v2 already ships
xcodeversion.Reader.GetVersion which covers the same surface.

Drive-by:
- Bump go-utils/v2 to v2.0.0-alpha.35 — FilterFS and the filter
  constructors landed in that tag (STEP-2135, PR #224).
- Re-run mockery against fileutil.FileManager and add a hand-written
  CopyFileFS stub in devportalservice/mock_filemanager.go so the
  internal mock satisfies the interface again.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
@Badlazzor Badlazzor requested a review from a team June 12, 2026 13:55
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.

1 participant