Skip to content

Commit

Permalink
manually load global ignore patterns
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed Sep 4, 2022
1 parent 340403b commit 2687d4e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions pkg/header/check.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ package header

import (
"errors"
"github.com/go-git/go-billy/v5/osfs"
"github.com/go-git/go-git/v5/plumbing/format/gitignore"
"io/fs"
"net/http"
"os"
Expand Down Expand Up @@ -80,6 +82,15 @@ func listFiles(config *ConfigHeader) ([]string, error) {
var candidates []string

t, _ := repo.Worktree()
if t.Excludes == nil {
t.Excludes = make([]gitignore.Pattern, 0)
}
if ignorePattens, err := gitignore.LoadGlobalPatterns(osfs.New("")); err == nil {
t.Excludes = append(t.Excludes, ignorePattens...)
}
if ignorePattens, err := gitignore.LoadSystemPatterns(osfs.New("")); err == nil {
t.Excludes = append(t.Excludes, ignorePattens...)
}
s, _ := t.Status()
for file := range s {
candidates = append(candidates, file)
Expand Down

0 comments on commit 2687d4e

Please sign in to comment.