fast_ignore 0.12.0 → 0.12.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: 45d98b9329a3cf9935ad9bda95f89ffcea7776c19acde46b4f758cf03bad654b
4
- data.tar.gz: ec33228d9d25f5e82a8deed045c5dc2f1885e7fcf05779e079ab4a1460f981f2
3
+ metadata.gz: e68a04cc6c34d7f72a6049beb86c9808c43bae4e712a1e9e8462e8e18f331bf0
4
+ data.tar.gz: 3c015e68f03e9d387064a68d42fe6f367e60894e1a20f02945af2c6669ddcebb
5
5
  SHA512:
6
- metadata.gz: 6d03cc0337b2b5bb4b7f90adaeedf645e6fcc01a299c873cbdec743f2d13a7a6820c2269a4193d1723907e3f7de00ec4aa76d90a52efba9c022462edb5e129fe
7
- data.tar.gz: 9771665b209531cd704c8603b9791755e054f5a3f72214ef43d23dfb403263f5c00f5ebe9be27b94a63503c85e35dc3d6c4293822cf93bd8ef4dc60b6b2b7715
6
+ metadata.gz: 047ec0c2f7fe90a3bf9a23b01ec3aa054bd7770e2f3b9d38dae8e77704ef8dd7d8d1449633faa3c7aae9ecc7b4d236f8b3442e5b3dcf489cf825da85efce19e5
7
+ data.tar.gz: d9fa32ba54a4268ce530556767972fd60dbf04a24ec8a890110fd084675611721244cbdf1f1722bfc70fe41794458a7fe6a0ecbde388149308ff710e76610a43
data/.simplecov CHANGED
@@ -1,3 +1,5 @@
1
+ # frozen_string_literal: true
2
+
1
3
  SimpleCov.start do
2
4
  add_filter '/backports'
3
5
  add_filter '/spec/'
@@ -1,3 +1,6 @@
1
+ # v0.12.1
2
+ - Reads all relevant git config files when finding a global .gitignore
3
+
1
4
  # v0.12.0
2
5
  - Reads all relevant gitignore files (nested .gitignore files, global .gitignore referred to in .gitconfig, and .git/info/exclude)
3
6
 
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FastIgnore
4
- module RuleSetBuilder
4
+ module RuleSetBuilder # rubocop:disable Metrics/ModuleLength
5
5
  class << self
6
6
  # :nocov:
7
7
  using ::FastIgnore::Backports::DeletePrefixSuffix if defined?(::FastIgnore::Backports::DeletePrefixSuffix)
@@ -70,30 +70,45 @@ class FastIgnore
70
70
  return unless gitignore
71
71
 
72
72
  gi = ::FastIgnore::RuleSet.new([], false, true)
73
- gi << from_gitignore_file(gitconfig_global_gitignore_path || default_global_gitignore_path)
74
- gi << from_gitignore_file(::File.join(project_root, '.git/info/exclude'))
75
- gi << from_gitignore_file(::File.join(project_root, '.gitignore'), soft: gitignore == :auto)
73
+ gi << from_root_gitignore_file(global_gitignore_path(root: project_root))
74
+ gi << from_root_gitignore_file(::File.join(project_root, '.git/info/exclude'))
75
+ gi << from_root_gitignore_file(::File.join(project_root, '.gitignore'), soft: gitignore == :auto)
76
76
  gi
77
77
  end
78
78
 
79
- def from_gitignore_file(path, soft: true)
79
+ def from_root_gitignore_file(path, soft: true)
80
80
  return if soft && !::File.exist?(path)
81
81
 
82
82
  build_rule_set(::File.readlines(path), false, file_root: '', gitignore: true)
83
83
  end
84
84
 
85
- def gitconfig_global_gitignore_path
86
- config_path = ::File.expand_path('~/.gitconfig')
85
+ def global_gitignore_path(root:)
86
+ gitconfig_gitignore_path(::File.expand_path('.git/config', root)) ||
87
+ gitconfig_gitignore_path(::File.expand_path('~/.gitconfig')) ||
88
+ gitconfig_gitignore_path(xdg_config_path) ||
89
+ gitconfig_gitignore_path('/etc/gitconfig') ||
90
+ default_global_gitignore_path
91
+ end
92
+
93
+ def gitconfig_gitignore_path(config_path)
94
+ return unless config_path
87
95
  return unless ::File.exist?(config_path)
88
96
 
89
- ignore_path = ::File.readlines(config_path).find { |l| l.start_with?("\texcludesfile = ") }
97
+ ignore_path = ::File.readlines(config_path).find { |l| l.sub!(/\A\s*excludesfile\s*=/, '') }
90
98
  return unless ignore_path
91
99
 
92
- ignore_path.delete_prefix!("\texcludesfile = ")
93
100
  ignore_path.strip!
101
+ return ignore_path if ignore_path.empty? # don't expand path in this case
102
+
94
103
  ::File.expand_path(ignore_path)
95
104
  end
96
105
 
106
+ def xdg_config_path
107
+ return unless ENV['XDG_CONFIG_HOME'] && !ENV['XDG_CONFIG_HOME'].empty?
108
+
109
+ ::File.expand_path('git/config', ENV['XDG_CONFIG_HOME'])
110
+ end
111
+
97
112
  def default_global_gitignore_path
98
113
  if ENV['XDG_CONFIG_HOME'] && !ENV['XDG_CONFIG_HOME'].empty?
99
114
  ::File.expand_path('git/ignore', ENV['XDG_CONFIG_HOME'])
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class FastIgnore
4
- VERSION = '0.12.0'
4
+ VERSION = '0.12.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.12.0
4
+ version: 0.12.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: 2020-05-04 00:00:00.000000000 Z
11
+ date: 2020-05-24 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler