Skip to content

Commit

Permalink
add internal ignore package
Browse files Browse the repository at this point in the history
  • Loading branch information
nasdf committed Mar 3, 2021
1 parent dfabd17 commit 3e67cfe
Show file tree
Hide file tree
Showing 29 changed files with 381 additions and 206 deletions.
5 changes: 1 addition & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ module github.com/multiverse-vcs/go-multiverse
go 1.16

require (
github.com/alecthomas/chroma v0.8.2
github.com/bmatcuk/doublestar/v3 v3.0.0
github.com/golang/groupcache v0.0.0-20191027212112-611e8accdfc9 // indirect
github.com/ipfs/go-bitswap v0.3.2
github.com/ipfs/go-block-format v0.0.2
github.com/ipfs/go-blockservice v0.1.4
github.com/ipfs/go-cid v0.0.7
github.com/ipfs/go-datastore v0.4.5
Expand All @@ -22,7 +21,6 @@ require (
github.com/ipfs/go-path v0.0.9
github.com/ipfs/go-unixfs v0.2.4
github.com/ipld/go-car v0.1.0
github.com/julienschmidt/httprouter v1.3.0
github.com/kr/text v0.2.0 // indirect
github.com/libp2p/go-libp2p v0.12.0
github.com/libp2p/go-libp2p-connmgr v0.2.4
Expand All @@ -40,7 +38,6 @@ require (
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e // indirect
github.com/onsi/ginkgo v1.14.0 // indirect
github.com/polydawn/refmt v0.0.0-20190807091052-3d65705ee9f1
github.com/sabhiram/go-gitignore v0.0.0-20201211210132-54b8a0bf510f
github.com/urfave/cli/v2 v2.3.0
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a // indirect
golang.org/x/net v0.0.0-20200707034311-ab3426394381 // indirect
Expand Down
25 changes: 2 additions & 23 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -11,19 +11,12 @@ github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAE
github.com/Stebalien/go-bitfield v0.0.1 h1:X3kbSSPUaJK60wV2hjOPZwmpljr6VGCqdq4cBLhbQBo=
github.com/Stebalien/go-bitfield v0.0.1/go.mod h1:GNjFpasyUVkHMsfEOk8EFLJ9syQ6SI+XWrX9Wf2XH0s=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38 h1:smF2tmSOzy2Mm+0dGI2AIUHY+w0BUc+4tn40djz7+6U=
github.com/alecthomas/assert v0.0.0-20170929043011-405dbfeb8e38/go.mod h1:r7bzyVFMNntcxPZXK3/+KdruV1H5KSlyVY0gc+NgInI=
github.com/alecthomas/chroma v0.8.2 h1:x3zkuE2lUk/RIekyAJ3XRqSCP4zwWDfcw/YJCuCAACg=
github.com/alecthomas/chroma v0.8.2/go.mod h1:sko8vR34/90zvl5QdcUdvzL3J8NKjAUx9va9jPuFNoM=
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721 h1:JHZL0hZKJ1VENNfmXvHbgYlbUOvpzYzvy2aZU5gXVeo=
github.com/alecthomas/colour v0.0.0-20160524082231-60882d9e2721/go.mod h1:QO9JBoKquHd+jz9nshCh40fOfO+JzsoXy8qTHF68zU0=
github.com/alecthomas/kong v0.2.4/go.mod h1:kQOmtJgV+Lb4aj+I2LEn40cbtawdWJ9Y8QLq+lElKxE=
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897 h1:p9Sln00KOTlrYkxI1zYWl1QLnEqAqEARBEYa8FQnQcY=
github.com/alecthomas/repr v0.0.0-20180818092828-117648cd9897/go.mod h1:xTS7Pm1pD1mvyM075QCDSRqH6qRLXylzS24ZTpRiSzQ=
github.com/armon/consul-api v0.0.0-20180202201655-eb2c6b5be1b6/go.mod h1:grANhF5doyWs3UAsr3K4I6qtAmlQcZDesFNEHPZAzj8=
github.com/benbjohnson/clock v1.0.2/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
github.com/benbjohnson/clock v1.0.3 h1:vkLuvpK4fmtSCuo60+yC63p7y0BmQ8gm5ZXGuBCJyXg=
github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM=
github.com/bmatcuk/doublestar/v3 v3.0.0 h1:TQtVPlDnAYwcrVNB2JiGuMc++H5qzWZd9PhkNo5WyHI=
github.com/bmatcuk/doublestar/v3 v3.0.0/go.mod h1:6PcTVMw80pCY1RVuoqu3V++99uQB3vsSYKPTd8AWA0k=
github.com/btcsuite/btcd v0.0.0-20190213025234-306aecffea32/go.mod h1:DrZx5ec/dmnfpw9KyYoQyYo7d0KEvTkk/5M/vbZjAr8=
github.com/btcsuite/btcd v0.0.0-20190523000118-16327141da8c/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI=
github.com/btcsuite/btcd v0.0.0-20190605094302-a0d1e3e36d50/go.mod h1:3J08xEfcugPacsc34/LKRU2yO7YmuT8yt28J8k2+rrI=
Expand Down Expand Up @@ -60,8 +53,6 @@ github.com/crackcomm/go-gitignore v0.0.0-20170627025303-887ab5e44cc3/go.mod h1:p
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
github.com/cskr/pubsub v1.0.2 h1:vlOzMhl6PFn60gRlTQQsIfVwaPB/B/8MziK8FhEPt/0=
github.com/cskr/pubsub v1.0.2/go.mod h1:/8MzYXk/NJAz782G8RPkFzXTZVu63VotefPnR9TIRis=
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 v0.0.0-20171005155431-ecdeabc65495/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
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=
Expand All @@ -81,8 +72,6 @@ github.com/dgraph-io/ristretto v0.0.2/go.mod h1:KPxhHT9ZxKefz+PCeOGsrHpl1qZ7i70d
github.com/dgryski/go-farm v0.0.0-20190104051053-3adb47b1fb0f/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2 h1:tdlZCpZ/P9DhczCTSixgIKmwPv6+wP5DGjqLYw5SUiA=
github.com/dgryski/go-farm v0.0.0-20190423205320-6a90982ecee2/go.mod h1:SqUrOPUnsFjfmXRMNPybcSiG0BgUW2AuFH8PAnS2iTw=
github.com/dlclark/regexp2 v1.2.0 h1:8sAhBGEM0dRWogWqWyQeIJnxjWO6oIjl8FKqREDsGfk=
github.com/dlclark/regexp2 v1.2.0/go.mod h1:2pZnwuY/m+8K6iRw6wQdMtk+rH5tNGR1i55kozfMjCc=
github.com/dustin/go-humanize v1.0.0 h1:VSnTsYCnlFHaM2/igO1h6X3HA71jcobQuxemgkq4zYo=
github.com/dustin/go-humanize v1.0.0/go.mod h1:HtrtbFcZ19U5GC7JDqmcUSB87Iq5E25KnS6fMYU6eOk=
github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4=
Expand Down Expand Up @@ -306,8 +295,6 @@ github.com/jrick/logrotate v1.0.0/go.mod h1:LNinyqDIJnpAur+b8yyulnQw/wDuN1+BYKlT
github.com/jtolds/gls v4.2.1+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo=
github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU=
github.com/julienschmidt/httprouter v1.3.0 h1:U0609e9tgbseu3rBINet9P48AI/D3oJs4dN7jwJOQ1U=
github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM=
github.com/kami-zh/go-capturer v0.0.0-20171211120116-e492ea43421d/go.mod h1:P2viExyCEfeWGU259JnaQ34Inuec4R38JCyBx2edgD0=
github.com/kisielk/errcheck v1.1.0/go.mod h1:EZBBE59ingxPouuu3KfxchcWSUPOHkagtvWXihfKN4Q=
github.com/kisielk/errcheck v1.2.0/go.mod h1:/BMXB+zMLi60iA8Vv6Ksmxu/1UDYcXs4uQLJ+jE2L00=
Expand Down Expand Up @@ -581,12 +568,9 @@ github.com/mailru/easyjson v0.0.0-20180823135443-60711f1a8329/go.mod h1:C1wdFJiN
github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU=
github.com/mattn/go-colorable v0.1.1/go.mod h1:FuOcm+DKB9mbwrcAfNl7/TZVBZ6rcnceauSikq3lYCQ=
github.com/mattn/go-colorable v0.1.2/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE=
github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc=
github.com/mattn/go-isatty v0.0.4/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4=
github.com/mattn/go-isatty v0.0.5/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s=
github.com/mattn/go-isatty v0.0.12 h1:wuysRhFDzyxgEmMf5xjvJ2M9dZoWAXNNr5LSBS7uHXY=
github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU=
github.com/mgutz/ansi v0.0.0-20170206155736-9520e82c474b/go.mod h1:01TrycV0kFyexm33Z7vhZRXopbI8J3TDReVlkTgMUxE=
github.com/miekg/dns v1.1.12/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg=
github.com/miekg/dns v1.1.28/go.mod h1:KNUDUusw/aVsxyTYZM1oqvCicbwhgbNgztCETuNZ7xM=
Expand Down Expand Up @@ -702,9 +686,6 @@ github.com/russross/blackfriday v1.5.2 h1:HyvC0ARfnZBqnXwABFeSZHpKvJHJJfPz81GNue
github.com/russross/blackfriday v1.5.2/go.mod h1:JO/DiYxRf+HjHt06OyowR9PTA263kcR/rfWxYHBV53g=
github.com/russross/blackfriday/v2 v2.0.1 h1:lPqVAte+HuHNfhJ/0LC98ESWRz8afy9tM/0RK8m9o+Q=
github.com/russross/blackfriday/v2 v2.0.1/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM=
github.com/sabhiram/go-gitignore v0.0.0-20201211210132-54b8a0bf510f h1:8P2MkG70G76gnZBOPGwmMIgwBb/rESQuwsJ7K8ds4NE=
github.com/sabhiram/go-gitignore v0.0.0-20201211210132-54b8a0bf510f/go.mod h1:+ePHsJ1keEjQtpvf9HHw0f4ZeJ0TLRsxhunSI2hYJSs=
github.com/sergi/go-diff v1.0.0/go.mod h1:0CfEIISq7TuYL3j771MWULgwwjU+GofnZX9QAmXWZgo=
github.com/sergi/go-diff v1.1.0 h1:we8PVUC3FE2uYfodKH/nBHMSetSfHDR6scGdBi+erh0=
github.com/sergi/go-diff v1.1.0/go.mod h1:STckp+ISIX8hZLjrqAeVduY0gWCT9IjLuqbuNXdaHfM=
github.com/shurcooL/sanitized_anchor_name v1.0.0 h1:PdmoCO6wvbs+7yrJyMORt4/BmY5IYyJwS/kOiWx8mHo=
Expand Down Expand Up @@ -853,11 +834,9 @@ golang.org/x/sys v0.0.0-20190904154756-749cb33beabd/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20191120155948-bd437916bb0e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200413165638-669c56c373c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200519105757-fe76b779f299/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210123111255-9b0068b26619 h1:yLLDsUUPDliIQpKl7BjVb1igwngIMH2GBjo1VpwLTE0=
golang.org/x/sys v0.0.0-20210123111255-9b0068b26619/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
60 changes: 60 additions & 0 deletions internal/ignore/ignore.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
package ignore

import (
"os"
"path/filepath"
"strings"
)

// IgnoreFile is the name of the ignore file.
const IgnoreFile = ".multignore"

// Filter is a list of paths to ignore.
type Filter []Rule

// New returns a new ignore filter.
func New(dir string, patterns ...string) Filter {
var rules []Rule
for _, p := range patterns {
rule := ParseRule(filepath.Join(dir, p))
rules = append(rules, rule)
}

return Filter(rules)
}

// Load returns the ignore filter from the given directory.
func Load(dir string) (Filter, error) {
data, err := os.ReadFile(filepath.Join(dir, IgnoreFile))
if os.IsNotExist(err) {
return nil, nil
}

if err != nil {
return nil, err
}

patterns := strings.Split(string(data), "\n")
return New(dir, patterns...), nil
}

// Match returns true if the path matches any ignore rules.
func (f Filter) Match(name string) bool {
for _, r := range f {
if match, _ := r.Match(name); match {
return true
}
}

return false
}

// Merge combines the ignore rules with the other ignore.
func (f Filter) Merge(other Filter) Filter {
var merge Filter
for _, r := range other {
merge = append(merge, r)
}

return append(f, merge...)
}
58 changes: 58 additions & 0 deletions internal/ignore/ignore_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
package ignore

import (
"testing"
)

func TestMatch(t *testing.T) {
ignore := New("test", "*.exe")

if !ignore.Match("test/foo/bar.exe") {
t.Error("expected ignore to match")
}

if !ignore.Match("foo.exe") {
t.Error("expected ignore to match")
}
}

func TestLoad(t *testing.T) {
ignore, err := Load("testdata")
if err != nil {
t.Fatal("failed to load ignore file")
}

if !ignore.Match("foo/bar") {
t.Error("expected ignore to match")
}

if !ignore.Match("bar/foo") {
t.Error("expected ignore to match")
}

if ignore.Match("foo.exe") {
t.Error("expected ignore not to match")
}
}

func TestMerge(t *testing.T) {
ignore, err := Load("testdata")
if err != nil {
t.Fatal("failed to load ignore file")
}

other := New("test", "*.exe")
merge := ignore.Merge(other)

if !merge.Match("foo/bar") {
t.Error("expected ignore to match")
}

if !merge.Match("bar/foo") {
t.Error("expected ignore to match")
}

if !merge.Match("foo.exe") {
t.Error("expected ignore to match")
}
}
79 changes: 79 additions & 0 deletions internal/ignore/rule.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
package ignore

import (
"path/filepath"
"strings"
)

// Rule is used to match file paths.
type Rule interface {
// Match returns true if the path matches.
Match(string) (bool, error)
}

// compile time interface checks
var _ Rule = (*NegateRule)(nil)
var _ Rule = (BaseRule)("")
var _ Rule = (PathRule)("")
var _ Rule = (EmptyRule)("")

// NegateRule negates a rule.
type NegateRule struct {
wrapped Rule
}

// BaseRule matches the base of the path.
type BaseRule string

// PathRule matches the entire path.
type PathRule string

// EmptyRule never matches.
type EmptyRule string

// Match returns true if the path matches.
func (r NegateRule) Match(name string) (bool, error) {
match, err := r.wrapped.Match(name)
return !match, err
}

// Match returns true if the path matches.
func (r BaseRule) Match(name string) (bool, error) {
base := filepath.Base(name)
return filepath.Match(string(r), base)
}

// Match returns true if the path matches.
func (r PathRule) Match(name string) (bool, error) {
return filepath.Match(string(r), name)
}

// Match returns true if the path matches.
func (r EmptyRule) Match(name string) (bool, error) {
return false, nil
}

// ParseRule returns a rule for the given pattern.
func ParseRule(pattern string) Rule {
pattern = strings.TrimSpace(pattern)
if pattern == "" {
return EmptyRule(pattern)
}

if strings.HasPrefix(pattern, "#") {
return EmptyRule(pattern)
}

var rule Rule
if strings.Contains(pattern, "/") {
rule = PathRule(pattern)
} else {
rule = BaseRule(filepath.Base(pattern))
}

if strings.HasPrefix(pattern, "!") {
rule = NegateRule{rule}
}

return rule
}
7 changes: 7 additions & 0 deletions internal/ignore/testdata/.multignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# *.exe

foo

!bar

/foo/bar
5 changes: 3 additions & 2 deletions pkg/command/checkout.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ import (
"os"

cid "github.com/ipfs/go-cid"
"github.com/urfave/cli/v2"

"github.com/multiverse-vcs/go-multiverse/pkg/command/context"
"github.com/multiverse-vcs/go-multiverse/pkg/dag"
"github.com/multiverse-vcs/go-multiverse/pkg/fs"
"github.com/multiverse-vcs/go-multiverse/pkg/object"
"github.com/urfave/cli/v2"
)

// NewCheckoutCommand returns a new cli command.
Expand Down Expand Up @@ -71,7 +72,7 @@ func NewCheckoutCommand() *cli.Command {
cli.ShowAppHelpAndExit(c, -1)
}

stash, err := cc.Tree(c.Context)
stash, err := fs.Add(c.Context, cc.DAG, cc.Root, context.DefaultIgnore)
if err != nil {
return err
}
Expand Down
9 changes: 5 additions & 4 deletions pkg/command/commit.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ import (
"errors"
"os"

"github.com/urfave/cli/v2"

"github.com/multiverse-vcs/go-multiverse/pkg/command/context"
"github.com/multiverse-vcs/go-multiverse/pkg/dag"
"github.com/multiverse-vcs/go-multiverse/pkg/fs"
"github.com/multiverse-vcs/go-multiverse/pkg/object"
"github.com/urfave/cli/v2"
)

// NewCommitCommand returns a new cli command.
Expand All @@ -33,13 +35,12 @@ func NewCommitCommand() *cli.Command {
return err
}

branch := cc.Config.Branches[cc.Config.Branch]

tree, err := cc.Tree(c.Context)
tree, err := fs.Add(c.Context, cc.DAG, cc.Root, context.DefaultIgnore)
if err != nil {
return err
}

branch := cc.Config.Branches[cc.Config.Branch]
diffs, err := dag.Status(c.Context, cc.DAG, tree, branch.Head)
if err != nil {
return err
Expand Down
Loading

0 comments on commit 3e67cfe

Please sign in to comment.