mirror of
https://github.com/packwiz/packwiz.git
synced 2025-04-19 21:16:30 +02:00
.packwizignore files
This commit is contained in:
parent
2ab625c650
commit
e3bf7afe33
@ -11,6 +11,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/BurntSushi/toml"
|
"github.com/BurntSushi/toml"
|
||||||
|
"github.com/denormal/go-gitignore"
|
||||||
"github.com/vbauerster/mpb/v4"
|
"github.com/vbauerster/mpb/v4"
|
||||||
"github.com/vbauerster/mpb/v4/decor"
|
"github.com/vbauerster/mpb/v4/decor"
|
||||||
)
|
)
|
||||||
@ -162,14 +163,17 @@ func (in *Index) Refresh() error {
|
|||||||
pathPF, _ := filepath.Abs(in.flags.PackFile)
|
pathPF, _ := filepath.Abs(in.flags.PackFile)
|
||||||
pathIndex, _ := filepath.Abs(in.indexFile)
|
pathIndex, _ := filepath.Abs(in.indexFile)
|
||||||
|
|
||||||
progressContainer := mpb.New()
|
|
||||||
|
|
||||||
// TODO: A method of specifying pack root directory?
|
// TODO: A method of specifying pack root directory?
|
||||||
// TODO: A method of excluding files
|
|
||||||
packRoot := filepath.Dir(in.flags.PackFile)
|
packRoot := filepath.Dir(in.flags.PackFile)
|
||||||
var fileList []string
|
ignoreExists := true
|
||||||
|
pathIgnore, _ := filepath.Abs(filepath.Join(packRoot, ".packwizignore"))
|
||||||
|
ignore, err := gitignore.NewFromFile(filepath.Join(packRoot, ".packwizignore"))
|
||||||
|
if err != nil {
|
||||||
|
ignoreExists = false
|
||||||
|
}
|
||||||
|
|
||||||
err := filepath.Walk(packRoot, func(path string, info os.FileInfo, err error) error {
|
var fileList []string
|
||||||
|
err = filepath.Walk(packRoot, func(path string, info os.FileInfo, err error) error {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// TODO: Handle errors on individual files properly
|
// TODO: Handle errors on individual files properly
|
||||||
return err
|
return err
|
||||||
@ -184,6 +188,18 @@ func (in *Index) Refresh() error {
|
|||||||
if info.IsDir() {
|
if info.IsDir() {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
if ignoreExists {
|
||||||
|
if absPath == pathIgnore {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
rel, err := filepath.Rel(packRoot, path)
|
||||||
|
if err == nil {
|
||||||
|
if ignore.Ignore(filepath.ToSlash(rel)) {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fileList = append(fileList, path)
|
fileList = append(fileList, path)
|
||||||
return nil
|
return nil
|
||||||
@ -192,6 +208,7 @@ func (in *Index) Refresh() error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
progressContainer := mpb.New()
|
||||||
progress := progressContainer.AddBar(int64(len(fileList)),
|
progress := progressContainer.AddBar(int64(len(fileList)),
|
||||||
mpb.PrependDecorators(
|
mpb.PrependDecorators(
|
||||||
// simple name decorator
|
// simple name decorator
|
||||||
|
2
go.mod
2
go.mod
@ -3,8 +3,10 @@ module github.com/comp500/packwiz
|
|||||||
require (
|
require (
|
||||||
github.com/BurntSushi/toml v0.3.1
|
github.com/BurntSushi/toml v0.3.1
|
||||||
github.com/agnivade/levenshtein v1.0.2
|
github.com/agnivade/levenshtein v1.0.2
|
||||||
|
github.com/danwakefield/fnmatch v0.0.0-20160403171240-cbb64ac3d964 // indirect
|
||||||
github.com/davecgh/go-spew v1.1.1 // indirect
|
github.com/davecgh/go-spew v1.1.1 // indirect
|
||||||
github.com/daviddengcn/go-colortext v0.0.0-20180409174941-186a3d44e920 // indirect
|
github.com/daviddengcn/go-colortext v0.0.0-20180409174941-186a3d44e920 // indirect
|
||||||
|
github.com/denormal/go-gitignore v0.0.0-20180930084346-ae8ad1d07817
|
||||||
github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450 // indirect
|
github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450 // indirect
|
||||||
github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995 // indirect
|
github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995 // indirect
|
||||||
github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e // indirect
|
github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e // indirect
|
||||||
|
4
go.sum
4
go.sum
@ -4,10 +4,14 @@ github.com/VividCortex/ewma v1.1.1 h1:MnEK4VOv6n0RSY4vtRe3h11qjxL3+t0B8yOL8iMXdc
|
|||||||
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
|
github.com/VividCortex/ewma v1.1.1/go.mod h1:2Tkkvm3sRDVXaiyucHiACn4cqf7DpdyLvmxzcbUokwA=
|
||||||
github.com/agnivade/levenshtein v1.0.2 h1:xKF7WlEzoa+ZVkzBxy0ukdzI2etYiWGlTPMNTBGncKI=
|
github.com/agnivade/levenshtein v1.0.2 h1:xKF7WlEzoa+ZVkzBxy0ukdzI2etYiWGlTPMNTBGncKI=
|
||||||
github.com/agnivade/levenshtein v1.0.2/go.mod h1:JLvzGblJATanj48SD0YhHTEFGkWvw3ASLFWSiMIFXsE=
|
github.com/agnivade/levenshtein v1.0.2/go.mod h1:JLvzGblJATanj48SD0YhHTEFGkWvw3ASLFWSiMIFXsE=
|
||||||
|
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.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
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/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/daviddengcn/go-colortext v0.0.0-20180409174941-186a3d44e920 h1:d/cVoZOrJPJHKH1NdeUjyVAWKp4OpOT+Q+6T1sH7jeU=
|
github.com/daviddengcn/go-colortext v0.0.0-20180409174941-186a3d44e920 h1:d/cVoZOrJPJHKH1NdeUjyVAWKp4OpOT+Q+6T1sH7jeU=
|
||||||
github.com/daviddengcn/go-colortext v0.0.0-20180409174941-186a3d44e920/go.mod h1:dv4zxwHi5C/8AeI+4gX4dCWOIvNi7I6JCSX0HvlKPgE=
|
github.com/daviddengcn/go-colortext v0.0.0-20180409174941-186a3d44e920/go.mod h1:dv4zxwHi5C/8AeI+4gX4dCWOIvNi7I6JCSX0HvlKPgE=
|
||||||
|
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/golangplus/bytes v0.0.0-20160111154220-45c989fe5450 h1:7xqw01UYS+KCI25bMrPxwNYkSns2Db1ziQPpVq99FpE=
|
github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450 h1:7xqw01UYS+KCI25bMrPxwNYkSns2Db1ziQPpVq99FpE=
|
||||||
github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAONeMXrxql8uvOKuAZSu8aM5RUGv+1C6IJaEho=
|
github.com/golangplus/bytes v0.0.0-20160111154220-45c989fe5450/go.mod h1:Bk6SMAONeMXrxql8uvOKuAZSu8aM5RUGv+1C6IJaEho=
|
||||||
github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995 h1:f5gsjBiF9tRRVomCvrkGMMWI8W1f2OBFar2c5oakAP0=
|
github.com/golangplus/fmt v0.0.0-20150411045040-2a5d6d7d2995 h1:f5gsjBiF9tRRVomCvrkGMMWI8W1f2OBFar2c5oakAP0=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user