From 86bdbfbf45a0c13aca146955a3325207ebd66c75 Mon Sep 17 00:00:00 2001 From: Arran Walker Date: Tue, 23 Apr 2019 10:50:46 +0000 Subject: plumbing: format/gitattributes support Implements gitattributes parsing, matching and attribute extraction. Signed-off-by: Arran Walker --- plumbing/format/gitattributes/matcher_test.go | 29 +++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 plumbing/format/gitattributes/matcher_test.go (limited to 'plumbing/format/gitattributes/matcher_test.go') diff --git a/plumbing/format/gitattributes/matcher_test.go b/plumbing/format/gitattributes/matcher_test.go new file mode 100644 index 0000000..edb71a1 --- /dev/null +++ b/plumbing/format/gitattributes/matcher_test.go @@ -0,0 +1,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") +} -- cgit