git 5.0.4 → 5.1.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 +4 -4
- data/.github/workflows/continuous_integration.yml +305 -16
- data/.github/workflows/enforce_conventional_commits.yml +6 -0
- data/.github/workflows/warm_bundler_caches.yml +82 -0
- data/.release-please-manifest.json +1 -1
- data/.rubocop.yml +14 -2
- data/CHANGELOG.md +44 -0
- data/CONTRIBUTING.md +30 -5
- data/README.md +67 -0
- data/git.gemspec +43 -15
- data/lib/git/configuring.rb +56 -0
- data/lib/git/execution_context.rb +57 -1
- data/lib/git/log.rb +19 -0
- data/lib/git/repository/logging.rb +35 -11
- data/lib/git/repository/object_operations.rb +22 -1
- data/lib/git/version.rb +1 -1
- metadata +32 -31
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 10e1f676a8b4122760435d18757f8dbb0f67e8e0f59f2e85463c0c7c93add807
|
|
4
|
+
data.tar.gz: 47687fd4a08c52945fb1eb8aa668429e33c7e4e9ce06f6a8664dc2f83e0372bc
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3073e1e644e4d927de4e78bb6b0a8f082e6c757353a68b53c0ac2035c8ebee978e8d4a0a4c3a5fcaccece86ce5139f433af86716193ae2f8b0a0d26d6d9119c0
|
|
7
|
+
data.tar.gz: dcc552a33be697647b62e780492d454d3da93b1c9c8de218363f5118125abc59c7aa331ed15c1b69eb87e2b60b205db466b9e5da7cc59022d0a1ae9f55d0384a
|
|
@@ -5,7 +5,51 @@ on:
|
|
|
5
5
|
branches: [main, 4.x]
|
|
6
6
|
workflow_dispatch:
|
|
7
7
|
|
|
8
|
+
# Cancel an in-progress run when the same PR (or branch) gets a new push. For
|
|
9
|
+
# pull_request events github.ref is refs/pull/<n>/merge, so runs are grouped per PR
|
|
10
|
+
# and pushing a new commit -- or force-pushing during a rebase -- no longer leaves a
|
|
11
|
+
# full matrix running to completion against a commit nobody will merge.
|
|
12
|
+
concurrency:
|
|
13
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
14
|
+
cancel-in-progress: true
|
|
15
|
+
|
|
8
16
|
jobs:
|
|
17
|
+
# RuboCop and YARD analyze source text, so their results do not depend on the
|
|
18
|
+
# runtime executing them: RuboCop's verdict is fixed by TargetRubyVersion in
|
|
19
|
+
# .rubocop.yml, not by the host Ruby. Running them once here instead of inside the
|
|
20
|
+
# matrix removes the single largest cost in the build -- RuboCop alone accounted for
|
|
21
|
+
# over half the wall time of the JRuby and TruffleRuby jobs -- while checking exactly
|
|
22
|
+
# the same things.
|
|
23
|
+
#
|
|
24
|
+
# Ruby 3.4 hosts this job rather than the newest supported Ruby because it gates
|
|
25
|
+
# merges: a lint gate should be insulated from churn in a brand-new major, and Ruby
|
|
26
|
+
# 4.0 deprecations still surface through the matrix jobs below, which do run 4.0.
|
|
27
|
+
# 3.3+ is also a hard floor here, since yard-lint is only installed on 3.3 and later
|
|
28
|
+
# (see the gemspec) and YARD itself cannot build on JRuby or TruffleRuby.
|
|
29
|
+
lint:
|
|
30
|
+
name: Lint and Docs
|
|
31
|
+
|
|
32
|
+
# Skip this job if triggered by a release PR
|
|
33
|
+
if: >-
|
|
34
|
+
github.event_name == 'workflow_dispatch' ||
|
|
35
|
+
(github.event_name == 'pull_request' && !startsWith(github.event.pull_request.head.ref, 'release-please--'))
|
|
36
|
+
|
|
37
|
+
runs-on: ubuntu-latest
|
|
38
|
+
|
|
39
|
+
steps:
|
|
40
|
+
- name: Checkout Code
|
|
41
|
+
uses: actions/checkout@v6
|
|
42
|
+
|
|
43
|
+
- name: Setup Ruby
|
|
44
|
+
uses: ruby/setup-ruby@v1
|
|
45
|
+
with:
|
|
46
|
+
ruby-version: "3.4"
|
|
47
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
48
|
+
|
|
49
|
+
- name: Run RuboCop and YARD
|
|
50
|
+
run: bundle exec rake rubocop yard
|
|
51
|
+
timeout-minutes: 15
|
|
52
|
+
|
|
9
53
|
build:
|
|
10
54
|
name: Ruby ${{ matrix.ruby }} on ${{ matrix.operating-system }}
|
|
11
55
|
|
|
@@ -15,42 +59,34 @@ jobs:
|
|
|
15
59
|
(github.event_name == 'pull_request' && !startsWith(github.event.pull_request.head.ref, 'release-please--'))
|
|
16
60
|
|
|
17
61
|
runs-on: ${{ matrix.operating-system }}
|
|
18
|
-
continue-on-error: ${{ matrix.experimental == 'Yes' }}
|
|
19
62
|
env: { JAVA_OPTS: -Djdk.io.File.enableADS=true }
|
|
20
63
|
|
|
21
64
|
strategy:
|
|
22
65
|
fail-fast: false
|
|
23
66
|
matrix:
|
|
24
|
-
# Only the minimum required versions of JRuby and TruffleRuby are tested
|
|
25
|
-
|
|
67
|
+
# Only the minimum required versions of JRuby and TruffleRuby are tested.
|
|
68
|
+
#
|
|
69
|
+
ruby: ["3.2", "4.0", "truffleruby-24.2.1", "jruby-10.0.0.1"]
|
|
26
70
|
operating-system: [ubuntu-latest]
|
|
27
|
-
experimental: [No]
|
|
28
|
-
java_version: [""]
|
|
29
71
|
include:
|
|
30
72
|
- ruby: "3.2"
|
|
31
73
|
operating-system: windows-latest
|
|
32
|
-
experimental: No
|
|
33
|
-
java_version: ""
|
|
34
74
|
|
|
35
75
|
steps:
|
|
36
76
|
- name: Checkout Code
|
|
37
77
|
uses: actions/checkout@v6
|
|
38
78
|
|
|
39
|
-
- name: Setup Java
|
|
40
|
-
if: matrix.java_version != ''
|
|
41
|
-
uses: actions/setup-java@v5
|
|
42
|
-
with:
|
|
43
|
-
distribution: 'temurin'
|
|
44
|
-
java-version: ${{ matrix.java_version }}
|
|
45
|
-
|
|
46
79
|
- name: Setup Ruby
|
|
47
80
|
uses: ruby/setup-ruby@v1
|
|
48
81
|
with:
|
|
49
82
|
ruby-version: ${{ matrix.ruby }}
|
|
50
83
|
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
51
84
|
|
|
52
|
-
|
|
53
|
-
|
|
85
|
+
# Specs only. RuboCop and YARD run once in the lint job above instead of being
|
|
86
|
+
# repeated identically on every runtime. `rake build` still runs on every
|
|
87
|
+
# platform, as a prerequisite of the Test Gem step below.
|
|
88
|
+
- name: Run Specs
|
|
89
|
+
run: bundle exec rake spec
|
|
54
90
|
timeout-minutes: 15
|
|
55
91
|
|
|
56
92
|
# The unit suite enforces 100% line and branch coverage (see the "Test coverage
|
|
@@ -67,3 +103,256 @@ jobs:
|
|
|
67
103
|
|
|
68
104
|
- name: Test Gem
|
|
69
105
|
run: bundle exec rake test:gem
|
|
106
|
+
|
|
107
|
+
# The branch ruleset cannot require the matrix jobs above directly. A required status
|
|
108
|
+
# check is matched by name, and `build`'s name is a template -- GitHub only expands it
|
|
109
|
+
# into "Ruby 3.2 on ubuntu-latest" and friends when it evaluates the matrix. The
|
|
110
|
+
# job-level `if:` short-circuits before that happens, so a release PR reports one check
|
|
111
|
+
# named literally "Ruby ${{ matrix.ruby }} on ${{ matrix.operating-system }}" and the
|
|
112
|
+
# five expanded names never report at all. Required checks that never report block a PR
|
|
113
|
+
# indefinitely rather than passing, which is what stranded the v5.0.5 release PR.
|
|
114
|
+
#
|
|
115
|
+
# So the ruleset requires this job instead: one stable name, no matrix, no template to
|
|
116
|
+
# expand. It also decouples the required-check list from the matrix, so adding or
|
|
117
|
+
# dropping a Ruby version no longer needs a matching ruleset edit.
|
|
118
|
+
#
|
|
119
|
+
# This job carries the same release-PR guard as every job above, so that a release PR
|
|
120
|
+
# reports it as skipped rather than as a success for specs that never ran. Skipping is
|
|
121
|
+
# safe here and was not safe for `build`: this job's name is a literal string, so the
|
|
122
|
+
# check run exists and reports a skipped conclusion whether or not the job runs, and
|
|
123
|
+
# rulesets treat skipped as passing. A matrix job's name does not exist at all until the
|
|
124
|
+
# matrix is evaluated, which is the whole reason this job exists.
|
|
125
|
+
#
|
|
126
|
+
# `always()` is load-bearing and must stay. Without a status check function a job-level
|
|
127
|
+
# `if:` implies `success()`, so a failing matrix would skip this job -- and a skipped
|
|
128
|
+
# required check counts as passing, meaning a red build would merge. `always()` forces a
|
|
129
|
+
# real verdict on every run that is not a release PR. `!cancelled()` is not a substitute:
|
|
130
|
+
# a cancelled run would then skip the gate, and a skipped conclusion is one rulesets treat
|
|
131
|
+
# as passing -- so a build that never finished would stop blocking the merge.
|
|
132
|
+
#
|
|
133
|
+
# The case below accepts `success` only. `build` and this job now carry the same release-PR
|
|
134
|
+
# guard, so this job runs exactly when `build` ran; a `skipped` result would mean the two
|
|
135
|
+
# guards have drifted apart, and failing closed on it turns that into a loud failure rather
|
|
136
|
+
# than a silent pass.
|
|
137
|
+
build-complete:
|
|
138
|
+
name: All Specs Passed
|
|
139
|
+
|
|
140
|
+
needs: [build]
|
|
141
|
+
|
|
142
|
+
# Report a verdict on every non-release PR regardless of the matrix result, and skip
|
|
143
|
+
# on release PRs, where the matrix was never meant to run.
|
|
144
|
+
if: >-
|
|
145
|
+
always() &&
|
|
146
|
+
(github.event_name == 'workflow_dispatch' ||
|
|
147
|
+
(github.event_name == 'pull_request' && !startsWith(github.event.pull_request.head.ref, 'release-please--')))
|
|
148
|
+
|
|
149
|
+
runs-on: ubuntu-latest
|
|
150
|
+
|
|
151
|
+
steps:
|
|
152
|
+
- name: Check the result of the build job
|
|
153
|
+
run: |
|
|
154
|
+
case "${{ needs.build.result }}" in
|
|
155
|
+
success)
|
|
156
|
+
echo "build: ${{ needs.build.result }}"
|
|
157
|
+
;;
|
|
158
|
+
*)
|
|
159
|
+
echo "::error::build: ${{ needs.build.result }}"
|
|
160
|
+
exit 1
|
|
161
|
+
;;
|
|
162
|
+
esac
|
|
163
|
+
|
|
164
|
+
# Everything above runs in English, because GitHub-hosted runners generate no locale
|
|
165
|
+
# beyond C/C.UTF-8. That makes git's translated diagnostics invisible to CI even
|
|
166
|
+
# though they are the default experience for any contributor whose shell locale is not
|
|
167
|
+
# English -- so a spec that matches an English git message passes here and fails for
|
|
168
|
+
# them, on code they did not touch. This job is what stops such a spec from reaching
|
|
169
|
+
# main. See issue #1670.
|
|
170
|
+
#
|
|
171
|
+
# German because git's `de` translation is close enough to complete that a
|
|
172
|
+
# message-matching assumption cannot hide behind a string that was never translated.
|
|
173
|
+
# Most of the suite is insulated from this by the LC_ALL pin in Git::ExecutionContext;
|
|
174
|
+
# what this job really exercises is the code that bypasses that pin.
|
|
175
|
+
locale:
|
|
176
|
+
name: Non-English Locale
|
|
177
|
+
|
|
178
|
+
# Skip this job if triggered by a release PR
|
|
179
|
+
if: >-
|
|
180
|
+
github.event_name == 'workflow_dispatch' ||
|
|
181
|
+
(github.event_name == 'pull_request' && !startsWith(github.event.pull_request.head.ref, 'release-please--'))
|
|
182
|
+
|
|
183
|
+
runs-on: ubuntu-latest
|
|
184
|
+
|
|
185
|
+
# Set at job scope rather than on the spec step so that every step -- including the
|
|
186
|
+
# check below that the locale is real -- sees exactly the environment the suite runs
|
|
187
|
+
# under. Setting these before locale-gen is harmless: they are simply inert until
|
|
188
|
+
# the locale exists.
|
|
189
|
+
env:
|
|
190
|
+
LANG: de_DE.UTF-8
|
|
191
|
+
LC_ALL: de_DE.UTF-8
|
|
192
|
+
|
|
193
|
+
steps:
|
|
194
|
+
- name: Checkout Code
|
|
195
|
+
uses: actions/checkout@v6
|
|
196
|
+
|
|
197
|
+
# Two separate things are missing from a stock runner, and skipping either one
|
|
198
|
+
# leaves the env above inert -- git keeps answering in English and the job proves
|
|
199
|
+
# nothing:
|
|
200
|
+
#
|
|
201
|
+
# 1. The locale itself. Only C and C.UTF-8 are generated, so setlocale fails for
|
|
202
|
+
# anything else and every process falls back to English.
|
|
203
|
+
# 2. git's German message catalog. Unlike Debian, Ubuntu strips gettext catalogs
|
|
204
|
+
# out of packages and ships them in language packs, so the installed git has
|
|
205
|
+
# no de translation until language-pack-de provides one.
|
|
206
|
+
#
|
|
207
|
+
# `update-locale` is deliberately not run: it edits /etc/default/locale, which is
|
|
208
|
+
# only consulted for logins that do not already set LANG and LC_ALL, and this job
|
|
209
|
+
# sets both explicitly.
|
|
210
|
+
#
|
|
211
|
+
# The two apt settings below exist because this step reaches out to the Ubuntu
|
|
212
|
+
# archive, which is the only part of this job that can fail for reasons that have
|
|
213
|
+
# nothing to do with the code under test:
|
|
214
|
+
#
|
|
215
|
+
# * `Acquire::Retries` retries an individual download that fails outright,
|
|
216
|
+
# rather than failing the job on one unlucky mirror.
|
|
217
|
+
# * `timeout-minutes` bounds a mirror that accepts the connection and then
|
|
218
|
+
# stops responding, which retries cannot help with. Without it the step
|
|
219
|
+
# inherits the 6 hour job default: run 32087601711 sat here for 12 minutes
|
|
220
|
+
# before it was cancelled by hand, and would otherwise have held a runner
|
|
221
|
+
# for the rest of the day. The whole job normally finishes in 53-118
|
|
222
|
+
# seconds, so 5 minutes is generous while still failing the same morning.
|
|
223
|
+
#
|
|
224
|
+
- name: Install the German locale and message catalogs
|
|
225
|
+
timeout-minutes: 5
|
|
226
|
+
run: |
|
|
227
|
+
sudo apt-get -o Acquire::Retries=3 update -qq
|
|
228
|
+
sudo apt-get -o Acquire::Retries=3 install -y --no-install-recommends language-pack-de
|
|
229
|
+
sudo locale-gen de_DE.UTF-8
|
|
230
|
+
|
|
231
|
+
# Ruby 3.4 to share the bundler cache the lint job already warms. Nothing about
|
|
232
|
+
# this job is Ruby-version specific -- the locale is what is under test.
|
|
233
|
+
- name: Setup Ruby
|
|
234
|
+
uses: ruby/setup-ruby@v1
|
|
235
|
+
with:
|
|
236
|
+
ruby-version: "3.4"
|
|
237
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
238
|
+
|
|
239
|
+
# Guard against a vacuous pass. Diffing git's output against the same command run
|
|
240
|
+
# under LC_ALL=C proves translation is actually active, without pinning a German
|
|
241
|
+
# string that a future git release is free to reword.
|
|
242
|
+
- name: Verify the Locale Took Effect
|
|
243
|
+
run: |
|
|
244
|
+
dir="$(mktemp -d)"
|
|
245
|
+
localized="$(cd "$dir" && git status 2>&1 || true)"
|
|
246
|
+
english="$(cd "$dir" && LC_ALL=C git status 2>&1 || true)"
|
|
247
|
+
echo "LC_ALL=$LC_ALL -> $localized"
|
|
248
|
+
echo "LC_ALL=C -> $english"
|
|
249
|
+
if [ "$localized" = "$english" ]; then
|
|
250
|
+
echo "::error::git is still emitting English: de_DE.UTF-8 did not take effect, so this job would test nothing"
|
|
251
|
+
exit 1
|
|
252
|
+
fi
|
|
253
|
+
|
|
254
|
+
- name: Run Specs
|
|
255
|
+
run: bundle exec rake spec
|
|
256
|
+
timeout-minutes: 15
|
|
257
|
+
|
|
258
|
+
# On the ubuntu jobs above, `C.UTF-8` and `en_US.UTF-8` both resolve to a UTF-8 ctype
|
|
259
|
+
# (measured on the runner in issue #1669), and on windows the pinned value makes no
|
|
260
|
+
# difference under any value at all. So the non-ASCII regex coverage those jobs run
|
|
261
|
+
# passes whatever `Git::ExecutionContext` pins, and cannot tell a correct `LC_ALL`
|
|
262
|
+
# value from a wrong one. That blind spot is what let the original defect go
|
|
263
|
+
# unreported for eighteen months: the gem pinned `en_US.UTF-8`, stock Debian, Ubuntu,
|
|
264
|
+
# and RHEL images generate no such locale, git silently fell back to a C ctype, and
|
|
265
|
+
# every non-ASCII regex in `grep`, `log`, and the `config` value regexes returned a
|
|
266
|
+
# wrong answer with exit status zero -- while CI stayed green throughout.
|
|
267
|
+
#
|
|
268
|
+
# This job makes one run discriminating. `LOCPATH` overrides where glibc looks for
|
|
269
|
+
# compiled locale data, so pointing it at an empty directory takes away every locale
|
|
270
|
+
# that needs a locale archive -- `en_US.UTF-8` among them -- while leaving `C.UTF-8`
|
|
271
|
+
# working, because glibc 2.35 and later compile that one into the library itself.
|
|
272
|
+
# The suite then runs in an environment where the value shipped before #1681 fails
|
|
273
|
+
# and the value shipped now passes: no container image, no second bundle install,
|
|
274
|
+
# no cache miss. Measured on ubuntu:24.04 (glibc 2.39, the runner's base) with
|
|
275
|
+
# `en_US.UTF-8` generated first:
|
|
276
|
+
#
|
|
277
|
+
# normal en_US.UTF-8 charmap=UTF-8 C.UTF-8 charmap=UTF-8
|
|
278
|
+
# LOCPATH=empty en_US.UTF-8 charmap=ANSI_X3.4-1968 C.UTF-8 charmap=UTF-8
|
|
279
|
+
#
|
|
280
|
+
# This has to be a property of the run rather than of a spec. Never gate a spec on
|
|
281
|
+
# whether the pinned locale loads: such a spec skips itself in exactly the
|
|
282
|
+
# environments where this defect lives, which is how the defect went unreported for
|
|
283
|
+
# eighteen months.
|
|
284
|
+
#
|
|
285
|
+
# LANG is set explicitly so only `en_US.UTF-8` is taken away and the ambient
|
|
286
|
+
# environment stays UTF-8. The runner already sets this value; pinning it here keeps
|
|
287
|
+
# the job from depending on the image's default.
|
|
288
|
+
missing-locale:
|
|
289
|
+
name: Missing en_US.UTF-8 Locale
|
|
290
|
+
|
|
291
|
+
# Skip this job if triggered by a release PR
|
|
292
|
+
if: >-
|
|
293
|
+
github.event_name == 'workflow_dispatch' ||
|
|
294
|
+
(github.event_name == 'pull_request' && !startsWith(github.event.pull_request.head.ref, 'release-please--'))
|
|
295
|
+
|
|
296
|
+
runs-on: ubuntu-latest
|
|
297
|
+
|
|
298
|
+
env:
|
|
299
|
+
LANG: C.UTF-8
|
|
300
|
+
|
|
301
|
+
steps:
|
|
302
|
+
- name: Checkout Code
|
|
303
|
+
uses: actions/checkout@v6
|
|
304
|
+
|
|
305
|
+
# Exported through GITHUB_ENV rather than set at job scope because the `runner`
|
|
306
|
+
# context is not available there, and the directory has to exist before anything
|
|
307
|
+
# reads a locale -- glibc warns on every process when LOCPATH names a directory
|
|
308
|
+
# that does not exist. RUNNER_TEMP rather than the workspace so that
|
|
309
|
+
# actions/checkout cannot clean it away.
|
|
310
|
+
- name: Point LOCPATH at an Empty Directory
|
|
311
|
+
run: |
|
|
312
|
+
mkdir -p "$RUNNER_TEMP/empty-locale-dir"
|
|
313
|
+
echo "LOCPATH=$RUNNER_TEMP/empty-locale-dir" >> "$GITHUB_ENV"
|
|
314
|
+
|
|
315
|
+
# Ruby 3.4 to share the bundler cache the lint job already warms. Nothing about
|
|
316
|
+
# this job is Ruby-version specific -- the locale environment is what differs.
|
|
317
|
+
- name: Setup Ruby
|
|
318
|
+
uses: ruby/setup-ruby@v1
|
|
319
|
+
with:
|
|
320
|
+
ruby-version: "3.4"
|
|
321
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
|
322
|
+
|
|
323
|
+
# Guard against a vacuous pass, functionally. `locale -a` still lists en_US.utf8
|
|
324
|
+
# under LOCPATH (measured) even though setlocale then refuses it, so asking git
|
|
325
|
+
# to match is the only assertion worth making: `.` spans the two-byte U+00C4 only
|
|
326
|
+
# under a UTF-8 ctype. The metacharacter-free control has to keep matching under
|
|
327
|
+
# the removed locale as well -- it matches bytes under any ctype, so if it fails,
|
|
328
|
+
# the probe never delivered UTF-8 bytes to git and the rest proves nothing.
|
|
329
|
+
- name: Verify the Run Discriminates
|
|
330
|
+
run: |
|
|
331
|
+
dir="$(mktemp -d)"
|
|
332
|
+
cd "$dir"
|
|
333
|
+
git init -q .
|
|
334
|
+
printf '\xc3\x84PFEL sind gut\n' > w.txt
|
|
335
|
+
git add w.txt
|
|
336
|
+
|
|
337
|
+
if ! LC_ALL=C.UTF-8 git grep -q '^.PFEL' -- w.txt; then
|
|
338
|
+
echo "::error::C.UTF-8 no longer yields a UTF-8 ctype under LOCPATH, so this job would fail for the wrong reason"
|
|
339
|
+
exit 1
|
|
340
|
+
fi
|
|
341
|
+
if ! LC_ALL=en_US.UTF-8 git grep -q 'PFEL sind' -- w.txt; then
|
|
342
|
+
echo "::error::the control pattern did not match, so this probe is not delivering UTF-8 bytes to git"
|
|
343
|
+
exit 1
|
|
344
|
+
fi
|
|
345
|
+
if LC_ALL=en_US.UTF-8 git grep -q '^.PFEL' -- w.txt; then
|
|
346
|
+
echo "::error::en_US.UTF-8 still yields a UTF-8 ctype, so this job cannot detect a wrong LC_ALL pin"
|
|
347
|
+
exit 1
|
|
348
|
+
fi
|
|
349
|
+
echo "en_US.UTF-8 is unusable and C.UTF-8 works: a wrong pin fails this job"
|
|
350
|
+
|
|
351
|
+
# The whole suite rather than the non-ASCII regex spec alone: the point is that
|
|
352
|
+
# this run is indistinguishable from any other except for the missing locale, so
|
|
353
|
+
# every locale-sensitive surface added later is covered without touching this
|
|
354
|
+
# file. It also keeps the coverage gate satisfied, which a single spec file
|
|
355
|
+
# cannot do.
|
|
356
|
+
- name: Run Specs
|
|
357
|
+
run: bundle exec rake spec
|
|
358
|
+
timeout-minutes: 15
|
|
@@ -10,6 +10,12 @@ on:
|
|
|
10
10
|
- main
|
|
11
11
|
- 4.x
|
|
12
12
|
|
|
13
|
+
# Cancel an in-progress run when the same PR gets a new push; only the commit messages
|
|
14
|
+
# as they stand after the latest push are worth linting.
|
|
15
|
+
concurrency:
|
|
16
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
17
|
+
cancel-in-progress: true
|
|
18
|
+
|
|
13
19
|
jobs:
|
|
14
20
|
commit-lint:
|
|
15
21
|
name: Verify Conventional Commits
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
name: Warm Bundler Caches
|
|
2
|
+
|
|
3
|
+
# GitHub Actions scopes every cache to the ref that wrote it, and only caches
|
|
4
|
+
# written at *default-branch* scope are readable from other refs. The CI workflow runs
|
|
5
|
+
# on `pull_request`, where github.ref is refs/pull/<n>/merge, so the caches it writes
|
|
6
|
+
# are visible to that one PR and nothing else. The result is that nearly every PR paid
|
|
7
|
+
# a cold `bundle install` on nearly every job. See issue #1674 for the measurements.
|
|
8
|
+
#
|
|
9
|
+
# This workflow exists solely to write those caches from refs/heads/main so that a
|
|
10
|
+
# PR's *first* run can read them. It does no checkout-and-test work beyond what
|
|
11
|
+
# `bundler-cache: true` needs: no specs, no RuboCop, no YARD.
|
|
12
|
+
#
|
|
13
|
+
# The matrix below must stay in sync with continuous_integration.yml: setup-ruby's
|
|
14
|
+
# cache key embeds the runner OS, the resolved Ruby version, and the Gemfile.lock hash,
|
|
15
|
+
# so a pair that is not warmed here still starts cold in CI. That includes the lint
|
|
16
|
+
# job's Ruby 3.4 and the Windows 3.2 job, neither of which appears in CI's main matrix
|
|
17
|
+
# list. The head rubies from experimental_continuous_integration.yml are deliberately
|
|
18
|
+
# absent: that workflow already runs on `push: [main]` and warms its own caches.
|
|
19
|
+
#
|
|
20
|
+
# Only `main` is listed below. A run's readable caches are its own ref, its base ref,
|
|
21
|
+
# and the default branch, so warming 4.x would need this file backported to the 4.x
|
|
22
|
+
# branch with that branch's own matrix -- the copy on main is never what runs for a
|
|
23
|
+
# push to 4.x.
|
|
24
|
+
on:
|
|
25
|
+
push:
|
|
26
|
+
branches: [main]
|
|
27
|
+
|
|
28
|
+
workflow_dispatch:
|
|
29
|
+
|
|
30
|
+
# Deliberately NOT cancel-in-progress. Two merges landing close together would
|
|
31
|
+
# otherwise cancel the first one's warming mid-save, which is the opposite of the
|
|
32
|
+
# point; queueing them costs a couple of runner-minutes and always leaves a warm cache
|
|
33
|
+
# behind. This group is also distinct from CI's because github.workflow differs.
|
|
34
|
+
concurrency:
|
|
35
|
+
group: ${{ github.workflow }}-${{ github.ref }}
|
|
36
|
+
cancel-in-progress: false
|
|
37
|
+
|
|
38
|
+
permissions:
|
|
39
|
+
contents: read
|
|
40
|
+
|
|
41
|
+
jobs:
|
|
42
|
+
warm:
|
|
43
|
+
name: Warm Ruby ${{ matrix.ruby }} on ${{ matrix.operating-system }}
|
|
44
|
+
|
|
45
|
+
runs-on: ${{ matrix.operating-system }}
|
|
46
|
+
timeout-minutes: 15
|
|
47
|
+
|
|
48
|
+
strategy:
|
|
49
|
+
fail-fast: false
|
|
50
|
+
matrix:
|
|
51
|
+
include:
|
|
52
|
+
- ruby: "3.2"
|
|
53
|
+
operating-system: ubuntu-latest
|
|
54
|
+
|
|
55
|
+
- # Hosts the lint and locale jobs in continuous_integration.yml
|
|
56
|
+
ruby: "3.4"
|
|
57
|
+
operating-system: ubuntu-latest
|
|
58
|
+
|
|
59
|
+
- ruby: "4.0"
|
|
60
|
+
operating-system: ubuntu-latest
|
|
61
|
+
|
|
62
|
+
- ruby: "truffleruby-24.2.1"
|
|
63
|
+
operating-system: ubuntu-latest
|
|
64
|
+
|
|
65
|
+
- ruby: "jruby-10.0.0.1"
|
|
66
|
+
operating-system: ubuntu-latest
|
|
67
|
+
|
|
68
|
+
- ruby: "3.2"
|
|
69
|
+
operating-system: windows-latest
|
|
70
|
+
|
|
71
|
+
steps:
|
|
72
|
+
- name: Checkout Code
|
|
73
|
+
uses: actions/checkout@v6
|
|
74
|
+
|
|
75
|
+
# No bundler-* inputs here on purpose. setup-ruby folds its `bundler`, `with`,
|
|
76
|
+
# `without`, and `only` inputs into the cache key, so any option set here and not
|
|
77
|
+
# in continuous_integration.yml would warm a key CI never looks up.
|
|
78
|
+
- name: Setup Ruby
|
|
79
|
+
uses: ruby/setup-ruby@v1
|
|
80
|
+
with:
|
|
81
|
+
ruby-version: ${{ matrix.ruby }}
|
|
82
|
+
bundler-cache: true # runs 'bundle install' and caches installed gems automatically
|
data/.rubocop.yml
CHANGED
|
@@ -26,7 +26,19 @@ Layout/LineLength:
|
|
|
26
26
|
Style/OneClassPerFile:
|
|
27
27
|
Enabled: false
|
|
28
28
|
|
|
29
|
+
# The repository is stored with LF line endings, but this cop defaults to `native`,
|
|
30
|
+
# which expects CRLF on Windows and so reports every file in the project as an
|
|
31
|
+
# offense there. Pinning it to `lf` makes the lint verdict identical on every
|
|
32
|
+
# platform, which is the same reason CI runs RuboCop on one runtime only.
|
|
33
|
+
Layout/EndOfLine:
|
|
34
|
+
EnforcedStyle: lf
|
|
35
|
+
|
|
29
36
|
AllCops:
|
|
30
|
-
#
|
|
31
|
-
#
|
|
37
|
+
# Must match the floor of required_ruby_version in the gemspec: TargetRubyVersion
|
|
38
|
+
# decides which syntax RuboCop permits and suggests, so a value above the floor
|
|
39
|
+
# would let in code that does not parse on the oldest supported Ruby.
|
|
40
|
+
#
|
|
41
|
+
# Pinned explicitly rather than inferred because main_branch_shared_rubocop_config
|
|
42
|
+
# sets 3.1, which is older than this gem supports, and a value inherited through
|
|
43
|
+
# inherit_gem takes precedence over inference from the gemspec.
|
|
32
44
|
TargetRubyVersion: 3.2
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,50 @@
|
|
|
5
5
|
|
|
6
6
|
# Change Log
|
|
7
7
|
|
|
8
|
+
## [5.1.0](https://github.com/ruby-git/ruby-git/compare/v5.0.5...v5.1.0) (2026-08-18)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **grep:** Expose perl_regexp on the Git::Repository#grep facade ([759436f](https://github.com/ruby-git/ruby-git/commit/759436f7b59ac5028e38a2158a9a354720640415))
|
|
14
|
+
* **log:** Expose perl_regexp on the log path ([df8ea33](https://github.com/ruby-git/ruby-git/commit/df8ea33bb7d019d1a52fbb99370d9ffd67bf279f))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Other Changes
|
|
18
|
+
|
|
19
|
+
* Add fiddle as a Windows development dependency ([1847989](https://github.com/ruby-git/ruby-git/commit/18479892529bd1f992596cbc055a9a42be326680))
|
|
20
|
+
* Bound the locale job's apt step so a stalled mirror fails fast ([3a5d83b](https://github.com/ruby-git/ruby-git/commit/3a5d83b7685091a4abbde2c84c0136214fa66e5d))
|
|
21
|
+
* Cover the perl_regexp escape hatch for non-ASCII regex matching ([55e2ded](https://github.com/ruby-git/ruby-git/commit/55e2ded4563a39a0389dbbd52f8425da9a1e3aea))
|
|
22
|
+
* Document the Git for Windows byte-matching regex limitation ([9aaedbd](https://github.com/ruby-git/ruby-git/commit/9aaedbd94488bcfeef05cc56dfce61ce69f529fc))
|
|
23
|
+
* Document the windows symlink privilege requirement ([696dff3](https://github.com/ruby-git/ruby-git/commit/696dff3cbf09647bbfa51279f7e35fc8a85eaab4))
|
|
24
|
+
* Express development dependency conditions as named predicates ([acca20a](https://github.com/ruby-git/ruby-git/commit/acca20a43a6fb79f6b36de900ac8aa8c2488d87f))
|
|
25
|
+
* Fix a broken section link in the pre-review checklist ([719f595](https://github.com/ruby-git/ruby-git/commit/719f595af69c1afcf6b025d1a2bb920963738f80))
|
|
26
|
+
* Make integration fixtures independent of git and platform settings ([c2a1592](https://github.com/ruby-git/ruby-git/commit/c2a159287ec007793c125929029303707669c8ad))
|
|
27
|
+
* Pin rubocop to lf line endings ([7f40413](https://github.com/ruby-git/ruby-git/commit/7f40413c3eded1af7a3dede02e1d94d7dc9c829b))
|
|
28
|
+
* Pin test repository config from a single source ([6e227b7](https://github.com/ruby-git/ruby-git/commit/6e227b70f59f4bbaf2bbc1d30a4b1b86ffbe6afc))
|
|
29
|
+
* Scope the symlink rescue to the symlink call ([c2bed8f](https://github.com/ruby-git/ruby-git/commit/c2bed8fefdd8bdf2efa84432c318b2b39ba223d2))
|
|
30
|
+
* Skip the symlink specs when the host cannot create symlinks ([8e9b667](https://github.com/ruby-git/ruby-git/commit/8e9b667daeb6a179a02df7c946a495c7b7e6fce5))
|
|
31
|
+
|
|
32
|
+
## [5.0.5](https://github.com/ruby-git/ruby-git/compare/v5.0.4...v5.0.5) (2026-08-09)
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
* Detect Darwin under JRuby when pinning LC_ALL ([89bf625](https://github.com/ruby-git/ruby-git/commit/89bf62579999bec27a9b0f1aab16d37e7d5af2b8)), closes [#1669](https://github.com/ruby-git/ruby-git/issues/1669)
|
|
38
|
+
* Pin LC_ALL to a locale that exists on the host platform ([5a4e0d6](https://github.com/ruby-git/ruby-git/commit/5a4e0d657b0e0828de0b38f283ae60dfbe2d4cc6)), closes [#1669](https://github.com/ruby-git/ruby-git/issues/1669)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
### Other Changes
|
|
42
|
+
|
|
43
|
+
* Correct two imprecise claims in the build-complete comment ([c4391cd](https://github.com/ruby-git/ruby-git/commit/c4391cdf441a8379dee4cda59f800da41bf8e8b2)), closes [#1675](https://github.com/ruby-git/ruby-git/issues/1675)
|
|
44
|
+
* Gate merges on a matrix-free job instead of the per-matrix checks ([47f2d17](https://github.com/ruby-git/ruby-git/commit/47f2d17d16d1ea201bf9cc8f74aedffa7619eb0a)), closes [#1675](https://github.com/ruby-git/ruby-git/issues/1675)
|
|
45
|
+
* Remove vestigial matrix dimensions ([3a89886](https://github.com/ruby-git/ruby-git/commit/3a8988650a7d8f0a81c093c470fb9f524142c9b9)), closes [#1676](https://github.com/ruby-git/ruby-git/issues/1676)
|
|
46
|
+
* Run RuboCop and YARD once instead of on every matrix job ([0726964](https://github.com/ruby-git/ruby-git/commit/072696491662867cfbc0424febcf36542548f051))
|
|
47
|
+
* Run the suite once with en_US.UTF-8 unavailable ([6e012c5](https://github.com/ruby-git/ruby-git/commit/6e012c54d52c8b0c25bf629f07e310b6fcbac229)), closes [#1669](https://github.com/ruby-git/ruby-git/issues/1669)
|
|
48
|
+
* Run the test suite under a non-English locale ([c65d402](https://github.com/ruby-git/ruby-git/commit/c65d4022f358a4e4e676dbf2492427851205cdd6)), closes [#1670](https://github.com/ruby-git/ruby-git/issues/1670)
|
|
49
|
+
* Skip the All Specs Passed gate on release PRs ([6dfeee0](https://github.com/ruby-git/ruby-git/commit/6dfeee0ed508932393106c8887d9b7c9ef9dbbca)), closes [#1675](https://github.com/ruby-git/ruby-git/issues/1675)
|
|
50
|
+
* Warm bundler caches at default-branch scope on push to main ([2821477](https://github.com/ruby-git/ruby-git/commit/282147796f6b859fb9c7f8b5a614cab399cc9539)), closes [#1674](https://github.com/ruby-git/ruby-git/issues/1674)
|
|
51
|
+
|
|
8
52
|
## [5.0.4](https://github.com/ruby-git/ruby-git/compare/v5.0.3...v5.0.4) (2026-08-07)
|
|
9
53
|
|
|
10
54
|
|
data/CONTRIBUTING.md
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
- [How to report an issue or request a feature](#how-to-report-an-issue-or-request-a-feature)
|
|
11
11
|
- [Local development setup](#local-development-setup)
|
|
12
12
|
- [Prerequisites](#prerequisites)
|
|
13
|
+
- [A note for Windows contributors](#a-note-for-windows-contributors)
|
|
13
14
|
- [Bootstrap the project](#bootstrap-the-project)
|
|
14
15
|
- [Verify the toolchain](#verify-the-toolchain)
|
|
15
16
|
- [Contributor validation policy](#contributor-validation-policy)
|
|
@@ -97,6 +98,18 @@ prerequisite is missing.
|
|
|
97
98
|
| git | `>= 2.28.0` (matches `git.gemspec` `requirements`) | Older git versions are not supported and the test suite will not pass against them. |
|
|
98
99
|
| Node.js / npm | Optional | Required only to install the local Conventional Commit `commit-msg` hook (Husky + commitlint). If npm is missing, `bin/setup` will warn and continue — CI will still validate commit messages. |
|
|
99
100
|
|
|
101
|
+
#### A note for Windows contributors
|
|
102
|
+
|
|
103
|
+
A few unit specs create real symlinks, which on Windows requires
|
|
104
|
+
`SeCreateSymbolicLinkPrivilege`. A non-elevated process only holds that privilege
|
|
105
|
+
when Developer Mode is enabled (Settings → System → For developers). Without it
|
|
106
|
+
those specs skip rather than fail, so `bundle exec rake` still passes — but the
|
|
107
|
+
behavior they cover goes unverified locally.
|
|
108
|
+
|
|
109
|
+
The same privilege decides whether Git for Windows materializes the committed
|
|
110
|
+
`.claude/skills` symlink, so enabling Developer Mode fixes both at once. See
|
|
111
|
+
[Agent configuration](#agent-configuration).
|
|
112
|
+
|
|
100
113
|
### Bootstrap the project
|
|
101
114
|
|
|
102
115
|
From the project root, run:
|
|
@@ -181,7 +194,7 @@ Before moving a pull request out of draft or requesting a review, confirm:
|
|
|
181
194
|
- [ ] `bundle exec rake` passes locally on your branch (see
|
|
182
195
|
[Local development setup](#local-development-setup)).
|
|
183
196
|
- [ ] New or changed code has accompanying tests under `spec/`
|
|
184
|
-
(see [Unit tests](#unit-tests)).
|
|
197
|
+
(see [Unit tests vs Integration tests](#unit-tests-vs-integration-tests)).
|
|
185
198
|
- [ ] Every commit message follows [Conventional Commits](#commit-message-guidelines).
|
|
186
199
|
- [ ] User-facing changes are documented in `README.md` and/or YARD as appropriate.
|
|
187
200
|
|
|
@@ -301,7 +314,7 @@ The `git` gem is organized into three architectural layers:
|
|
|
301
314
|
| --- | --- | --- |
|
|
302
315
|
| **Facade** (`Git::Repository` and `Git`) | Public API | Normalizes Ruby arguments, sets safe defaults, calls one or more `Git::Commands::*` classes, and may parse output into public Ruby objects |
|
|
303
316
|
| **Command** (`Git::Commands::*`) | Neutral git CLI interface | Declares CLI arguments via the [Arguments DSL](lib/git/commands/arguments.rb), builds the git argv and executes git via `#call`, and returns `Git::CommandLine::Result` |
|
|
304
|
-
| **Execution** (`Git::ExecutionContext::*`) | Execution context and subprocess defaults | Carries execution settings such as working directory, environment, timeout, binary path, and logging; runs the git CLI with default global options (such as `-c color.ui=false`) and subprocess environment variables (such as `LC_ALL
|
|
317
|
+
| **Execution** (`Git::ExecutionContext::*`) | Execution context and subprocess defaults | Carries execution settings such as working directory, environment, timeout, binary path, and logging; runs the git CLI with default global options (such as `-c color.ui=false`) and subprocess environment variables (such as a platform-conditional `LC_ALL` — `en_US.UTF-8` on macOS, `C.UTF-8` elsewhere) |
|
|
305
318
|
|
|
306
319
|
Command classes (`Git::Commands::*`) are **faithful, neutral representations of the
|
|
307
320
|
git CLI**. Each command class does the following:
|
|
@@ -967,9 +980,21 @@ below either threshold.
|
|
|
967
980
|
|
|
968
981
|
This is enforceable without being onerous because unit coverage in this project is
|
|
969
982
|
deterministic: `lib/` has no Ruby-version, Ruby-engine, or platform conditionals, and
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
983
|
+
the handful of unit specs that are conditionally skipped are redundant for coverage —
|
|
984
|
+
every `lib/` line and branch they reach is also reached by a spec that always runs.
|
|
985
|
+
Every supported MRI runtime therefore measures exactly the same lines and branches, so
|
|
986
|
+
a coverage failure is always something the pull request introduced.
|
|
987
|
+
|
|
988
|
+
A new conditional skip in `spec/unit/` must preserve that property. Verify it on a
|
|
989
|
+
host where the guard actually skips: run the full unit suite there and confirm it
|
|
990
|
+
still reports 100% line and branch coverage. A conditionally skipped unit spec that
|
|
991
|
+
is the only thing covering a line would turn this gate into a platform-dependent
|
|
992
|
+
failure, which is exactly what the policy exists to prevent.
|
|
993
|
+
|
|
994
|
+
Write the guard the same way the rest of the suite does: a reusable predicate in
|
|
995
|
+
`spec/spec_helper.rb` (`unless_git`, `unless_command`, `unless_pcre`,
|
|
996
|
+
`unless_ci_build`) used as `skip:` metadata, or — for a one-off capability that the
|
|
997
|
+
`before` block is already exercising — a `rescue` in that block that calls `skip`.
|
|
973
998
|
|
|
974
999
|
What the policy does and does not cover:
|
|
975
1000
|
|
data/README.md
CHANGED
|
@@ -30,6 +30,8 @@ Commits](https://img.shields.io/badge/Conventional%20Commits-1.0.0-%23FE5196?log
|
|
|
30
30
|
- [Errors Raised by This Gem](#errors-raised-by-this-gem)
|
|
31
31
|
- [Specifying and Handling Timeouts](#specifying-and-handling-timeouts)
|
|
32
32
|
- [Deprecations](#deprecations)
|
|
33
|
+
- [Platform Limitations](#platform-limitations)
|
|
34
|
+
- [Regex Metacharacters on Git for Windows](#regex-metacharacters-on-git-for-windows)
|
|
33
35
|
- [Project Policies](#project-policies)
|
|
34
36
|
- [Ruby Version Support Policy](#ruby-version-support-policy)
|
|
35
37
|
- [Git Version Support Policy](#git-version-support-policy)
|
|
@@ -302,6 +304,71 @@ needed for the upgrade.
|
|
|
302
304
|
For the full list of deprecated methods and their replacements, see
|
|
303
305
|
[UPGRADING.md](UPGRADING.md).
|
|
304
306
|
|
|
307
|
+
## Platform Limitations
|
|
308
|
+
|
|
309
|
+
### Regex Metacharacters on Git for Windows
|
|
310
|
+
|
|
311
|
+
On Git for Windows, git's regex engine matches **bytes** rather than characters. A
|
|
312
|
+
metacharacter such as `.`, or a POSIX character class such as `[[:alpha:]]`, therefore
|
|
313
|
+
never matches a whole multi-byte character. The same call matches on Linux and macOS.
|
|
314
|
+
|
|
315
|
+
The failure is silent — nothing raises, and the result is indistinguishable from a
|
|
316
|
+
pattern that genuinely does not occur:
|
|
317
|
+
|
|
318
|
+
```ruby
|
|
319
|
+
# File content, commit message, and config value are all 'ÄPFEL sind gut'.
|
|
320
|
+
# 'Ä' is two bytes in UTF-8 (C3 84), so '.' has to match both to match the character.
|
|
321
|
+
|
|
322
|
+
repo.grep('^.PFEL') # => {} on Windows, matches elsewhere
|
|
323
|
+
repo.log.grep('^.PFEL').execute.size # => 0 on Windows, 1 elsewhere
|
|
324
|
+
repo.config_get_all('test.desc', '^.PFEL') # => [] on Windows, matches elsewhere
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
This is a property of the regex engine git bundles on that platform, not something the
|
|
328
|
+
gem sets. It is unaffected by the locale: the behavior is identical under `en_US.UTF-8`,
|
|
329
|
+
`C.UTF-8`, `C`, and with no `LC_ALL` set at all. Literal (metacharacter-free) patterns
|
|
330
|
+
and case-insensitive matching are unaffected on every platform.
|
|
331
|
+
|
|
332
|
+
**Workaround.** Perl-compatible regular expressions do match characters on Git for
|
|
333
|
+
Windows, so the surfaces that can reach a PCRE engine accept an opt-in selector:
|
|
334
|
+
|
|
335
|
+
```ruby
|
|
336
|
+
repo.grep('^.PFEL', nil, perl_regexp: true) # matches on every platform
|
|
337
|
+
repo.log.perl_regexp.grep('^.PFEL').execute # matches on every platform
|
|
338
|
+
repo.full_log_commits(grep: '^.PFEL', perl_regexp: true)
|
|
339
|
+
```
|
|
340
|
+
|
|
341
|
+
Two caveats:
|
|
342
|
+
|
|
343
|
+
- **PCRE is a different dialect** than git's default POSIX basic/extended regular
|
|
344
|
+
expressions. Selecting it is a deliberate choice by the caller, so the gem does not
|
|
345
|
+
substitute it automatically based on the host.
|
|
346
|
+
- **PCRE must be compiled in.** Git for Windows and the mainstream Linux and macOS
|
|
347
|
+
packages ship it, but git built without `USE_LIBPCRE` fails with `cannot use
|
|
348
|
+
Perl-compatible regexes...`.
|
|
349
|
+
|
|
350
|
+
**There is no workaround for `git config` value patterns.** They are POSIX extended
|
|
351
|
+
regular expressions with no PCRE mode, so `config_get`, `config_get_all`,
|
|
352
|
+
`config_get_regexp`, `config_replace_all`, `config_unset`, and `config_unset_all` cannot
|
|
353
|
+
match a metacharacter against a non-ASCII character on Git for Windows. Match on ASCII
|
|
354
|
+
text or an exact value instead.
|
|
355
|
+
|
|
356
|
+
`config_replace_all` deserves particular care, because there the failure is not merely an
|
|
357
|
+
empty result. When the value pattern selects nothing, `git config --replace-all` *adds*
|
|
358
|
+
the new value as an additional entry rather than replacing one, and exits zero:
|
|
359
|
+
|
|
360
|
+
```ruby
|
|
361
|
+
# Existing value of test.desc is 'ÄPFEL sind gut'
|
|
362
|
+
repo.config_replace_all('test.desc', 'NEW', '^.PFEL')
|
|
363
|
+
|
|
364
|
+
repo.config_get_all('test.desc').map(&:value)
|
|
365
|
+
# => ["NEW"] elsewhere — replaced, as intended
|
|
366
|
+
# => ["ÄPFEL sind gut", "NEW"] on Windows — original kept, duplicate added
|
|
367
|
+
```
|
|
368
|
+
|
|
369
|
+
So a replace can silently leave the original value in place and add a second entry beside
|
|
370
|
+
it. Confirm with `config_get_all` when the key must end up single-valued.
|
|
371
|
+
|
|
305
372
|
## Project Policies
|
|
306
373
|
|
|
307
374
|
These documents set expectations for behavior, contribution workflows, AI-assisted
|
data/git.gemspec
CHANGED
|
@@ -46,31 +46,59 @@ Gem::Specification.new do |spec|
|
|
|
46
46
|
spec.add_dependency 'process_executer', '~> 4.0'
|
|
47
47
|
spec.add_dependency 'rchardet', '~> 1.9'
|
|
48
48
|
|
|
49
|
+
# Not every development dependency is installed on every runtime. Each predicate
|
|
50
|
+
# below names one reason for holding a gem back, which keeps the dependency list
|
|
51
|
+
# itself a flat, readable list. Deriving one predicate from another also keeps
|
|
52
|
+
# coupled gems from drifting apart when a condition changes.
|
|
53
|
+
#
|
|
54
|
+
# These are local variables rather than methods deliberately. The Gemfile uses
|
|
55
|
+
# `gemspec`, so Bundler evaluates this file on every `bundle exec`, and a top-level
|
|
56
|
+
# `def` -- including one written inside this block, since a block is not a definition
|
|
57
|
+
# scope -- would define a private method on Object in every one of those processes.
|
|
58
|
+
|
|
59
|
+
# JRuby (which reports RUBY_PLATFORM as 'java') and TruffleRuby build no C extensions
|
|
60
|
+
# and do not run the docs build.
|
|
61
|
+
mri = !(RUBY_PLATFORM == 'java' || RUBY_ENGINE == 'truffleruby')
|
|
62
|
+
|
|
63
|
+
# irb stopped being a default gem in Ruby 3.4. JRuby and TruffleRuby ship their own.
|
|
64
|
+
install_irb = mri
|
|
65
|
+
|
|
66
|
+
# Ruby 4.0.0 dropped fiddle from the default gems. On Windows, irb loads
|
|
67
|
+
# reline/io/windows.rb, which requires fiddle/import for the Win32 console API, so
|
|
68
|
+
# bin/console cannot start without it; every other platform takes reline's ANSI IO
|
|
69
|
+
# gate and never loads that file. Derived from install_irb because fiddle exists only
|
|
70
|
+
# to serve irb and, being a C extension, could not install where irb is not.
|
|
71
|
+
install_fiddle = install_irb && Gem.win_platform?
|
|
72
|
+
|
|
73
|
+
# The docs toolchain is supported on MRI only. redcarpet, YARD's Markdown renderer,
|
|
74
|
+
# is also a C extension and so could not install on JRuby regardless.
|
|
75
|
+
install_docs = mri
|
|
76
|
+
|
|
77
|
+
# yard-lint requires Ruby >= 3.3.
|
|
78
|
+
install_yard_lint = install_docs && Gem.ruby_version >= Gem::Version.new('3.3.0')
|
|
79
|
+
|
|
80
|
+
# i18n 1.15+ uses Fiber.[] (Ruby 3.2 Fiber storage), which TruffleRuby < 34.0.0 does
|
|
81
|
+
# not implement, so those runtimes hold at the last release that works there.
|
|
82
|
+
pin_old_i18n = RUBY_ENGINE == 'truffleruby' &&
|
|
83
|
+
Gem::Version.new(RUBY_ENGINE_VERSION) < Gem::Version.new('34.0.0')
|
|
84
|
+
|
|
49
85
|
spec.add_development_dependency 'create_github_release', '~> 2.1'
|
|
86
|
+
spec.add_development_dependency 'fiddle', '~> 1.1' if install_fiddle
|
|
50
87
|
spec.add_development_dependency 'fuubar', '~> 2.5'
|
|
88
|
+
spec.add_development_dependency 'i18n', '< 1.15' if pin_old_i18n
|
|
89
|
+
spec.add_development_dependency 'irb', '~> 1.16' if install_irb
|
|
51
90
|
spec.add_development_dependency 'main_branch_shared_rubocop_config', '~> 0.1'
|
|
52
91
|
spec.add_development_dependency 'parallel_tests', '~> 5.6'
|
|
53
92
|
spec.add_development_dependency 'rake', '~> 13.3'
|
|
93
|
+
spec.add_development_dependency 'redcarpet', '~> 3.6' if install_docs
|
|
54
94
|
spec.add_development_dependency 'rspec', '~> 3.13'
|
|
55
95
|
spec.add_development_dependency 'rubocop', '~> 1.82'
|
|
56
96
|
spec.add_development_dependency 'simplecov', '~> 1.0'
|
|
57
97
|
spec.add_development_dependency 'simplecov-lcov', '~> 0.9'
|
|
58
98
|
spec.add_development_dependency 'simplecov-rspec', '~> 1.1'
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
spec.add_development_dependency 'i18n', '< 1.15'
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
unless RUBY_PLATFORM == 'java' || RUBY_ENGINE == 'truffleruby'
|
|
66
|
-
spec.add_development_dependency 'irb', '~> 1.16'
|
|
67
|
-
spec.add_development_dependency 'redcarpet', '~> 3.6'
|
|
68
|
-
spec.add_development_dependency 'yard', '~> 0.9', '>= 0.9.28'
|
|
69
|
-
spec.add_development_dependency 'yard_example_test', '~> 0.2', '>= 0.2.1'
|
|
70
|
-
|
|
71
|
-
# yard-lint requires Ruby >= 3.3, so it is only installed on Ruby 3.3+.
|
|
72
|
-
spec.add_development_dependency 'yard-lint', '~> 1.8' if Gem.ruby_version >= Gem::Version.new('3.3.0')
|
|
73
|
-
end
|
|
99
|
+
spec.add_development_dependency 'yard', '~> 0.9', '>= 0.9.28' if install_docs
|
|
100
|
+
spec.add_development_dependency 'yard_example_test', '~> 0.2', '>= 0.2.1' if install_docs
|
|
101
|
+
spec.add_development_dependency 'yard-lint', '~> 1.8' if install_yard_lint
|
|
74
102
|
|
|
75
103
|
# Specify which files should be added to the gem when it is released.
|
|
76
104
|
# The `git ls-files -z` loads the files in the RubyGem that have been added into git.
|
data/lib/git/configuring.rb
CHANGED
|
@@ -88,6 +88,14 @@ module Git
|
|
|
88
88
|
#
|
|
89
89
|
# @raise [Git::FailedError] if git exits with an unexpected non-zero status
|
|
90
90
|
#
|
|
91
|
+
# @note On Git for Windows, git's default regex engine matches *bytes* rather than
|
|
92
|
+
# characters, so a metacharacter such as `.` or a POSIX class such as
|
|
93
|
+
# `[[:alpha:]]` in `value_regex` never matches a whole multi-byte character. The
|
|
94
|
+
# failure is silent: nothing raises, and the outcome is indistinguishable from a
|
|
95
|
+
# `value_regex` that genuinely matches nothing. `git config` value patterns are
|
|
96
|
+
# POSIX extended regular expressions with no PCRE mode, so unlike
|
|
97
|
+
# {Git::Repository#grep} there is no alternate regex engine to select here.
|
|
98
|
+
#
|
|
91
99
|
def config_get(name, value_regex = nil, **options)
|
|
92
100
|
Private.assert_valid_opts!(CONFIG_GET_ALLOWED_OPTS, **options)
|
|
93
101
|
assert_valid_scope!(**options)
|
|
@@ -139,6 +147,14 @@ module Git
|
|
|
139
147
|
#
|
|
140
148
|
# @raise [Git::FailedError] if git exits with an unexpected non-zero status
|
|
141
149
|
#
|
|
150
|
+
# @note On Git for Windows, git's default regex engine matches *bytes* rather than
|
|
151
|
+
# characters, so a metacharacter such as `.` or a POSIX class such as
|
|
152
|
+
# `[[:alpha:]]` in `value_regex` never matches a whole multi-byte character. The
|
|
153
|
+
# failure is silent: nothing raises, and the outcome is indistinguishable from a
|
|
154
|
+
# `value_regex` that genuinely matches nothing. `git config` value patterns are
|
|
155
|
+
# POSIX extended regular expressions with no PCRE mode, so unlike
|
|
156
|
+
# {Git::Repository#grep} there is no alternate regex engine to select here.
|
|
157
|
+
#
|
|
142
158
|
def config_get_all(name, value_regex = nil, **options)
|
|
143
159
|
Private.assert_valid_opts!(CONFIG_GET_ALL_ALLOWED_OPTS, **options)
|
|
144
160
|
assert_valid_scope!(**options)
|
|
@@ -238,6 +254,14 @@ module Git
|
|
|
238
254
|
#
|
|
239
255
|
# @raise [Git::FailedError] if git exits with an unexpected non-zero status
|
|
240
256
|
#
|
|
257
|
+
# @note On Git for Windows, git's default regex engine matches *bytes* rather than
|
|
258
|
+
# characters, so a metacharacter such as `.` or a POSIX class such as
|
|
259
|
+
# `[[:alpha:]]` in `value_regex` never matches a whole multi-byte character. The
|
|
260
|
+
# failure is silent: nothing raises, and the outcome is indistinguishable from a
|
|
261
|
+
# `value_regex` that genuinely matches nothing. `git config` value patterns are
|
|
262
|
+
# POSIX extended regular expressions with no PCRE mode, so unlike
|
|
263
|
+
# {Git::Repository#grep} there is no alternate regex engine to select here.
|
|
264
|
+
#
|
|
241
265
|
def config_get_regexp(name_regex, value_regex = nil, **options)
|
|
242
266
|
Private.assert_valid_opts!(CONFIG_GET_REGEXP_ALLOWED_OPTS, **options)
|
|
243
267
|
assert_valid_scope!(**options)
|
|
@@ -529,6 +553,22 @@ module Git
|
|
|
529
553
|
#
|
|
530
554
|
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
531
555
|
#
|
|
556
|
+
# @note On Git for Windows, git's default regex engine matches *bytes* rather than
|
|
557
|
+
# characters, so a metacharacter such as `.` or a POSIX class such as
|
|
558
|
+
# `[[:alpha:]]` in `value_regex` never matches a whole multi-byte character. The
|
|
559
|
+
# failure is silent: nothing raises, and the outcome is indistinguishable from a
|
|
560
|
+
# `value_regex` that genuinely matches nothing. `git config` value patterns are
|
|
561
|
+
# POSIX extended regular expressions with no PCRE mode, so unlike
|
|
562
|
+
# {Git::Repository#grep} there is no alternate regex engine to select here.
|
|
563
|
+
#
|
|
564
|
+
# @note A `value_regex` that selects nothing does not make this method a no-op.
|
|
565
|
+
# `git config --replace-all` *adds* `value` as an additional entry when no
|
|
566
|
+
# existing value matches, and exits zero. On Git for Windows, a `value_regex`
|
|
567
|
+
# whose metacharacters span non-ASCII text therefore leaves the value it was
|
|
568
|
+
# meant to replace in place and silently creates a duplicate entry beside it.
|
|
569
|
+
# Confirm the result with {#config_get_all}, or match on ASCII text, when the
|
|
570
|
+
# key must end up single-valued.
|
|
571
|
+
#
|
|
532
572
|
def config_replace_all(name, value, value_regex = nil, **)
|
|
533
573
|
Private.assert_valid_opts!(CONFIG_REPLACE_ALL_ALLOWED_OPTS, **)
|
|
534
574
|
assert_valid_scope!(**)
|
|
@@ -621,6 +661,14 @@ module Git
|
|
|
621
661
|
#
|
|
622
662
|
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
623
663
|
#
|
|
664
|
+
# @note On Git for Windows, git's default regex engine matches *bytes* rather than
|
|
665
|
+
# characters, so a metacharacter such as `.` or a POSIX class such as
|
|
666
|
+
# `[[:alpha:]]` in `value_regex` never matches a whole multi-byte character. The
|
|
667
|
+
# failure is silent: nothing raises, and the outcome is indistinguishable from a
|
|
668
|
+
# `value_regex` that genuinely matches nothing. `git config` value patterns are
|
|
669
|
+
# POSIX extended regular expressions with no PCRE mode, so unlike
|
|
670
|
+
# {Git::Repository#grep} there is no alternate regex engine to select here.
|
|
671
|
+
#
|
|
624
672
|
def config_unset(name, value_regex = nil, **)
|
|
625
673
|
Private.assert_valid_opts!(CONFIG_UNSET_ALLOWED_OPTS, **)
|
|
626
674
|
assert_valid_scope!(**)
|
|
@@ -666,6 +714,14 @@ module Git
|
|
|
666
714
|
#
|
|
667
715
|
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
668
716
|
#
|
|
717
|
+
# @note On Git for Windows, git's default regex engine matches *bytes* rather than
|
|
718
|
+
# characters, so a metacharacter such as `.` or a POSIX class such as
|
|
719
|
+
# `[[:alpha:]]` in `value_regex` never matches a whole multi-byte character. The
|
|
720
|
+
# failure is silent: nothing raises, and the outcome is indistinguishable from a
|
|
721
|
+
# `value_regex` that genuinely matches nothing. `git config` value patterns are
|
|
722
|
+
# POSIX extended regular expressions with no PCRE mode, so unlike
|
|
723
|
+
# {Git::Repository#grep} there is no alternate regex engine to select here.
|
|
724
|
+
#
|
|
669
725
|
def config_unset_all(name, value_regex = nil, **)
|
|
670
726
|
Private.assert_valid_opts!(CONFIG_UNSET_ALL_ALLOWED_OPTS, **)
|
|
671
727
|
assert_valid_scope!(**)
|
|
@@ -453,12 +453,68 @@ module Git
|
|
|
453
453
|
'GIT_INDEX_FILE' => git_index_file,
|
|
454
454
|
'GIT_SSH' => git_ssh,
|
|
455
455
|
'GIT_EDITOR' => 'true',
|
|
456
|
-
'
|
|
456
|
+
# Pin the locale so git's behavior does not depend on the user's environment.
|
|
457
|
+
# Added for issue #753, where a German user's `git branch` output
|
|
458
|
+
# ("* (HEAD losgelöst bei origin/25.1)") broke branch parsing.
|
|
459
|
+
#
|
|
460
|
+
# The pin has two halves, and the load-bearing one is not the obvious one:
|
|
461
|
+
#
|
|
462
|
+
# - Messages: keeps git's human-readable text in English. This is now only
|
|
463
|
+
# defense-in-depth — lib/ reads `--format=%(refname:short)` rather than
|
|
464
|
+
# git's prose, and matches no English git message.
|
|
465
|
+
# - Ctype: makes git's regex engine match *characters* rather than *bytes*.
|
|
466
|
+
# This is the half that matters. Under a C ctype, `grep`, `log`, and the
|
|
467
|
+
# `config` value regexes silently return wrong answers — with exit status
|
|
468
|
+
# zero — for any pattern whose metacharacters span non-ASCII text.
|
|
469
|
+
#
|
|
470
|
+
# So do not "simplify" this to `C`: that yields English messages and a broken
|
|
471
|
+
# ctype, which is the worst of both. A pinned locale the host does not have
|
|
472
|
+
# degrades to that same C ctype, which is why each branch below has to name a
|
|
473
|
+
# locale that actually exists on the platform it applies to:
|
|
474
|
+
#
|
|
475
|
+
# - Non-Darwin: `C.UTF-8`. Stock Debian, Ubuntu, and RHEL images generate no
|
|
476
|
+
# `en_US.UTF-8`, so pinning it there produced exactly the silent breakage
|
|
477
|
+
# above. (musl ignores the locale name for ctype, so Alpine is UTF-8 either
|
|
478
|
+
# way.)
|
|
479
|
+
# - Darwin: `en_US.UTF-8`, which every macOS release ships. `C.UTF-8` did not
|
|
480
|
+
# arrive until macOS 15, so macOS 11–14 — including Intel Macs that are
|
|
481
|
+
# hardware-capped below 15 — would break under it. Delete this branch once
|
|
482
|
+
# macOS 14 and earlier are out of support.
|
|
483
|
+
#
|
|
484
|
+
# Windows takes the non-Darwin branch, where the value makes no difference:
|
|
485
|
+
# Git for Windows folds case and runs PCRE in UTF mode under every value, and
|
|
486
|
+
# matches bytes for `.` and POSIX classes under every value — measured on git
|
|
487
|
+
# 2.55.0 against `en_US.UTF-8`, `C.UTF-8`, `C`, and no pin at all.
|
|
488
|
+
#
|
|
489
|
+
# RHEL 7 (glibc 2.17) has neither locale and gets a C ctype whatever is pinned.
|
|
490
|
+
# It is EOL, and there is deliberately no public override for this value.
|
|
491
|
+
'LC_ALL' => darwin_platform? ? 'en_US.UTF-8' : 'C.UTF-8'
|
|
457
492
|
}.merge(additional_overrides)
|
|
458
493
|
end
|
|
459
494
|
|
|
460
495
|
private
|
|
461
496
|
|
|
497
|
+
# Whether this process is running on macOS
|
|
498
|
+
#
|
|
499
|
+
# Checks `RUBY_DESCRIPTION` as well as `RUBY_PLATFORM` because JRuby reports
|
|
500
|
+
# `RUBY_PLATFORM` as `"java"` on every host and records the real platform only in
|
|
501
|
+
# `RUBY_DESCRIPTION` (as, for example, `"... [arm64-darwin]"`). Testing
|
|
502
|
+
# `RUBY_PLATFORM` alone would put JRuby on macOS onto the non-Darwin branch of the
|
|
503
|
+
# `LC_ALL` pin, which is the one platform pairing that branch must never be given —
|
|
504
|
+
# see {#env_overrides}.
|
|
505
|
+
#
|
|
506
|
+
# Test the platform plainly rather than sniffing the Darwin version: `RUBY_PLATFORM`
|
|
507
|
+
# records the version Ruby was *built* against, so a Ruby built on macOS 14 still
|
|
508
|
+
# reports `darwin23` when run on macOS 15.
|
|
509
|
+
#
|
|
510
|
+
# @return [Boolean] true if this process is running on macOS
|
|
511
|
+
#
|
|
512
|
+
# @api private
|
|
513
|
+
#
|
|
514
|
+
def darwin_platform?
|
|
515
|
+
RUBY_PLATFORM.include?('darwin') || RUBY_DESCRIPTION.include?('darwin')
|
|
516
|
+
end
|
|
517
|
+
|
|
462
518
|
# Returns the Array of git global option strings for this context
|
|
463
519
|
#
|
|
464
520
|
# Prepends `--git-dir` and `--work-tree` when the corresponding attributes
|
data/lib/git/log.rb
CHANGED
|
@@ -142,6 +142,25 @@ module Git
|
|
|
142
142
|
#
|
|
143
143
|
def grep(regex) = set_option(:grep, regex)
|
|
144
144
|
|
|
145
|
+
# Interprets {#grep} and {#author} patterns as Perl-compatible regular expressions
|
|
146
|
+
#
|
|
147
|
+
# Selects PCRE instead of git's default POSIX basic regular expressions for
|
|
148
|
+
# every pattern in the query. Requires a git built with PCRE support.
|
|
149
|
+
#
|
|
150
|
+
# @example Match a metacharacter against a non-ASCII character on Git for Windows
|
|
151
|
+
# repo.log.perl_regexp.grep('^.PFEL').execute
|
|
152
|
+
#
|
|
153
|
+
# @return [Git::Log] the current query builder
|
|
154
|
+
#
|
|
155
|
+
# @note On Git for Windows, git's default regex engine matches *bytes* rather
|
|
156
|
+
# than characters, so a metacharacter such as `.` or a POSIX class such as
|
|
157
|
+
# `[[:alpha:]]` never matches a whole multi-byte character. The match fails
|
|
158
|
+
# silently: git exits zero and the result is empty. PCRE does match characters
|
|
159
|
+
# on that platform, but it is a different dialect than git's default, so
|
|
160
|
+
# selecting it is a deliberate choice by the caller.
|
|
161
|
+
#
|
|
162
|
+
def perl_regexp = set_option(:perl_regexp, true)
|
|
163
|
+
|
|
145
164
|
# Limits commits to those that touch the given path or paths
|
|
146
165
|
#
|
|
147
166
|
# @param path [String, Pathname, Array<String, Pathname>] path limiter input
|
|
@@ -18,7 +18,7 @@ module Git
|
|
|
18
18
|
# @return [Array<Symbol>] the supported option keys
|
|
19
19
|
#
|
|
20
20
|
FULL_LOG_COMMITS_ALLOWED_OPTS = %i[
|
|
21
|
-
count all cherry since until grep author between object path_limiter skip merges
|
|
21
|
+
count all cherry since until grep author between object path_limiter skip merges perl_regexp
|
|
22
22
|
].freeze
|
|
23
23
|
private_constant :FULL_LOG_COMMITS_ALLOWED_OPTS
|
|
24
24
|
|
|
@@ -68,6 +68,13 @@ module Git
|
|
|
68
68
|
#
|
|
69
69
|
# @option opts [Boolean, nil] :merges (nil) include only merge commits
|
|
70
70
|
#
|
|
71
|
+
# @option opts [Boolean, nil] :perl_regexp (nil) interpret the `:grep` and
|
|
72
|
+
# `:author` patterns as Perl-compatible regular expressions (PCRE) instead of
|
|
73
|
+
# git's default POSIX basic regular expressions
|
|
74
|
+
#
|
|
75
|
+
# Requires a git built with PCRE support; git otherwise fails with
|
|
76
|
+
# "cannot use Perl-compatible regexes...".
|
|
77
|
+
#
|
|
71
78
|
# @return [Array<Hash>] the parsed raw log output for each commit
|
|
72
79
|
#
|
|
73
80
|
# @raise [ArgumentError] if unsupported options are provided
|
|
@@ -76,6 +83,14 @@ module Git
|
|
|
76
83
|
#
|
|
77
84
|
# @raise [Git::FailedError] if git exits with a non-zero exit status
|
|
78
85
|
#
|
|
86
|
+
# @note On Git for Windows, git's default regex engine matches *bytes* rather
|
|
87
|
+
# than characters, so a metacharacter such as `.` or a POSIX class such as
|
|
88
|
+
# `[[:alpha:]]` never matches a whole multi-byte character in a `:grep` or
|
|
89
|
+
# `:author` pattern. The match fails silently: git exits zero and the result
|
|
90
|
+
# is empty. Pass `perl_regexp: true` to select PCRE, which does match
|
|
91
|
+
# characters. PCRE is a different dialect than git's default, so this is a
|
|
92
|
+
# deliberate choice by the caller rather than a transparent substitution.
|
|
93
|
+
#
|
|
79
94
|
# @see https://git-scm.com/docs/git-log git-log
|
|
80
95
|
#
|
|
81
96
|
def full_log_commits(opts = {})
|
|
@@ -113,6 +128,14 @@ module Git
|
|
|
113
128
|
module Private
|
|
114
129
|
module_function
|
|
115
130
|
|
|
131
|
+
# Log option keys forwarded to {Git::Commands::Log#call} under the same name
|
|
132
|
+
#
|
|
133
|
+
# The remaining options are renamed or reshaped by {#log_base_call_options}.
|
|
134
|
+
#
|
|
135
|
+
# @return [Array<Symbol>] the pass-through option keys
|
|
136
|
+
#
|
|
137
|
+
PASSTHROUGH_LOG_OPTS = %i[all cherry since until grep author perl_regexp].freeze
|
|
138
|
+
|
|
116
139
|
# Validates the :count log option
|
|
117
140
|
#
|
|
118
141
|
# @param opts [Hash] the log options
|
|
@@ -195,6 +218,9 @@ module Git
|
|
|
195
218
|
# @option opts [String, nil] :author (nil) only include commits whose author
|
|
196
219
|
# matches this pattern
|
|
197
220
|
#
|
|
221
|
+
# @option opts [Boolean, nil] :perl_regexp (nil) interpret the `:grep` and
|
|
222
|
+
# `:author` patterns as Perl-compatible regular expressions
|
|
223
|
+
#
|
|
198
224
|
# @option opts [Integer, nil] :count (nil) maximum number of commits to return
|
|
199
225
|
#
|
|
200
226
|
# @option opts [String, Pathname, Array<String, Pathname>, nil] :path_limiter (nil)
|
|
@@ -207,16 +233,14 @@ module Git
|
|
|
207
233
|
# @return [Hash] keyword options for {Git::Commands::Log#call}
|
|
208
234
|
#
|
|
209
235
|
def log_base_call_options(opts, extra = {})
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
path: opts[:path_limiter] ? Array(opts[:path_limiter]) : nil
|
|
219
|
-
}.merge(extra).compact
|
|
236
|
+
opts
|
|
237
|
+
.slice(*PASSTHROUGH_LOG_OPTS)
|
|
238
|
+
.merge(
|
|
239
|
+
max_count: opts[:count],
|
|
240
|
+
path: opts[:path_limiter] ? Array(opts[:path_limiter]) : nil
|
|
241
|
+
)
|
|
242
|
+
.merge(extra)
|
|
243
|
+
.compact
|
|
220
244
|
end
|
|
221
245
|
|
|
222
246
|
# Executes git log and parses the raw output
|
|
@@ -454,7 +454,7 @@ module Git
|
|
|
454
454
|
end
|
|
455
455
|
|
|
456
456
|
# Option keys accepted by {#grep}
|
|
457
|
-
GREP_ALLOWED_OPTS = %i[ignore_case i invert_match v extended_regexp E object].freeze
|
|
457
|
+
GREP_ALLOWED_OPTS = %i[ignore_case i invert_match v extended_regexp E perl_regexp P object].freeze
|
|
458
458
|
private_constant :GREP_ALLOWED_OPTS
|
|
459
459
|
|
|
460
460
|
# Search tracked file contents in a git tree for a pattern
|
|
@@ -475,6 +475,9 @@ module Git
|
|
|
475
475
|
# @example Case-insensitive search
|
|
476
476
|
# repo.grep('todo', nil, ignore_case: true)
|
|
477
477
|
#
|
|
478
|
+
# @example Match a metacharacter against a non-ASCII character on Git for Windows
|
|
479
|
+
# repo.grep('^.PFEL', nil, perl_regexp: true)
|
|
480
|
+
#
|
|
478
481
|
# @param pattern [String] the pattern to search for
|
|
479
482
|
#
|
|
480
483
|
# @param path_limiter [String, Pathname, Array<String, Pathname>, nil]
|
|
@@ -499,6 +502,14 @@ module Git
|
|
|
499
502
|
#
|
|
500
503
|
# Alias: :E
|
|
501
504
|
#
|
|
505
|
+
# @option opts [Boolean, nil] :perl_regexp (nil) use Perl-compatible regular
|
|
506
|
+
# expressions (PCRE) for the pattern
|
|
507
|
+
#
|
|
508
|
+
# Requires a git built with PCRE support; git otherwise fails with
|
|
509
|
+
# "cannot use Perl-compatible regexes...".
|
|
510
|
+
#
|
|
511
|
+
# Alias: :P
|
|
512
|
+
#
|
|
502
513
|
# @return [Hash<String, Array<Array(Integer, String)>>] a hash mapping
|
|
503
514
|
# each `"treeish:filename"` key to an array of `[line_number, text]`
|
|
504
515
|
# pairs; returns an empty hash when no lines match
|
|
@@ -508,6 +519,16 @@ module Git
|
|
|
508
519
|
# @raise [Git::FailedError] if git exits with a non-zero status and
|
|
509
520
|
# stderr is non-empty (e.g. bad object reference)
|
|
510
521
|
#
|
|
522
|
+
# @note On Git for Windows, git's default regex engine matches *bytes* rather
|
|
523
|
+
# than characters, so a metacharacter such as `.` or a POSIX class such as
|
|
524
|
+
# `[[:alpha:]]` never matches a whole multi-byte character. The failure is
|
|
525
|
+
# silent: nothing raises, and the empty hash returned is indistinguishable
|
|
526
|
+
# from a pattern that genuinely does not occur in the tree. Pass
|
|
527
|
+
# `perl_regexp: true` to select PCRE, which does match characters. PCRE is a
|
|
528
|
+
# different dialect than git's default POSIX basic/extended regular
|
|
529
|
+
# expressions, so this is a deliberate choice by the caller rather than a
|
|
530
|
+
# transparent substitution, and it requires a git built with PCRE support.
|
|
531
|
+
#
|
|
511
532
|
# @see https://git-scm.com/docs/git-grep git-grep documentation
|
|
512
533
|
#
|
|
513
534
|
def grep(pattern, path_limiter = nil, opts = {})
|
data/lib/git/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: git
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 5.0
|
|
4
|
+
version: 5.1.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Scott Chacon and others
|
|
@@ -93,6 +93,20 @@ dependencies:
|
|
|
93
93
|
- - "~>"
|
|
94
94
|
- !ruby/object:Gem::Version
|
|
95
95
|
version: '2.5'
|
|
96
|
+
- !ruby/object:Gem::Dependency
|
|
97
|
+
name: irb
|
|
98
|
+
requirement: !ruby/object:Gem::Requirement
|
|
99
|
+
requirements:
|
|
100
|
+
- - "~>"
|
|
101
|
+
- !ruby/object:Gem::Version
|
|
102
|
+
version: '1.16'
|
|
103
|
+
type: :development
|
|
104
|
+
prerelease: false
|
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
106
|
+
requirements:
|
|
107
|
+
- - "~>"
|
|
108
|
+
- !ruby/object:Gem::Version
|
|
109
|
+
version: '1.16'
|
|
96
110
|
- !ruby/object:Gem::Dependency
|
|
97
111
|
name: main_branch_shared_rubocop_config
|
|
98
112
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -135,6 +149,20 @@ dependencies:
|
|
|
135
149
|
- - "~>"
|
|
136
150
|
- !ruby/object:Gem::Version
|
|
137
151
|
version: '13.3'
|
|
152
|
+
- !ruby/object:Gem::Dependency
|
|
153
|
+
name: redcarpet
|
|
154
|
+
requirement: !ruby/object:Gem::Requirement
|
|
155
|
+
requirements:
|
|
156
|
+
- - "~>"
|
|
157
|
+
- !ruby/object:Gem::Version
|
|
158
|
+
version: '3.6'
|
|
159
|
+
type: :development
|
|
160
|
+
prerelease: false
|
|
161
|
+
version_requirements: !ruby/object:Gem::Requirement
|
|
162
|
+
requirements:
|
|
163
|
+
- - "~>"
|
|
164
|
+
- !ruby/object:Gem::Version
|
|
165
|
+
version: '3.6'
|
|
138
166
|
- !ruby/object:Gem::Dependency
|
|
139
167
|
name: rspec
|
|
140
168
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -205,34 +233,6 @@ dependencies:
|
|
|
205
233
|
- - "~>"
|
|
206
234
|
- !ruby/object:Gem::Version
|
|
207
235
|
version: '1.1'
|
|
208
|
-
- !ruby/object:Gem::Dependency
|
|
209
|
-
name: irb
|
|
210
|
-
requirement: !ruby/object:Gem::Requirement
|
|
211
|
-
requirements:
|
|
212
|
-
- - "~>"
|
|
213
|
-
- !ruby/object:Gem::Version
|
|
214
|
-
version: '1.16'
|
|
215
|
-
type: :development
|
|
216
|
-
prerelease: false
|
|
217
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
218
|
-
requirements:
|
|
219
|
-
- - "~>"
|
|
220
|
-
- !ruby/object:Gem::Version
|
|
221
|
-
version: '1.16'
|
|
222
|
-
- !ruby/object:Gem::Dependency
|
|
223
|
-
name: redcarpet
|
|
224
|
-
requirement: !ruby/object:Gem::Requirement
|
|
225
|
-
requirements:
|
|
226
|
-
- - "~>"
|
|
227
|
-
- !ruby/object:Gem::Version
|
|
228
|
-
version: '3.6'
|
|
229
|
-
type: :development
|
|
230
|
-
prerelease: false
|
|
231
|
-
version_requirements: !ruby/object:Gem::Requirement
|
|
232
|
-
requirements:
|
|
233
|
-
- - "~>"
|
|
234
|
-
- !ruby/object:Gem::Version
|
|
235
|
-
version: '3.6'
|
|
236
236
|
- !ruby/object:Gem::Dependency
|
|
237
237
|
name: yard
|
|
238
238
|
requirement: !ruby/object:Gem::Requirement
|
|
@@ -347,6 +347,7 @@ files:
|
|
|
347
347
|
- ".github/workflows/enforce_conventional_commits.yml"
|
|
348
348
|
- ".github/workflows/experimental_continuous_integration.yml"
|
|
349
349
|
- ".github/workflows/release.yml"
|
|
350
|
+
- ".github/workflows/warm_bundler_caches.yml"
|
|
350
351
|
- ".gitignore"
|
|
351
352
|
- ".husky/commit-msg"
|
|
352
353
|
- ".husky/pre-commit"
|
|
@@ -630,8 +631,8 @@ licenses:
|
|
|
630
631
|
metadata:
|
|
631
632
|
homepage_uri: http://github.com/ruby-git/ruby-git
|
|
632
633
|
source_code_uri: http://github.com/ruby-git/ruby-git
|
|
633
|
-
changelog_uri: https://rubydoc.info/gems/git/5.0
|
|
634
|
-
documentation_uri: https://rubydoc.info/gems/git/5.0
|
|
634
|
+
changelog_uri: https://rubydoc.info/gems/git/5.1.0/file/CHANGELOG.md
|
|
635
|
+
documentation_uri: https://rubydoc.info/gems/git/5.1.0
|
|
635
636
|
rubygems_mfa_required: 'true'
|
|
636
637
|
rdoc_options: []
|
|
637
638
|
require_paths:
|