Skip to content

Commit

Permalink
ignore hidden (dotted) files
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Menet committed Jan 23, 2024
1 parent 3653ae5 commit 5b2fd08
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 49 deletions.
15 changes: 15 additions & 0 deletions element.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,17 @@ func getPosition(basepath, path string) []string {
return pos
}

func isHidden(f os.FileInfo) bool {
base := filepath.Base(f.Name())
if base == "." {
return false
}
if strings.HasPrefix(base, ".") {
return true
}
return false
}

func newElementFromPersistence(basepath, matcher string, filesys billy.Filesystem) (*element, error) {
basepath = filepath.Clean(basepath)
_, err := filesys.Stat(basepath)
Expand All @@ -149,6 +160,10 @@ func newElementFromPersistence(basepath, matcher string, filesys billy.Filesyste
err = fmt.Errorf("Could not stat file '%s', error occured: %w", path, err)
return err
}
fmt.Println(info.Name())
if isHidden(info) {
return nil
}
if info.IsDir() {
elems, err := filesys.ReadDir(path)
if err != nil {
Expand Down
28 changes: 14 additions & 14 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ go 1.20
require (
github.com/adrg/frontmatter v0.2.0
github.com/carlmjohnson/versioninfo v0.22.4
github.com/go-git/go-billy/v5 v5.4.1
github.com/go-git/go-git/v5 v5.8.1
github.com/go-git/go-billy/v5 v5.5.0
github.com/go-git/go-git/v5 v5.11.0
github.com/mitchellh/go-homedir v1.1.0
github.com/spf13/cobra v1.7.0
golang.org/x/crypto v0.11.0
golang.org/x/crypto v0.18.0
gopkg.in/yaml.v3 v3.0.1
oss.terrastruct.com/d2 v0.5.1
)
Expand All @@ -19,13 +19,13 @@ require (
dario.cat/mergo v1.0.0 // indirect
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/Microsoft/go-winio v0.6.1 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230717121422-5aa5874ade95 // indirect
github.com/ProtonMail/go-crypto v0.0.0-20230923063757-afb1ddc0824c // indirect
github.com/PuerkitoBio/goquery v1.8.0 // indirect
github.com/acomagu/bufpipe v1.0.4 // indirect
github.com/alecthomas/chroma v0.10.0 // indirect
github.com/alecthomas/chroma/v2 v2.5.0 // indirect
github.com/andybalholm/cascadia v1.3.1 // indirect
github.com/cloudflare/circl v1.3.3 // indirect
github.com/cloudflare/circl v1.3.7 // indirect
github.com/cyphar/filepath-securejoin v0.2.4 // indirect
github.com/dlclark/regexp2 v1.8.1 // indirect
github.com/dop251/goja v0.0.0-20230122112309-96b1610dd4f7 // indirect
github.com/emirpasic/gods v1.18.1 // indirect
Expand All @@ -43,20 +43,20 @@ require (
github.com/mazznoer/csscolorparser v0.1.3 // indirect
github.com/pjbgf/sha1cd v0.3.0 // indirect
github.com/rivo/uniseg v0.4.3 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/skeema/knownhosts v1.2.0 // indirect
github.com/sergi/go-diff v1.3.1 // indirect
github.com/skeema/knownhosts v1.2.1 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xanzy/ssh-agent v0.3.3 // indirect
github.com/yuin/goldmark v1.5.3 // indirect
go.opencensus.io v0.24.0 // indirect
golang.org/x/exp v0.0.0-20221126150942-6ab00d035af9 // indirect
golang.org/x/image v0.3.0 // indirect
golang.org/x/mod v0.8.0 // indirect
golang.org/x/net v0.12.0 // indirect
golang.org/x/sys v0.10.0 // indirect
golang.org/x/term v0.10.0 // indirect
golang.org/x/text v0.11.0 // indirect
golang.org/x/tools v0.6.0 // indirect
golang.org/x/mod v0.14.0 // indirect
golang.org/x/net v0.20.0 // indirect
golang.org/x/sys v0.16.0 // indirect
golang.org/x/term v0.16.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/tools v0.17.0 // indirect
golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 // indirect
gonum.org/v1/plot v0.12.0 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
Expand Down
Loading

0 comments on commit 5b2fd08

Please sign in to comment.