Skip to content

Commit b7bb2e2

Browse files
committed
Enhance GitIgnore logic to prevent skipping the .git directory and its contents. This update ensures that any files within the .git directory are treated correctly, improving the handling of ignored files in version control.
1 parent 04a0d5c commit b7bb2e2

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

internal/utils/git_ignore.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ func NewGitIgnore(baseDir string) GitIgnore {
2727
}
2828

2929
func (i GitIgnore) SkipFile(path string) (bool, error) {
30-
// Never skip the .git directory, even if it's in the .gitignore files.
31-
if path == ".git" {
30+
// Never skip the .git directory or files inside it, even if matched by .gitignore patterns.
31+
if path == ".git" || strings.HasPrefix(path, ".git/") || strings.HasPrefix(path, ".git\\") {
3232
return false, nil
3333
}
3434

0 commit comments

Comments
 (0)