Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: include doublestar #170

Merged
merged 4 commits into from
Oct 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/[email protected]
go install github.com/daixiang0/[email protected]

.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
Loading