Skip to content

Commit

Permalink
refactor: include doublestar (#170)
Browse files Browse the repository at this point in the history
* refactor: include doublestar
  • Loading branch information
cugu authored Oct 19, 2024
1 parent 061f6f2 commit caade8d
Show file tree
Hide file tree
Showing 9 changed files with 1,076 additions and 9 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
- uses: actions/setup-go@v5
with: { go-version: '1.23' }
- uses: actions/checkout@v4
- run: make install generate-win fmt
- run: make install generate-win fmt_linux
- run: git diff --exit-code

lint:
Expand Down
16 changes: 13 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,24 @@ install:
go install mvdan.cc/gofumpt@v0.6.0
go install github.com/daixiang0/gci@v0.13.4

.PHONY: fmt
fmt:
.PHONY: fmt_darwin
fmt_darwin:
@echo "Formatting..."
go mod tidy
go fmt ./...
gci write -s standard -s default -s "prefix(github.com/forensicanalysis/artifactcollector)" .
gofumpt -l -w .
find . -type f -name "*.go" -print0 | xargs -0 sed -i.bak -e 's/ 0o/ 0/g'
find . -type f -name "*.go" -print0 | xargs -0 sed -i '' -e 's/ 0o/ 0/g'
wsl -fix ./... || true

.PHONY: fmt_linux
fmt_linux:
@echo "Formatting..."
go mod tidy
go fmt ./...
gci write -s standard -s default -s "prefix(github.com/forensicanalysis/artifactcollector)" .
gofumpt -l -w .
find . -type f -name "*.go" -print0 | xargs -0 sed -i -e 's/ 0o/ 0/g'
wsl -fix ./... || true

.PHONY: vendor
Expand Down
4 changes: 2 additions & 2 deletions artifacts/expansion.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
"runtime"
"strings"

"github.com/forensicanalysis/fsdoublestar"
"github.com/forensicanalysis/artifactcollector/doublestar"
)

const windows = "windows"
Expand Down Expand Up @@ -231,7 +231,7 @@ func expandPath(fs fs.FS, syspath string, prefixes []string, collector ArtifactC
expandedPath = strings.Replace(expandedPath, "{", `\{`, -1)
expandedPath = strings.Replace(expandedPath, "}", `\}`, -1)

unglobedPaths, err := fsdoublestar.Glob(fs, expandedPath)
unglobedPaths, err := doublestar.Glob(fs, expandedPath)
if err != nil {
log.Println(err)

Expand Down
22 changes: 22 additions & 0 deletions doublestar/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Recursive directory globbing via `**` for Go's [io/fs](https://golang.org/pkg/io/fs).

## Example

``` golang
func main() {
// get file system for this repository
wd, _ := os.Getwd()
fsys := os.DirFS(wd)

// get all yml files
matches, _ := fsdoublestar.Glob(fsys, "**/*.yml")

// print matches
fmt.Println(matches)
// Output: [.github/workflows/ci.yml .github/.golangci.yml]
}
```

## Acknowledgement

This repository is based on [Bob Matcuk's](https://github.com/bmatcuk) great [doublestar](https://github.com/bmatcuk/doublestar) package.
Loading

0 comments on commit caade8d

Please sign in to comment.