mirror of
https://github.com/packwiz/packwiz.git
synced 2025-05-02 18:46:31 +02:00
Fix ignore file inconsistencies (#88)
* Fix ignore file inconsistencies .packwizignore is supposed to work like .gitignore, yet it fails miserably at doing so, being able to ignore only global patterns like *.zip, and failing at patterns like /*.zip. This commit introduces two changes to fix the issue: - First, it uses a more up-to-date library. denormal/go-gitignore has not been updated since 2018 and has long open issues and pull requests, one of which tries to address leading slash ignoring, a-la /*.zip. denormal account seems to be abandoned since around the same year, so it makes sense to find a new library that does roughly the same thing. Gladly so, there's actually a library by sabhiram that shares the same name (but not the package name itself - which is just ignore - so it probably requires aliasing when importing). - Secondly, it checks relative paths against ignore file instead of the absolute ones, which makes it possible to use leading slash (and probably some other features) with the new library. From personal tests, it seems to address most - if not all - of the inconsistencies. However, since it's a different library more throughout testing probably wouldn't hurt to make sure it didn't break anything. * Move dependency to main block
This commit is contained in:
parent
e233ac09c7
commit
f41235b04c
@ -10,7 +10,7 @@ import (
|
||||
"time"
|
||||
|
||||
"github.com/BurntSushi/toml"
|
||||
"github.com/denormal/go-gitignore"
|
||||
gitignore "github.com/sabhiram/go-gitignore"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/vbauerster/mpb/v4"
|
||||
"github.com/vbauerster/mpb/v4/decor"
|
||||
@ -180,7 +180,7 @@ func (in *Index) Refresh() error {
|
||||
packRoot := in.GetPackRoot()
|
||||
ignoreExists := true
|
||||
pathIgnore, _ := filepath.Abs(filepath.Join(packRoot, ".packwizignore"))
|
||||
ignore, err := gitignore.NewFromFile(filepath.Join(packRoot, ".packwizignore"))
|
||||
ignore, err := gitignore.CompileIgnoreFile(filepath.Join(packRoot, ".packwizignore"))
|
||||
if err != nil {
|
||||
ignoreExists = false
|
||||
}
|
||||
@ -206,7 +206,7 @@ func (in *Index) Refresh() error {
|
||||
return nil
|
||||
}
|
||||
|
||||
if ignore.Ignore(absPath) {
|
||||
if ignore.MatchesPath(path) {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
3
go.mod
3
go.mod
@ -5,15 +5,14 @@ require (
|
||||
github.com/Masterminds/semver/v3 v3.1.1
|
||||
github.com/VividCortex/ewma v1.2.0 // indirect
|
||||
github.com/aviddiviner/go-murmur v0.0.0-20150519214947-b9740d71e571
|
||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect
|
||||
github.com/daviddengcn/go-colortext v1.0.0 // indirect
|
||||
github.com/denormal/go-gitignore v0.0.0-20180930084346-ae8ad1d07817
|
||||
github.com/fatih/camelcase v1.0.0
|
||||
github.com/igorsobreira/titlecase v0.0.0-20140109233139-4156b5b858ac
|
||||
github.com/kylelemons/godebug v1.1.0 // indirect
|
||||
github.com/mattn/go-isatty v0.0.13 // indirect
|
||||
github.com/mitchellh/mapstructure v1.4.1
|
||||
github.com/russross/blackfriday/v2 v2.1.0 // indirect
|
||||
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06
|
||||
github.com/sahilm/fuzzy v0.1.0
|
||||
github.com/skratchdot/open-golang v0.0.0-20200116055534-eef842397966
|
||||
github.com/spf13/cobra v1.1.3
|
||||
|
6
go.sum
6
go.sum
@ -78,15 +78,11 @@ github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSV
|
||||
github.com/coreos/pkg v0.0.0-20180928190104-399ea9e2e55f/go.mod h1:E3G3o1h8I7cfcXa63jLwjI0eiQQMgzzUDFVpN/nH/eA=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0 h1:EoUDS0afbrsXAZ9YQ9jdu/mZ2sXgT1/2yyNng4PGlyM=
|
||||
github.com/cpuguy83/go-md2man/v2 v2.0.0/go.mod h1:maD7wRr/U5Z6m/iR4s+kqSMx2CaBsrgA7czyZG/E6dU=
|
||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 h1:y5HC9v93H5EPKqaS1UYVg1uYah5Xf51mBfIoWehClUQ=
|
||||
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964/go.mod h1:Xd9hchkHSWYkEqJwUGisez3G1QY8Ryz0sdWrLPMGjLk=
|
||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||
github.com/daviddengcn/go-colortext v1.0.0 h1:ANqDyC0ys6qCSvuEK7l3g5RaehL/Xck9EX8ATG8oKsE=
|
||||
github.com/daviddengcn/go-colortext v1.0.0/go.mod h1:zDqEI5NVUop5QPpVJUxE9UO10hRnmkD5G4Pmri9+m4c=
|
||||
github.com/denormal/go-gitignore v0.0.0-20180930084346-ae8ad1d07817 h1:0nsrg//Dc7xC74H/TZ5sYR8uk4UQRNjsw8zejqH5a4Q=
|
||||
github.com/denormal/go-gitignore v0.0.0-20180930084346-ae8ad1d07817/go.mod h1:C/+sI4IFnEpCn6VQ3GIPEp+FrQnQw+YQP3+n+GdGq7o=
|
||||
github.com/dgrijalva/jwt-go v3.2.0+incompatible/go.mod h1:E3ru+11k8xSBh+hMPgOLZmtrrCbhqsmaPHjLKYnJCaQ=
|
||||
github.com/dgryski/go-sip13 v0.0.0-20181026042036-e10d5fee7954/go.mod h1:vAd38F8PWV+bWy6jNmig1y/TA+kYO4g3RSRF0IAv0no=
|
||||
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
|
||||
@ -288,6 +284,8 @@ github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQD
|
||||
github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk=
|
||||
github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
|
||||
github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts=
|
||||
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06 h1:OkMGxebDjyw0ULyrTYWeN0UNCCkmCWfjPnIA2W6oviI=
|
||||
github.com/sabhiram/go-gitignore v0.0.0-20210923224102-525f6e181f06/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
|
||||
github.com/sahilm/fuzzy v0.1.0 h1:FzWGaw2Opqyu+794ZQ9SYifWv2EIXpwP4q8dY1kDAwI=
|
||||
github.com/sahilm/fuzzy v0.1.0/go.mod h1:VFvziUEIMCrT6A6tw2RFIXPXXmzXbOsSHF0DOI8ZK9Y=
|
||||
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc=
|
||||
|
Loading…
x
Reference in New Issue
Block a user