aboutsummaryrefslogblamecommitdiffstats
path: root/plumbing/format/gitattributes/matcher_test.go
blob: edb71a1522f06e38cea2ab0194ce979d8f0c7d5c (plain) (tree)




























                                                                                          
package gitattributes

import (
	"strings"

	. "gopkg.in/check.v1"
)

func (s *MatcherSuite) TestMatcher_Match(c *C) {
	lines := []string{
		"[attr]binary -diff -merge -text",
		"**/middle/v[uo]l?ano binary text eol=crlf",
		"volcano -eol",
		"foobar diff merge text eol=lf foo=bar",
	}

	ma, err := ReadAttributes(strings.NewReader(strings.Join(lines, "\n")), nil, true)
	c.Assert(err, IsNil)

	m := NewMatcher(ma)
	results, matched := m.Match([]string{"head", "middle", "vulkano"}, nil)

	c.Assert(matched, Equals, true)
	c.Assert(results["binary"].IsSet(), Equals, true)
	c.Assert(results["diff"].IsUnset(), Equals, true)
	c.Assert(results["merge"].IsUnset(), Equals, true)
	c.Assert(results["text"].IsSet(), Equals, true)
	c.Assert(results["eol"].Value(), Equals, "crlf")
}