Skip to content

Fix: replace git ls-files with glob-based file detection#19

Merged
azu merged 8 commits intomainfrom
feature/replace-git-ls-files-with-glob
Mar 31, 2026
Merged

Fix: replace git ls-files with glob-based file detection#19
azu merged 8 commits intomainfrom
feature/replace-git-ls-files-with-glob

Conversation

@azu
Copy link
Copy Markdown
Owner

@azu azu commented Mar 31, 2026

Summary

Replace the git ls-files based auto-detection with a pure glob pattern using the doublestar library. This removes the dependency on being inside a git repository and eliminates potential hangs from shelling out to the git command.

Changes

  • Remove isTargetFile() and findFilesWithGit() functions that relied on git ls-files
  • Introduce defaultGlob constant used when neither -f nor --glob is specified
  • Unify the code path: both explicit --glob and auto-detect now use doublestar.FilepathGlob
  • Add cobra.NoArgs to check and run commands to reject unexpected positional arguments
  • Update tests to no longer require a git repository (remove initGitRepo/gitAdd helpers)
  • Update README to document the new default glob pattern

Breaking Changes

  • .gitignore is no longer respected in auto-detect mode (glob walks the filesystem directly)
  • The tool no longer requires a git repository to auto-detect files

Test Plan

  • Run go test ./... to verify all tests pass
  • Run dockerfile-pin check in a directory with Dockerfiles to verify auto-detection works
  • Run dockerfile-pin check in a non-git directory to verify it works without git

Open with Devin

Remove dependency on `git ls-files` for auto-detecting target files.
Use the doublestar glob library with a default pattern instead, which
is simpler, does not require a git repository, and avoids potential
hangs from shelling out to git. Also add cobra.NoArgs to check/run
commands to reject unexpected positional arguments.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@azu azu added the Type: Bug Bug or Bug fixes label Mar 31, 2026
devin-ai-integration[bot]

This comment was marked as resolved.

azu and others added 3 commits March 31, 2026 23:10
…try checks

- Restore git ls-files for .gitignore support, filter results with defaultGlob pattern
- Add glob-only fallback (skipping node_modules/vendor/.git) for non-git repos
- Parallelize registry digest verification in check command with semaphore
- Cache Exists() calls in CachedResolver for concurrent safety

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…on-git fallback

Remove mutex in check.go since each goroutine exclusively owns its allResults[i] slot.
Remove .git from skipDirs as doublestar glob already skips hidden directories.
Update README to document non-git fallback behavior.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

azu and others added 3 commits March 31, 2026 23:22
… from default glob

CachedResolver.Exists was incorrectly deriving the existence result from
whether err was nil, ignoring the actual boolean returned by the inner
resolver. This caused non-existent images to be cached as existing when
no error occurred. Also removes the unused dockerfile_*.tmpl pattern
from the default glob and updates README accordingly.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Handle errcheck: use `_, _ =` for cached.Exists in loop
- Fix goimports formatting

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
devin-ai-integration[bot]

This comment was marked as resolved.

…cross-method interference

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 10 additional findings in Devin Review.

Open in Devin Review

Comment thread cmd/files.go
@azu azu merged commit b6deb43 into main Mar 31, 2026
3 checks passed
@azu azu deleted the feature/replace-git-ls-files-with-glob branch March 31, 2026 14:54
@github-actions github-actions Bot mentioned this pull request Mar 31, 2026
azu pushed a commit that referenced this pull request Mar 31, 2026
<!-- Release notes generated using configuration in .github/release.yml
at main -->

## What's Changed
### Bug Fixes
* Fix: replace git ls-files with glob-based file detection by @azu in
#19


**Full Changelog**:
v1.0.3...v1.0.4

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Type: Bug Bug or Bug fixes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant