fast_ignore 0.16.0 → 0.16.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88d6249cc842976d1b5c0e984816cfc260cc3edcbe4774ea4580e934bedcf925
4
- data.tar.gz: 3ab13efc019bee9b5cadcb45f485021132f07787bce73d66bb9ef63b76bc51ca
3
+ metadata.gz: 7952045a743c12fa1963ffba7aa81a8ca3cc81aec40b0bfc9c0e6bb6424e9433
4
+ data.tar.gz: dcacd0bdd1873638156c9b2323263cf1ee7fc349b012f40c28caa4fe10d82f91
5
5
  SHA512:
6
- metadata.gz: 853124ae1ddf1fc599e8a422580ee84ff705907a70c7ece17db72502a4468ca0d5479f918c175f91dc1915c7cccb5ad4cd7eaa956adf2d7b0a5e2fa024821c3d
7
- data.tar.gz: b90c827caa6c24c3491237ec5fb538b828b2daea879a4d94d6bc3ac4368807c7040bc0d6ea6405b8e9712483d00fddfb6d43e1a970786f374144a4d6165f59ee
6
+ metadata.gz: 35c9fedb895b3e30632b29aab2eba3369ec6512bd6c5b9cfa563156c4c0c291b5c7854877aa4c8da063b54ed97a6f132c5d903622d2a6e2fc69c57c708150c33
7
+ data.tar.gz: ca894c9a8e11471d3c1f81f959862cd16a60db784898ef0d0e4da880e063257334fdf6aad061d95c23850c726ffde781076e6c248ebecfa808701d0731fbb125
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # v0.16.1
2
+ - respect GIT_CONFIG_SYSTEM, GIT_CONFIG_NOSYSTEM and GIT_CONFIG_GLOBAL env vars the same way git does
3
+ - make the tests more resilient to whatever global config is going on.
4
+
1
5
  # v0.16.0
2
6
  - Entirely rewrite the way that git config files are read. previously it was just a regexp. now we actually parse git config files according to the same rules as git.
3
7
  - Add ruby 3 to the test matrix
data/README.md CHANGED
@@ -309,6 +309,7 @@ This is not required, and if FastIgnore does have to go to the filesystem for th
309
309
  (It does handle changing the current working directory between [`FastIgnore#allowed?`](#allowed) calls)
310
310
  - FastIgnore always matches patterns case-insensitively. (git varies by filesystem).
311
311
  - FastIgnore always outputs paths as literal UTF-8 characters. (git depends on your core.quotepath setting but by default outputs non ascii paths with octal escapes surrounded by quotes).
312
+ - git has a system-wide config file installed at `$(prefix)/etc/gitconfig`, where `prefix` is defined for git at install time. FastIgnore assumes that it will always be `/usr/local/etc/gitconfig`. if it's important your system config file is looked at, as that's where you have the core.excludesfile defined, use git's built-in way to override this by adding `export GIT_CONFIG_SYSTEM='/the/actual/location'` to your shell profile.
312
313
  - Because git looks at its own index objects and FastIgnore looks at the file system there may be some differences between FastIgnore and `git ls-files`. To avoid these differences you may want to use the [`git_ls`](https://github.com/robotdana/git_ls) gem instead
313
314
  - Tracked files that were committed before the matching ignore rule was committed will be returned by `git ls-files`, but not by FastIgnore.
314
315
  - Untracked files will be returned by FastIgnore, but not by `git ls-files`
@@ -4,15 +4,23 @@ class FastIgnore
4
4
  module GlobalGitignore
5
5
  class << self
6
6
  def path(root:)
7
- gitconfig_gitignore_path(::File.expand_path('.git/config', root)) ||
8
- gitconfig_gitignore_path(::File.expand_path('~/.gitconfig')) ||
9
- gitconfig_gitignore_path(xdg_config_path) ||
10
- gitconfig_gitignore_path('/etc/gitconfig') ||
7
+ ignore_path = gitconfigs_gitignore_path(root) ||
11
8
  default_global_gitignore_path
9
+
10
+ ignore_path unless ignore_path.empty?
12
11
  end
13
12
 
14
13
  private
15
14
 
15
+ def gitconfigs_gitignore_path(root)
16
+ gitconfig_gitignore_path(repo_config_path(root)) ||
17
+ gitconfig_gitignore_path(global_config_path) ||
18
+ gitconfig_gitignore_path(default_user_config_path) ||
19
+ gitconfig_gitignore_path(system_config_path)
20
+ rescue ::FastIgnore::GitconfigParseError
21
+ ''
22
+ end
23
+
16
24
  def gitconfig_gitignore_path(config_path)
17
25
  return unless config_path
18
26
  return unless ::File.readable?(config_path)
@@ -26,24 +34,54 @@ class FastIgnore
26
34
  ::File.expand_path(ignore_path)
27
35
  end
28
36
 
29
- def xdg_config_path
30
- xdg_config_home? && ::File.expand_path('git/config', xdg_config_home)
37
+ def default_user_config_path
38
+ return if env('GIT_CONFIG_GLOBAL')
39
+
40
+ ::File.expand_path('git/config', default_config_home)
31
41
  end
32
42
 
33
43
  def default_global_gitignore_path
34
- if xdg_config_home?
35
- ::File.expand_path('git/ignore', xdg_config_home)
44
+ ::File.expand_path('git/ignore', default_config_home)
45
+ end
46
+
47
+ def repo_config_path(root)
48
+ ::File.expand_path('.git/config', root)
49
+ end
50
+
51
+ def global_config_path
52
+ ::File.expand_path(env('GIT_CONFIG_GLOBAL', '~/.gitconfig'))
53
+ end
54
+
55
+ def system_config_path
56
+ return if env?('GIT_CONFIG_NOSYSTEM')
57
+
58
+ ::File.expand_path(env('GIT_CONFIG_SYSTEM', '/usr/local/etc/gitconfig'))
59
+ end
60
+
61
+ def default_config_home
62
+ env('XDG_CONFIG_HOME', '~/.config')
63
+ end
64
+
65
+ def env(env_var, default = nil)
66
+ value = ::ENV[env_var]
67
+
68
+ if value && (not value.empty?)
69
+ value
36
70
  else
37
- ::File.expand_path('~/.config/git/ignore')
71
+ default
38
72
  end
39
73
  end
40
74
 
41
- def xdg_config_home
42
- ::ENV['XDG_CONFIG_HOME']
43
- end
75
+ def env?(env_var)
76
+ value = ::ENV[env_var]
44
77
 
45
- def xdg_config_home?
46
- xdg_config_home && (not xdg_config_home.empty?)
78
+ if value&.match?(/\A(yes|on|true|1)\z/i)
79
+ true
80
+ elsif !value || value.match?(/\A(no|off|false|0|)\z/i)
81
+ false
82
+ else
83
+ raise ::FastIgnore::GitconfigParseError
84
+ end
47
85
  end
48
86
  end
49
87
  end
@@ -73,7 +73,7 @@ class FastIgnore
73
73
  end
74
74
 
75
75
  def build_from_root_gitignore_file(path)
76
- return unless ::File.exist?(path)
76
+ return unless path && ::File.exist?(path)
77
77
 
78
78
  build_rule_set(::File.readlines(path), false, gitignore: true)
79
79
  end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FastIgnore
4
- VERSION = '0.16.0'
4
+ VERSION = '0.16.1'
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fast_ignore
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.16.0
4
+ version: 0.16.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dana Sherson
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-09 00:00:00.000000000 Z
11
+ date: 2021-12-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -100,6 +100,20 @@ dependencies:
100
100
  - - "<"
101
101
  - !ruby/object:Gem::Version
102
102
  version: '1.12'
103
+ - !ruby/object:Gem::Dependency
104
+ name: rubocop-rake
105
+ requirement: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ type: :development
111
+ prerelease: false
112
+ version_requirements: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
103
117
  - !ruby/object:Gem::Dependency
104
118
  name: rubocop-rspec
105
119
  requirement: !ruby/object:Gem::Requirement