aboutsummaryrefslogtreecommitdiffstats
path: root/plumbing/format/gitattributes/matcher_test.go
diff options
context:
space:
mode:
authorArran Walker <arran.walker@fiveturns.org>2019-04-23 10:50:46 +0000
committerArran Walker <arran.walker@fiveturns.org>2019-04-24 09:32:18 +0000
commit86bdbfbf45a0c13aca146955a3325207ebd66c75 (patch)
treec0ff62fa4f6778c3e67f992692dc486ec03bdc14 /plumbing/format/gitattributes/matcher_test.go
parenteb243ba9a55ac029ab3f9b15157920c46e24078b (diff)
downloadgo-git-86bdbfbf45a0c13aca146955a3325207ebd66c75.tar.gz
plumbing: format/gitattributes support
Implements gitattributes parsing, matching and attribute extraction. Signed-off-by: Arran Walker <arran.walker@fiveturns.org>
Diffstat (limited to 'plumbing/format/gitattributes/matcher_test.go')
-rw-r--r--plumbing/format/gitattributes/matcher_test.go29
1 files changed, 29 insertions, 0 deletions
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")
+}