gitattributes 2.3.0 → 2.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/gitattributes.gemspec +1 -1
- data/lib/reality/git/attributes.rb +2 -1
- data/test/reality/git/test_attributes.rb +29 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 81ece9154359b604cf544524240a1609ea5e12bd
|
4
|
+
data.tar.gz: 58c24e2789f447f2bf8d441a9acf8af07c447b92
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6dca0f325ef2196258736282be45ee3725b836e9e943b0a313a7021bc76c1894eb8ef1fd709ebad7377ffd13d6d52e2676c3fd0e1ba9d1a66b7b11b3a389891f
|
7
|
+
data.tar.gz: 7bf684386e42d0239cb0ebfb6d9485b6e766d43c4dbd7a2c0bca9699891df808300176ad068d096732f43c47b600204ca2f544bf93b22eef51932295328451f8
|
data/gitattributes.gemspec
CHANGED
@@ -43,7 +43,8 @@ module Reality #nodoc
|
|
43
43
|
full_path = File.join(@path, path)
|
44
44
|
|
45
45
|
@rules.reverse.each do |rule|
|
46
|
-
|
46
|
+
full_pattern = rule.pattern[0] == '/' ? "#{@relative_path}#{rule.pattern}" : "#{@relative_path}/**/#{rule.pattern}"
|
47
|
+
return rule.attributes if File.fnmatch?(full_pattern, full_path, File::FNM_PATHNAME | File::FNM_DOTMATCH)
|
47
48
|
end
|
48
49
|
|
49
50
|
{}
|
@@ -43,6 +43,35 @@ TEXT
|
|
43
43
|
assert_equal({ 'text' => true, 'crlf' => true }, attributes.attributes('Read Me.txt'))
|
44
44
|
end
|
45
45
|
|
46
|
+
def test_exact_match_in_subdirectory
|
47
|
+
content = <<TEXT
|
48
|
+
Read[[:space:]]Me.txt text crlf
|
49
|
+
TEXT
|
50
|
+
dir = "#{working_dir}/#{::SecureRandom.hex}"
|
51
|
+
write_standard_file(dir, content)
|
52
|
+
|
53
|
+
attributes = Reality::Git::Attributes.parse(dir)
|
54
|
+
assert_equal("#{dir}/.gitattributes", attributes.attributes_file)
|
55
|
+
assert_equal(['Read[[:space:]]Me.txt text crlf'], attributes.rules.collect {|p| p.to_s})
|
56
|
+
|
57
|
+
assert_equal({ 'text' => true, 'crlf' => true }, attributes.attributes('customer/notes/Read Me.txt'))
|
58
|
+
end
|
59
|
+
|
60
|
+
def test_absolute_pattern
|
61
|
+
content = <<TEXT
|
62
|
+
/bin/doc/README.md text
|
63
|
+
TEXT
|
64
|
+
dir = "#{working_dir}/#{::SecureRandom.hex}"
|
65
|
+
write_standard_file(dir, content)
|
66
|
+
|
67
|
+
attributes = Reality::Git::Attributes.parse(dir)
|
68
|
+
assert_equal("#{dir}/.gitattributes", attributes.attributes_file)
|
69
|
+
assert_equal(['/bin/doc/README.md text'], attributes.rules.collect {|p| p.to_s})
|
70
|
+
|
71
|
+
assert_equal({ 'text' => true }, attributes.attributes('bin/doc/README.md'))
|
72
|
+
assert_equal({ }, attributes.attributes('not/matching/bin/doc/README.md'))
|
73
|
+
end
|
74
|
+
|
46
75
|
def test_gitattributes_in_non_standard_location
|
47
76
|
content = <<TEXT
|
48
77
|
* -text
|