fcom 0.10.0 → 0.11.0

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: 68129781aa3cc8ae384295332a34c05c270d2c9dbbb60a415783e4e5305100b0
4
- data.tar.gz: 5629104bbb23e2a2c196b3f39bed19403ced76bac870572a170ea659d5b1fd49
3
+ metadata.gz: 119bff12adbc5cad5c6cea84a16ecb4f60c86a3c660e8d14f8702f1bfb11825b
4
+ data.tar.gz: 6388da5105a976113ce17a7b3b4c4e057e67692e73050f98c1e92f87e325ce95
5
5
  SHA512:
6
- metadata.gz: d749e928e35e8d967d24405f4003fec4493317c003d046ee394f0e7daf3ec01acd3eb3d2542ead6df1fa3fe8aebbc19297807aeab9ca198ffea2e698d3adf144
7
- data.tar.gz: af623c1d0bec21086dd67e3b6641cb042610a5e19bc9c0cce524eebe16903b2f4b835cc03ca444bd1c243a3233d7363b299595b9a75de5306fa1069f7cee6bf4
6
+ metadata.gz: 8647b6f1bda783995ec33ba3783f33a749fb658070e7925811fcb0cc2220788ae2714f22a19870d64b7cbcc74ed49231d0092093572dcbe9c0fb023e1b3a6324
7
+ data.tar.gz: bad3ca0c6d631474232afa105a0e690a9e87c86c7ee1ecf865944923093568e8f9102ae84eec83ee98f2b963c8e7bf718748f58599dd966fa8d02e8e4b76ad9f
@@ -1,8 +1,11 @@
1
+ ---
1
2
  version: 2
2
3
  updates:
3
- - package-ecosystem: bundler
4
- directory: "/"
5
- schedule:
6
- interval: daily
7
- time: "04:04"
8
- timezone: America/Chicago
4
+ - package-ecosystem: bundler
5
+ directory: "/"
6
+ schedule:
7
+ interval: daily
8
+ time: "04:04"
9
+ timezone: America/Chicago
10
+ allow:
11
+ - dependency-type: all
data/.ruby-version CHANGED
@@ -1 +1 @@
1
- 3.3.3
1
+ 3.3.4
data/CHANGELOG.md CHANGED
@@ -1,3 +1,6 @@
1
+ ## v0.11.0 (2024-07-16)
2
+ - Search back through renames
3
+
1
4
  ## v0.10.0 (2024-06-28)
2
5
  - Enforce only major and minor parts of required Ruby version (loosening the
3
6
  required Ruby version from 3.3.3 to 3.3.0)
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- fcom (0.10.0)
4
+ fcom (0.11.0)
5
5
  activesupport (>= 6, < 8)
6
6
  memo_wise (>= 1.7, < 2)
7
7
  rainbow (>= 3.0, < 4)
@@ -35,10 +35,10 @@ GEM
35
35
  language_server-protocol (3.17.0.3)
36
36
  memo_wise (1.9.0)
37
37
  method_source (1.1.0)
38
- minitest (5.24.0)
38
+ minitest (5.24.1)
39
39
  mutex_m (0.2.0)
40
40
  parallel (1.25.1)
41
- parser (3.3.3.0)
41
+ parser (3.3.4.0)
42
42
  ast (~> 2.4.1)
43
43
  racc
44
44
  prism (0.30.0)
@@ -52,7 +52,7 @@ GEM
52
52
  rainbow (3.1.1)
53
53
  rake (13.2.1)
54
54
  regexp_parser (2.9.2)
55
- rexml (3.3.1)
55
+ rexml (3.3.2)
56
56
  strscan
57
57
  rspec (3.13.0)
58
58
  rspec-core (~> 3.13.0)
@@ -67,13 +67,13 @@ GEM
67
67
  diff-lcs (>= 1.2.0, < 2.0)
68
68
  rspec-support (~> 3.13.0)
69
69
  rspec-support (3.13.1)
70
- rubocop (1.64.1)
70
+ rubocop (1.65.0)
71
71
  json (~> 2.3)
72
72
  language_server-protocol (>= 3.17.0)
73
73
  parallel (~> 1.10)
74
74
  parser (>= 3.3.0.2)
75
75
  rainbow (>= 2.2.2, < 4.0)
76
- regexp_parser (>= 1.8, < 3.0)
76
+ regexp_parser (>= 2.4, < 3.0)
77
77
  rexml (>= 3.2.5, < 4.0)
78
78
  rubocop-ast (>= 1.31.1, < 2.0)
79
79
  ruby-progressbar (~> 1.7)
@@ -85,15 +85,15 @@ GEM
85
85
  rubocop-ast (>= 1.31.1, < 2.0)
86
86
  rubocop-rake (0.6.0)
87
87
  rubocop (~> 1.0)
88
- rubocop-rspec (3.0.1)
88
+ rubocop-rspec (3.0.3)
89
89
  rubocop (~> 1.61)
90
90
  ruby-progressbar (1.13.0)
91
- runger_release_assistant (0.8.0)
91
+ runger_release_assistant (0.10.0)
92
92
  activesupport (>= 6, < 8)
93
93
  memo_wise (>= 1.7, < 2)
94
94
  rainbow (>= 3.0, < 4)
95
95
  slop (~> 4.8)
96
- runger_style (2.8.0)
96
+ runger_style (2.12.0)
97
97
  prism (>= 0.24.0)
98
98
  rubocop (>= 1.38.0, < 2)
99
99
  slop (4.10.1)
@@ -120,7 +120,7 @@ DEPENDENCIES
120
120
  runger_style
121
121
 
122
122
  RUBY VERSION
123
- ruby 3.3.3p89
123
+ ruby 3.3.4p94
124
124
 
125
125
  BUNDLED WITH
126
126
  2.5.11
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+
3
+ set -euo pipefail # exit on any error, don't allow undefined variables, pipes don't swallow errors
4
+
5
+ lint gitleaks
6
+
7
+ background-and-notify lint rubocop
8
+ background-and-notify lint shellcheck
data/lib/fcom/querier.rb CHANGED
@@ -5,6 +5,7 @@ require_relative 'options_helpers.rb'
5
5
  # This class executes a system command to retrieve the git history, which is passed through `rg`
6
6
  # (ripgrep), and then ultimately is fed back to `fcom` for parsing.
7
7
  class Fcom::Querier
8
+ prepend MemoWise
8
9
  include ::Fcom::OptionsHelpers
9
10
 
10
11
  def initialize(options)
@@ -13,6 +14,7 @@ class Fcom::Querier
13
14
 
14
15
  # rubocop:disable Metrics/CyclomaticComplexity
15
16
  # rubocop:disable Metrics/PerceivedComplexity
17
+ # rubocop:disable Metrics/MethodLength
16
18
  def query
17
19
  expression_to_match = search_string
18
20
  expression_to_match = Regexp.escape(expression_to_match).gsub('\\ ', ' ') unless regex_mode?
@@ -24,37 +26,88 @@ class Fcom::Querier
24
26
 
25
27
  quote = expression_to_match.include?('"') ? "'" : '"'
26
28
 
27
- command = <<~COMMAND.squish
28
- git log
29
- --format="commit %s|%H|%an|%cr (%ci)"
30
- --patch
31
- --full-diff
32
- --no-textconv
33
- #{%(--author="#{author}") if author}
34
- #{"--since=#{days}.day" unless days.nil?}
35
- --
36
- #{path}
37
- |
38
-
39
- rg #{quote}(#{expression_to_match})|(^commit )|(^diff )#{quote}
40
- --color never
41
- #{'--ignore-case' if ignore_case?}
42
- #{@options[:rg_options]}
43
- |
44
-
45
- #{'exe/' if development?}fcom #{quote}#{search_string}#{quote}
46
- #{"--days #{days}" if days}
47
- #{'--regex' if regex_mode?}
48
- #{'--debug' if debug?}
49
- #{'--ignore-case' if ignore_case?}
50
- --path #{path}
51
- --parse-mode
52
- --repo #{repo}
53
- COMMAND
54
-
55
- Fcom.logger.debug("Executing command: #{command}")
56
- system(command)
29
+ commands =
30
+ filename_by_most_recent_containing_commit.map do |commit, path_at_commit|
31
+ <<~COMMAND.squish
32
+ git log
33
+ --format="commit %s|%H|%an|%cr (%ci)"
34
+ --patch
35
+ --full-diff
36
+ --no-textconv
37
+ #{%(--author="#{author}") if author}
38
+ #{"--since=#{days}.day" unless days.nil?}
39
+ #{commit}
40
+ --
41
+ #{path_at_commit}
42
+ |
43
+
44
+ rg #{quote}(#{expression_to_match})|(^commit )|(^diff )#{quote}
45
+ --color never
46
+ #{'--ignore-case' if ignore_case?}
47
+ #{@options[:rg_options]}
48
+ |
49
+
50
+ #{'exe/' if development?}fcom #{quote}#{search_string}#{quote}
51
+ #{"--days #{days}" if days}
52
+ #{'--regex' if regex_mode?}
53
+ #{'--debug' if debug?}
54
+ #{'--ignore-case' if ignore_case?}
55
+ --path #{path_at_commit}
56
+ --parse-mode
57
+ --repo #{repo}
58
+ COMMAND
59
+ end
60
+
61
+ previous_command_generated_output = false
62
+
63
+ commands.each do |command|
64
+ Fcom.logger.debug("Executing command: #{command}")
65
+ output = `#{command}`
66
+
67
+ if output.empty?
68
+ previous_command_generated_output = false
69
+ else
70
+ if previous_command_generated_output
71
+ puts("\n\n") # print blank lines for spacing
72
+ end
73
+
74
+ previous_command_generated_output = true
75
+
76
+ puts(output)
77
+ end
78
+ end
57
79
  end
80
+ # rubocop:enable Metrics/MethodLength
58
81
  # rubocop:enable Metrics/PerceivedComplexity
59
82
  # rubocop:enable Metrics/CyclomaticComplexity
83
+
84
+ private
85
+
86
+ memo_wise \
87
+ def filename_by_most_recent_containing_commit
88
+ {
89
+ most_recent_commit_with_file => path,
90
+ }.merge(renames.transform_keys { "#{_1}^" })
91
+ end
92
+
93
+ memo_wise \
94
+ def most_recent_commit_with_file
95
+ if system(%(test -e "#{path}"))
96
+ 'HEAD'
97
+ else
98
+ `git log --all -1 --format="%H" -- "#{path}"`.rstrip
99
+ end
100
+ end
101
+
102
+ memo_wise \
103
+ def renames
104
+ `git log HEAD --format=%H --name-status --follow --diff-filter=R -- '#{path}'`.
105
+ split(/\n(?=[0-9a-f]{40})/).
106
+ to_h do |sha_and_name_info|
107
+ sha_and_name_info.
108
+ match(/(?<sha>[0-9a-f]{40})\n\nR\d+\s+(?<previous_name>\S+)?/).
109
+ named_captures.
110
+ values_at('sha', 'previous_name')
111
+ end
112
+ end
60
113
  end
data/lib/fcom/version.rb CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  # rubocop:disable Style/StaticClass
4
4
  class Fcom
5
- VERSION = '0.10.0'
5
+ VERSION = '0.11.0'
6
6
  end
7
7
  # rubocop:enable Style/StaticClass
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: fcom
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.10.0
4
+ version: 0.11.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Runger
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-06-28 00:00:00.000000000 Z
11
+ date: 2024-07-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -108,6 +108,7 @@ files:
108
108
  - Rakefile
109
109
  - bin/_guard-core
110
110
  - bin/console
111
+ - bin/githooks/pre-push
111
112
  - bin/guard
112
113
  - bin/release
113
114
  - bin/rspec
@@ -145,7 +146,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
145
146
  - !ruby/object:Gem::Version
146
147
  version: '0'
147
148
  requirements: []
148
- rubygems_version: 3.5.14
149
+ rubygems_version: 3.5.15
149
150
  signing_key:
150
151
  specification_version: 4
151
152
  summary: CLI tool for parsing git history