grepfruit 4.0.1 → 4.0.2

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: d27a11eff0190c85e32b6081219b6db2b3f79e92170f85443e7e422df011bd5e
4
- data.tar.gz: 7d1ab993aa73df36b9cfd1653721757d0e6f0473413562900231da351f9dbc89
3
+ metadata.gz: a1e692e9c73cb5e153c74e9f9dad30665f77eae2c1d12335b9cda68eb19cc27e
4
+ data.tar.gz: be22dc571889bcd9e59378e8896949dfd792d966e2bb01d65ad3c4fec70329a6
5
5
  SHA512:
6
- metadata.gz: a8f66005b0f1ddc8a75747fa4c24b16e6401332fad5061b57220f766eba2a64691a46f9686c349dce4f7b7b42b308e5e7141da58177b338a5104386573f5322e
7
- data.tar.gz: 8ed7dc08c649a3becacc813a9e6f7bfbb0722c14a5b63cf3749e9a00cf2333fa75b8990ac2656d82c47dea5422bcb06e48ebc00eb413aca362fdb6d6e91b754a
6
+ metadata.gz: fb52ee14db47e883bedbfe53ab17aea9b032b87f6749910a6af441cda3fe9b413ba9e11d5baa8d6ff8b3f8271b76da61d45f4ea9db6aa67a4714124bea9c96dd
7
+ data.tar.gz: 64052138a5df15c7e3ad5f9f6e2227d60016e9cfa6539e2a7b09c5166af8924d07eb03943af522fb2daa63baafb3fe5120aad0f315161c07ba7f93e0b02e63d1
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## v4.0.2
2
+
3
+ - Fixed searches silently checking no files when the search path itself was hidden or matched an exclusion
4
+ - Fixed a crash backtrace being printed after the error message when the search path does not exist
5
+ - Fixed the whole search crashing when a file is deleted or becomes unreadable mid-search
6
+
1
7
  ## v4.0.1
2
8
 
3
9
  - Restored accidentally removed CLI progress indicator
data/exe/grepfruit CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  RubyVM::YJIT.enable if defined?(RubyVM::YJIT) && RubyVM::YJIT.respond_to?(:enable)
4
4
 
5
+ Warning[:experimental] = false
6
+
5
7
  $LOAD_PATH.unshift("#{__dir__}/../lib")
6
8
 
7
9
  require "grepfruit"
@@ -5,7 +5,10 @@ module Grepfruit
5
5
  include Grepfruit::CliDecorator
6
6
 
7
7
  def execute
8
- puts "Error: Path '#{path}' does not exist." and exit 1 unless File.exist?(path)
8
+ unless File.exist?(path)
9
+ puts "Error: Path '#{path}' does not exist."
10
+ exit 1
11
+ end
9
12
 
10
13
  unless json
11
14
  puts "Searching for #{regex.inspect} in #{path.inspect}..."
@@ -2,8 +2,6 @@ require "find"
2
2
  require "etc"
3
3
  require_relative "ractor_compat"
4
4
 
5
- Warning[:experimental] = false
6
-
7
5
  module Grepfruit
8
6
  class Search
9
7
  attr_reader :path, :regex, :exclusions, :inclusions, :excluded_paths, :excluded_lines, :truncate, :search_hidden, :jobs, :json, :count
@@ -98,14 +96,18 @@ module Grepfruit
98
96
  file_path, pattern, exc_lines, count = work
99
97
  file_results, has_matches, match_count = [], false, 0
100
98
 
101
- File.foreach(file_path).with_index do |line, line_num|
102
- next unless line.valid_encoding? && line.match?(pattern)
99
+ begin
100
+ File.foreach(file_path).with_index do |line, line_num|
101
+ next unless line.valid_encoding? && line.match?(pattern)
103
102
 
104
- next if exc_lines.any? { "#{file_path}:#{line_num + 1}".end_with?(_1) }
103
+ next if exc_lines.any? { "#{file_path}:#{line_num + 1}".end_with?(_1) }
105
104
 
106
- file_results << [file_path, line_num + 1, line] unless count
107
- has_matches = true
108
- match_count += 1
105
+ file_results << [file_path, line_num + 1, line] unless count
106
+ has_matches = true
107
+ match_count += 1
108
+ end
109
+ rescue Errno::ENOENT, Errno::EACCES, Errno::EISDIR
110
+ file_results, has_matches, match_count = [], false, 0
109
111
  end
110
112
 
111
113
  RactorCompat.yield_result(port, [file_results, has_matches, match_count])
@@ -137,7 +139,7 @@ module Grepfruit
137
139
  Find.find(path) do |file_path|
138
140
  is_file = File.file?(file_path)
139
141
 
140
- Find.prune if excluded_path?(is_file, file_path, file_path.delete_prefix("#{path}/"))
142
+ Find.prune if file_path != path && excluded_path?(is_file, file_path, file_path.delete_prefix("#{path}/"))
141
143
 
142
144
  next unless is_file && File.readable?(file_path)
143
145
 
@@ -1,3 +1,3 @@
1
1
  module Grepfruit
2
- VERSION = "4.0.1".freeze
2
+ VERSION = "4.0.2".freeze
3
3
  end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: grepfruit
3
3
  version: !ruby/object:Gem::Version
4
- version: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - enjaku4
8
8
  bindir: exe
9
9
  cert_chain: []
10
- date: 2026-07-05 00:00:00.000000000 Z
10
+ date: 2026-07-19 00:00:00.000000000 Z
11
11
  dependencies:
12
12
  - !ruby/object:Gem::Dependency
13
13
  name: dry-cli
@@ -74,7 +74,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
74
74
  - !ruby/object:Gem::Version
75
75
  version: '0'
76
76
  requirements: []
77
- rubygems_version: 4.0.8
77
+ rubygems_version: 4.0.3
78
78
  specification_version: 4
79
79
  summary: Tool for searching regex patterns in files
80
80
  test_files: []