File: matcher_test.go

package info (click to toggle)
golang-github-go-git-go-git 5.4.2-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 3,072 kB
  • sloc: sh: 61; makefile: 29
file content (29 lines) | stat: -rw-r--r-- 778 bytes parent folder | download | duplicates (2)
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")
}