aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/gitattributes/matcher_test.go
blob: edb71a1522f06e38cea2ab0194ce979d8f0c7d5c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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")
}