Skip to content

Commit

Permalink
transform windows filepaths to linux filepaths
Browse files Browse the repository at this point in the history
I hope this will make this code OS independent.
  • Loading branch information
shibumi committed Nov 14, 2020
1 parent 46b508b commit 3654633
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ jobs:
strategy:
matrix:
go-version: [1.13.x, 1.14.x, 1.15.x]
os: [ubuntu-latest]
os: [ubuntu-latest, macos-latest, windows-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Install Go
Expand Down
5 changes: 5 additions & 0 deletions gitignore.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ import (
"bufio"
"bytes"
"io"
"path/filepath"
"regexp"
"strings"
)
Expand All @@ -85,6 +86,8 @@ type gitIgnorePattern struct {
func GitIgnore(patterns []string, name string) (ignore bool, err error) {
for _, pattern := range patterns {
p := parsePattern(pattern)
// Convert Windows paths to Unix paths
name = filepath.ToSlash(name)
match, err := regexp.MatchString(p.Regex, name)
if err != nil {
return ignore, err
Expand Down Expand Up @@ -113,6 +116,8 @@ func ReadGitIgnore(content io.Reader, name string) (ignore bool, err error) {
continue
}
p := parsePattern(pattern)
// Convert Windows paths to Unix paths
name = filepath.ToSlash(name)
match, err := regexp.MatchString(p.Regex, name)
if err != nil {
return ignore, err
Expand Down

0 comments on commit 3654633

Please sign in to comment.