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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f126e35bb048a9aa68b62eba4593cc7a040aa0ec
4
- data.tar.gz: 240a38cf94ba4d0797bfa5080c4a9cfc652c6e18
3
+ metadata.gz: 81ece9154359b604cf544524240a1609ea5e12bd
4
+ data.tar.gz: 58c24e2789f447f2bf8d441a9acf8af07c447b92
5
5
  SHA512:
6
- metadata.gz: 117bc70ee90fb3158d36300516a8e6a8d3d1a6e30dd136de484e90c3f190f1cf3ee8a0039d4239ec02d70461e46a9d41f09980155cfa100aa8eaf67eb3b668f1
7
- data.tar.gz: ae70b802be7c8a80edb5092606c75e394e1a6c9637404ea2e9ca2cd583c57ac6b8f1e54b5b78c4f87e1e743f93a771cc6c98a42785ebee6d5af444bab565d8a6
6
+ metadata.gz: 6dca0f325ef2196258736282be45ee3725b836e9e943b0a313a7021bc76c1894eb8ef1fd709ebad7377ffd13d6d52e2676c3fd0e1ba9d1a66b7b11b3a389891f
7
+ data.tar.gz: 7bf684386e42d0239cb0ebfb6d9485b6e766d43c4dbd7a2c0bca9699891df808300176ad068d096732f43c47b600204ca2f544bf93b22eef51932295328451f8
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{gitattributes}
5
- s.version = '2.3.0'
5
+ s.version = '2.4.0'
6
6
  s.platform = Gem::Platform::RUBY
7
7
 
8
8
  s.authors = ['Peter Donald']
@@ -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
- return rule.attributes if File.fnmatch?(File.join(@relative_path, rule.pattern), full_path)
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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitattributes
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.3.0
4
+ version: 2.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Peter Donald