git 5.4.1 → 5.6.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/CHANGELOG.md +31 -0
- data/CONTRIBUTING.md +16 -12
- data/README.md +6 -5
- data/UPGRADING.md +55 -0
- data/lib/git/repository/context_helpers.rb +81 -14
- data/lib/git/version.rb +1 -1
- data/lib/git.rb +27 -7
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: fb847c9e15258e66f25f6856a2ceb170213e9ae310d061035ef23501e6e0cd72
|
|
4
|
+
data.tar.gz: eca3a73ec5bf9f979d4576375062ceaeb71a78b54f12660b3b4386c2920792e9
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3842eadabba8c7bead2147b438ca51597ca0acc129b7d33b41f942750d29cb7e5910b1ca92e3f50cf7bc440afb9f5ed203a97f38b72c19b09025f4e7317849f2
|
|
7
|
+
data.tar.gz: 558adf7d3f23639b9143dcf3b9092739caba6415e066a8273f491f0589f3af06851dc15fd1776b2bad3e406d01429da76cce72c7e05f3c7ac57858bc3a771645
|
data/CHANGELOG.md
CHANGED
|
@@ -5,6 +5,37 @@
|
|
|
5
5
|
|
|
6
6
|
# Change Log
|
|
7
7
|
|
|
8
|
+
## [5.6.0](https://github.com/ruby-git/ruby-git/compare/v5.5.0...v5.6.0) (2026-09-12)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* **repository:** Deprecate with_* context helper blocks that declare no parameter ([231b65c](https://github.com/ruby-git/ruby-git/commit/231b65c435e9b3d9cdbf8b113b3aba9313da5110)), closes [#1835](https://github.com/ruby-git/ruby-git/issues/1835)
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
### Other Changes
|
|
17
|
+
|
|
18
|
+
* **export:** Describe what a failed .git removal leaves behind ([bd08096](https://github.com/ruby-git/ruby-git/commit/bd080964e44a11594202726e3823a8cafad62bd5)), closes [#1823](https://github.com/ruby-git/ruby-git/issues/1823)
|
|
19
|
+
|
|
20
|
+
## [5.5.0](https://github.com/ruby-git/ruby-git/compare/v5.4.1...v5.5.0) (2026-09-10)
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
### Features
|
|
24
|
+
|
|
25
|
+
* **export:** Warn when the :remote option is passed to Git.export ([55a9810](https://github.com/ruby-git/ruby-git/commit/55a9810b7681a510781e55b17026ec6e13dcbfa5)), closes [#1820](https://github.com/ruby-git/ruby-git/issues/1820)
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
### Bug Fixes
|
|
29
|
+
|
|
30
|
+
* **export:** Drop the redundant checkout that broke Git.export for tags ([5e8422d](https://github.com/ruby-git/ruby-git/commit/5e8422d2361bff43959a0bba2254118087907a2a)), closes [#1815](https://github.com/ruby-git/ruby-git/issues/1815)
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
### Other Changes
|
|
34
|
+
|
|
35
|
+
* **export:** Document the deprecated :remote option to Git.export ([3806d2b](https://github.com/ruby-git/ruby-git/commit/3806d2b5a6fdb167006097df83c783573024a521)), closes [#1820](https://github.com/ruby-git/ruby-git/issues/1820)
|
|
36
|
+
* Name the 5.x maintenance branch alongside 4.x ([ad30718](https://github.com/ruby-git/ruby-git/commit/ad30718a61cb89c343c84c71feb1c94cf3995f28))
|
|
37
|
+
* Run the CI, commitlint, release, and cache workflows for the 5.x branch ([7c3fd13](https://github.com/ruby-git/ruby-git/commit/7c3fd13994104c2c6b6564cc41d1e3c4e614255a))
|
|
38
|
+
|
|
8
39
|
## [5.4.1](https://github.com/ruby-git/ruby-git/compare/v5.4.0...v5.4.1) (2026-09-04)
|
|
9
40
|
|
|
10
41
|
|
data/CONTRIBUTING.md
CHANGED
|
@@ -128,7 +128,7 @@ bin/setup
|
|
|
128
128
|
3. Run `npm install` (when npm is available) to install the Conventional Commit
|
|
129
129
|
`commit-msg` hook used by this project (Husky + commitlint). A separate
|
|
130
130
|
`pre-commit` hook is also installed that blocks direct commits to the
|
|
131
|
-
protected branches (`main`, `4.x`).
|
|
131
|
+
protected branches (`main`, `5.x`, `4.x`).
|
|
132
132
|
4. Verify the toolchain by running `bundle exec rake --tasks`.
|
|
133
133
|
|
|
134
134
|
`bin/setup` checks for [lychee](https://lychee.cli.rs) alongside Ruby, git, and
|
|
@@ -197,7 +197,7 @@ Once your pull request is ready for review, request a review from at least one
|
|
|
197
197
|
|
|
198
198
|
During the review process, you may need to make additional commits; squash them.
|
|
199
199
|
You will also need to rebase your branch onto the latest version of the target
|
|
200
|
-
branch (e.g., `main` or `4.x`) before merging.
|
|
200
|
+
branch (e.g., `main`, `5.x`, or `4.x`) before merging.
|
|
201
201
|
|
|
202
202
|
At least one approval from a project maintainer is required before your pull request
|
|
203
203
|
can be merged. The maintainer is responsible for ensuring that the pull request meets
|
|
@@ -219,11 +219,13 @@ first keeps the review cycle short.
|
|
|
219
219
|
|
|
220
220
|
## Branch strategy
|
|
221
221
|
|
|
222
|
-
This project maintains
|
|
222
|
+
This project maintains `main` plus one maintenance branch for each supported previous
|
|
223
|
+
major series:
|
|
223
224
|
|
|
224
225
|
- **`main`**: All development. It releases the next version of the gem, including
|
|
225
|
-
the next major version.
|
|
226
|
-
|
|
226
|
+
the next major version. Its next release is v6.0.0; every further v5.x release is
|
|
227
|
+
cut from `5.x`.
|
|
228
|
+
- **`5.x`** and **`4.x`**: The maintenance branches for the v5.x and v4.x series. Each
|
|
227
229
|
receives bug fixes and security fixes, and backward-compatible features at the
|
|
228
230
|
maintainers' discretion.
|
|
229
231
|
|
|
@@ -233,8 +235,10 @@ each major series is supported.
|
|
|
233
235
|
When submitting a pull request:
|
|
234
236
|
|
|
235
237
|
- **New features and breaking changes**: Target the `main` branch
|
|
236
|
-
- **Bug fixes**: Target `main`, and maintainers will backport to
|
|
237
|
-
|
|
238
|
+
- **Bug fixes**: Target `main`, and maintainers will backport to the maintenance
|
|
239
|
+
branches if applicable
|
|
240
|
+
- **Security fixes**: Target `main` and every affected maintenance branch, or only a
|
|
241
|
+
maintenance branch if the issue affects that series alone
|
|
238
242
|
|
|
239
243
|
Removing a deprecated API follows the
|
|
240
244
|
[deprecation policy](.github/skills/breaking-change-analysis/SKILL.md#step-4-deprecation-policy):
|
|
@@ -981,9 +985,9 @@ skill. Follow it when writing or reviewing specs under `spec/unit/`.
|
|
|
981
985
|
|
|
982
986
|
#### Test coverage policy
|
|
983
987
|
|
|
984
|
-
**Every pull request to `main` must keep `bundle exec rake spec:unit` at
|
|
985
|
-
coverage and 100% branch coverage of `lib/`.** CI fails the build when it
|
|
986
|
-
below either threshold.
|
|
988
|
+
**Every pull request to `main` or `5.x` must keep `bundle exec rake spec:unit` at
|
|
989
|
+
100% line coverage and 100% branch coverage of `lib/`.** CI fails the build when it
|
|
990
|
+
drops below either threshold.
|
|
987
991
|
|
|
988
992
|
This is enforceable without being onerous because unit coverage in this project is
|
|
989
993
|
deterministic: `lib/` has no Ruby-version, Ruby-engine, or platform conditionals, and
|
|
@@ -1088,8 +1092,8 @@ $ LIST_UNCOVERED_DETAIL=true bundle exec rake spec:unit
|
|
|
1088
1092
|
$ open coverage/index.html
|
|
1089
1093
|
```
|
|
1090
1094
|
|
|
1091
|
-
This policy applies to `main`
|
|
1092
|
-
not held to these thresholds.
|
|
1095
|
+
This policy applies to `main` and `5.x`. The `4.x` maintenance branch predates it and
|
|
1096
|
+
is not held to these thresholds.
|
|
1093
1097
|
|
|
1094
1098
|
#### Unit tests vs integration tests
|
|
1095
1099
|
|
data/README.md
CHANGED
|
@@ -447,12 +447,13 @@ are in [UPGRADING.md](UPGRADING.md#upgrading-to-v600). See
|
|
|
447
447
|
### Release support policy
|
|
448
448
|
|
|
449
449
|
All development happens on `main`, which releases the next version of the gem,
|
|
450
|
-
including the next major version.
|
|
450
|
+
including the next major version. The next release from `main` is v6.0.0. Every
|
|
451
|
+
further v5.x release is cut from `5.x`.
|
|
451
452
|
|
|
452
|
-
|
|
453
|
-
series, currently `4.x`.
|
|
454
|
-
backward-compatible features at the maintainers' discretion. Fixes land on
|
|
455
|
-
first and are backported, except a fix for a problem that exists only in
|
|
453
|
+
Each supported previous major series is maintained on a branch named for that
|
|
454
|
+
series, currently `5.x` and `4.x`. These branches receive bug fixes and security
|
|
455
|
+
fixes, and backward-compatible features at the maintainers' discretion. Fixes land on
|
|
456
|
+
`main` first and are backported, except a fix for a problem that exists only in a
|
|
456
457
|
maintenance branch, which targets that branch directly.
|
|
457
458
|
|
|
458
459
|
Support for a major series ends when the second major after it is released. v4.x is
|
data/UPGRADING.md
CHANGED
|
@@ -34,6 +34,8 @@ to update your code when upgrading from the preceding major version.
|
|
|
34
34
|
- [`Git.clone` option renames](#gitclone-option-renames)
|
|
35
35
|
- [`Git::Log` Enumerable interface deprecated](#gitlog-enumerable-interface-deprecated)
|
|
36
36
|
- [`Git::Object::Commit#set_commit` deprecated](#gitobjectcommitset_commit-deprecated)
|
|
37
|
+
- [`Git.export` `:remote` option deprecated](#gitexport-remote-option-deprecated)
|
|
38
|
+
- [Context helper blocks that declare no parameter deprecated](#context-helper-blocks-that-declare-no-parameter-deprecated)
|
|
37
39
|
|
|
38
40
|
## Upgrading to v6.0.0
|
|
39
41
|
|
|
@@ -1117,4 +1119,57 @@ effect.
|
|
|
1117
1119
|
|-----------------------------------------------------|-------------|
|
|
1118
1120
|
| `commit.set_commit(data)` | `commit.from_data(data)` |
|
|
1119
1121
|
|
|
1122
|
+
#### `Git.export` `:remote` option deprecated
|
|
1123
|
+
|
|
1124
|
+
`Git.export` has always dropped a `:remote` option before calling `Git.clone`
|
|
1125
|
+
without telling the caller. Passing it now emits a deprecation warning. The option
|
|
1126
|
+
is still dropped, so the export itself is unchanged, and it will be removed in a
|
|
1127
|
+
future major release. Once it is removed, passing `:remote` raises `ArgumentError`
|
|
1128
|
+
like any other unsupported option (see [Unsupported options raise
|
|
1129
|
+
`ArgumentError`](#unsupported-options-raise-argumenterror)).
|
|
1130
|
+
|
|
1131
|
+
There is no replacement option. `:remote` renamed the clone's remote, and
|
|
1132
|
+
`Git.export` deletes the `.git` directory before returning, so the name was never
|
|
1133
|
+
observable in the result. Delete the option from the call.
|
|
1134
|
+
|
|
1135
|
+
| Deprecated call (works in v5.x, removed in a future major release) | Replacement |
|
|
1136
|
+
|--------------------------------------------------------------------|-------------|
|
|
1137
|
+
| `Git.export(url, dir, remote: name)` | `Git.export(url, dir)` |
|
|
1138
|
+
|
|
1139
|
+
#### Context helper blocks that declare no parameter deprecated
|
|
1140
|
+
|
|
1141
|
+
`Git::Repository#with_index`, `#with_temp_index`, `#with_working`, and
|
|
1142
|
+
`#with_temp_working` yield `self` in v5.x, so a block could ignore the yielded
|
|
1143
|
+
value and call methods on the receiver. Calling one of these helpers with a block
|
|
1144
|
+
that declares no positional parameter (`do ... end`, `{ }`, `{ || }`, or a block
|
|
1145
|
+
with only keyword or block parameters) now emits a deprecation warning. The
|
|
1146
|
+
behavior is otherwise unchanged: the helpers still yield `self`, and a call with
|
|
1147
|
+
no block still raises `LocalJumpError`.
|
|
1148
|
+
|
|
1149
|
+
In v6.0.0 these helpers yield a separate repository bound to the other index or
|
|
1150
|
+
working tree instead of rebinding the receiver, and they raise `ArgumentError` for
|
|
1151
|
+
a block that declares no positional parameter. A call with no block also raises
|
|
1152
|
+
`ArgumentError` in v6.0.0 instead of `LocalJumpError`. Declare a block parameter
|
|
1153
|
+
and call methods on it. The parameter is required even when the block never uses
|
|
1154
|
+
the repository, for example a `with_temp_working` block that only writes files
|
|
1155
|
+
(`do |_scratch|`). Blocks that already declare a positional parameter (`|repo|`,
|
|
1156
|
+
`|_|`, `|repo = nil|`, `|*args|`, or a symbol-to-proc such as `&:write_tree`) do
|
|
1157
|
+
not warn. Both versions read the block's parameter list rather than its arity, so
|
|
1158
|
+
the v5.x warning and the v6.0.0 error agree on every block form.
|
|
1159
|
+
|
|
1160
|
+
The warning detects only the block's parameter list. Adding an unused parameter
|
|
1161
|
+
(`|_|`) silences it but does not fix a block that still calls methods on the outer
|
|
1162
|
+
repository; that block does not warn and acts on the wrong repository in v6.0.0,
|
|
1163
|
+
so review those blocks by hand.
|
|
1164
|
+
|
|
1165
|
+
| Deprecated call (works in v5.x, raises in v6.0.0) | Replacement |
|
|
1166
|
+
|---------------------------------------------------|-------------|
|
|
1167
|
+
| `g.with_index(path) { g.read_tree('HEAD') }` | `g.with_index(path) { \|r\| r.read_tree('HEAD') }` |
|
|
1168
|
+
| `g.with_temp_index { g.read_tree('HEAD') }` | `g.with_temp_index { \|r\| r.read_tree('HEAD') }` |
|
|
1169
|
+
| `g.with_working(dir) { g.add('.') }` | `g.with_working(dir) { \|r\| r.add('.') }` |
|
|
1170
|
+
| `g.with_temp_working { g.add('.') }` | `g.with_temp_working { \|r\| r.add('.') }` |
|
|
1171
|
+
|
|
1172
|
+
`chdir` is not part of this deprecation. It yields the directory path in both
|
|
1173
|
+
versions.
|
|
1174
|
+
|
|
1120
1175
|
---
|
|
@@ -18,6 +18,10 @@ module Git
|
|
|
18
18
|
# @api private
|
|
19
19
|
#
|
|
20
20
|
module ContextHelpers
|
|
21
|
+
# Parameter types from `Proc#parameters` that receive a positional argument
|
|
22
|
+
CONTEXT_HELPERS_POSITIONAL_PARAMETERS = %i[req opt rest].freeze
|
|
23
|
+
private_constant :CONTEXT_HELPERS_POSITIONAL_PARAMETERS
|
|
24
|
+
|
|
21
25
|
# Changes the current working directory to the repository working directory
|
|
22
26
|
# for the duration of the block
|
|
23
27
|
#
|
|
@@ -51,9 +55,13 @@ module Git
|
|
|
51
55
|
# yields `self`, then unconditionally restores the original execution
|
|
52
56
|
# context — even if the block raises an exception.
|
|
53
57
|
#
|
|
58
|
+
# Deprecated form: a block that declares no positional parameter emits a
|
|
59
|
+
# deprecation warning, because v6.0.0 yields a separate repository
|
|
60
|
+
# instead of `self`.
|
|
61
|
+
#
|
|
54
62
|
# @example Read a tree into a custom index
|
|
55
|
-
# repo.with_index('/tmp/custom.index') do
|
|
56
|
-
#
|
|
63
|
+
# repo.with_index('/tmp/custom.index') do |r|
|
|
64
|
+
# r.read_tree('HEAD')
|
|
57
65
|
# end
|
|
58
66
|
#
|
|
59
67
|
# @param new_index [String, Pathname] path to the replacement index file
|
|
@@ -66,7 +74,8 @@ module Git
|
|
|
66
74
|
#
|
|
67
75
|
# @yieldreturn [Object] returned as the method's return value
|
|
68
76
|
#
|
|
69
|
-
def with_index(new_index) # :yields: self
|
|
77
|
+
def with_index(new_index, &block) # :yields: self
|
|
78
|
+
context_helpers_warn_if_block_declares_no_parameter(:with_index, block)
|
|
70
79
|
old_context = @execution_context
|
|
71
80
|
set_index(new_index, must_exist: false)
|
|
72
81
|
yield self
|
|
@@ -84,10 +93,14 @@ module Git
|
|
|
84
93
|
# are removed unconditionally after the block exits, even if the block
|
|
85
94
|
# raises an exception.
|
|
86
95
|
#
|
|
96
|
+
# Deprecated form: a block that declares no positional parameter emits a
|
|
97
|
+
# deprecation warning, because v6.0.0 yields a separate repository
|
|
98
|
+
# instead of `self`.
|
|
99
|
+
#
|
|
87
100
|
# @example Stage changes using a temporary index
|
|
88
|
-
# repo.with_temp_index do
|
|
89
|
-
#
|
|
90
|
-
#
|
|
101
|
+
# repo.with_temp_index do |r|
|
|
102
|
+
# r.read_tree('HEAD')
|
|
103
|
+
# r.write_tree
|
|
91
104
|
# end
|
|
92
105
|
#
|
|
93
106
|
# @return [Object] the value returned by the block
|
|
@@ -98,13 +111,17 @@ module Git
|
|
|
98
111
|
#
|
|
99
112
|
# @yieldreturn [Object] returned as the method's return value
|
|
100
113
|
#
|
|
101
|
-
def with_temp_index(&) # :yields: self
|
|
114
|
+
def with_temp_index(&block) # :yields: self
|
|
115
|
+
context_helpers_warn_if_block_declares_no_parameter(:with_temp_index, block)
|
|
102
116
|
# Use a unique temp directory so the index file path is collision-free
|
|
103
117
|
# and does not exist until git writes it. An existing empty file would
|
|
104
118
|
# be treated as a corrupt index by git.
|
|
105
119
|
temp_dir = Dir.mktmpdir('git-temp-index-')
|
|
106
120
|
begin
|
|
107
|
-
with_index
|
|
121
|
+
# The inner block declares a parameter so with_index does not warn a
|
|
122
|
+
# second time under its own name; forwarding &block would.
|
|
123
|
+
# rubocop:disable-next Style/ExplicitBlockArgument
|
|
124
|
+
with_index(File.join(temp_dir, 'index')) { |repo| yield repo }
|
|
108
125
|
ensure
|
|
109
126
|
FileUtils.remove_entry(temp_dir, true)
|
|
110
127
|
end
|
|
@@ -118,10 +135,14 @@ module Git
|
|
|
118
135
|
# `self`, then unconditionally restores the original execution context —
|
|
119
136
|
# even if the block raises an exception.
|
|
120
137
|
#
|
|
138
|
+
# Deprecated form: a block that declares no positional parameter emits a
|
|
139
|
+
# deprecation warning, because v6.0.0 yields a separate repository
|
|
140
|
+
# instead of `self`.
|
|
141
|
+
#
|
|
121
142
|
# @example Commit changes from a different worktree path
|
|
122
|
-
# repo.with_working('/path/to/worktree') do
|
|
123
|
-
#
|
|
124
|
-
#
|
|
143
|
+
# repo.with_working('/path/to/worktree') do |r|
|
|
144
|
+
# r.add('.')
|
|
145
|
+
# r.commit('chore: automated update')
|
|
125
146
|
# end
|
|
126
147
|
#
|
|
127
148
|
# @param work_dir [String, Pathname] path to the replacement working
|
|
@@ -138,7 +159,8 @@ module Git
|
|
|
138
159
|
#
|
|
139
160
|
# @yieldreturn [Object] returned as the method's return value
|
|
140
161
|
#
|
|
141
|
-
def with_working(work_dir) # :yields: self
|
|
162
|
+
def with_working(work_dir, &block) # :yields: self
|
|
163
|
+
context_helpers_warn_if_block_declares_no_parameter(:with_working, block)
|
|
142
164
|
old_context = @execution_context
|
|
143
165
|
set_working(work_dir)
|
|
144
166
|
Dir.chdir(dir.to_s) { yield self }
|
|
@@ -153,9 +175,14 @@ module Git
|
|
|
153
175
|
# The temporary directory is removed unconditionally after the block
|
|
154
176
|
# exits, even if the block raises an exception.
|
|
155
177
|
#
|
|
178
|
+
# Deprecated form: a block that declares no positional parameter emits a
|
|
179
|
+
# deprecation warning, because v6.0.0 yields a separate repository
|
|
180
|
+
# instead of `self`.
|
|
181
|
+
#
|
|
156
182
|
# @example Write files in an isolated temporary working directory
|
|
157
|
-
# repo.with_temp_working do
|
|
183
|
+
# repo.with_temp_working do |r|
|
|
158
184
|
# File.write('scratch.txt', 'temporary content')
|
|
185
|
+
# r.add('scratch.txt')
|
|
159
186
|
# end
|
|
160
187
|
#
|
|
161
188
|
# @return [Object] the value returned by the block
|
|
@@ -168,7 +195,11 @@ module Git
|
|
|
168
195
|
# @yieldreturn [Object] returned as the method's return value
|
|
169
196
|
#
|
|
170
197
|
def with_temp_working(&block) # :yields: self
|
|
171
|
-
|
|
198
|
+
context_helpers_warn_if_block_declares_no_parameter(:with_temp_working, block)
|
|
199
|
+
# The inner block declares a parameter so with_working does not warn a
|
|
200
|
+
# second time under its own name; forwarding &block would.
|
|
201
|
+
# rubocop:disable-next Style/ExplicitBlockArgument
|
|
202
|
+
Dir.mktmpdir('temp-workdir') { |temp_dir| with_working(temp_dir) { |repo| yield repo } }
|
|
172
203
|
end
|
|
173
204
|
|
|
174
205
|
# Sets the git index to `index_file` and rebuilds the execution context
|
|
@@ -231,6 +262,42 @@ module Git
|
|
|
231
262
|
|
|
232
263
|
private
|
|
233
264
|
|
|
265
|
+
# Emits a deprecation warning when `block` declares no positional parameter
|
|
266
|
+
#
|
|
267
|
+
# In v6.0.0 the `with_*` helpers yield a separate repository instead of
|
|
268
|
+
# rebinding the receiver, so a block that calls methods on the receiver
|
|
269
|
+
# (the v5.x form) acts on the wrong repository there. v6.0.0 raises
|
|
270
|
+
# `ArgumentError` for that form using this same rule: the block must
|
|
271
|
+
# declare a required, optional, or splat positional parameter. The rule
|
|
272
|
+
# reads `Proc#parameters` rather than arity because an optional parameter
|
|
273
|
+
# gives a proc an arity of zero although it receives the repository,
|
|
274
|
+
# while keyword and block parameters cannot receive it.
|
|
275
|
+
#
|
|
276
|
+
# A missing block is not checked here; the helper's `yield` raises
|
|
277
|
+
# `LocalJumpError` as before.
|
|
278
|
+
#
|
|
279
|
+
# The warning reports the helper's caller, not this helper's caller, so
|
|
280
|
+
# the location points at the block that needs changing.
|
|
281
|
+
#
|
|
282
|
+
# @param helper [Symbol] the public helper name used in the warning
|
|
283
|
+
#
|
|
284
|
+
# @param block [Proc, nil] the block passed to the helper
|
|
285
|
+
#
|
|
286
|
+
# @return [void]
|
|
287
|
+
#
|
|
288
|
+
def context_helpers_warn_if_block_declares_no_parameter(helper, block)
|
|
289
|
+
return if block.nil?
|
|
290
|
+
return if block.parameters.any? { |type, _name| CONTEXT_HELPERS_POSITIONAL_PARAMETERS.include?(type) }
|
|
291
|
+
|
|
292
|
+
Git::Deprecation.warn(
|
|
293
|
+
"Calling Git::Repository##{helper} with a block that declares no positional " \
|
|
294
|
+
'parameter is deprecated and will be removed in v6.0.0, where the helper ' \
|
|
295
|
+
'yields a separate repository instead of self. Declare a block parameter and ' \
|
|
296
|
+
"call methods on it instead: #{helper} { |repo| repo.some_method }",
|
|
297
|
+
caller_locations(2)
|
|
298
|
+
)
|
|
299
|
+
end
|
|
300
|
+
|
|
234
301
|
# Resolves deprecated `check` argument semantics with `must_exist:`
|
|
235
302
|
#
|
|
236
303
|
# @param check [Boolean, nil] deprecated positional existence-check value
|
data/lib/git/version.rb
CHANGED
data/lib/git.rb
CHANGED
|
@@ -327,25 +327,45 @@ module Git
|
|
|
327
327
|
# Exports the current HEAD (or the specific branch given in <tt>options[:branch]</tt>)
|
|
328
328
|
# into the given `directory`. It then removes all traces of git from the directory.
|
|
329
329
|
#
|
|
330
|
-
#
|
|
331
|
-
#
|
|
330
|
+
# Removing `.git` is not atomic. If it fails, the exported files are complete and
|
|
331
|
+
# usable, but the directory keeps whatever part of `.git` could not be deleted.
|
|
332
|
+
# Nothing is cleaned up, because the exported files are the deliverable and the
|
|
333
|
+
# leftover has to be removed by hand once the cause of the failure is fixed.
|
|
334
|
+
#
|
|
335
|
+
# Takes the same options as {Git.clone} except that `:depth` defaults to 1 and
|
|
336
|
+
# `:remote` is ignored with a deprecation warning.
|
|
332
337
|
#
|
|
333
338
|
# @param repository_url [String, URI, Pathname] the repository to export from
|
|
334
339
|
#
|
|
335
340
|
# @param directory [String, Pathname, nil] the directory to export into; defaults to the
|
|
336
341
|
# repository basename
|
|
337
342
|
#
|
|
338
|
-
# @param options [Hash] options forwarded to {Git.clone} (`:
|
|
339
|
-
#
|
|
343
|
+
# @param options [Hash] options forwarded to {Git.clone} (`:depth` defaults to 1)
|
|
344
|
+
#
|
|
345
|
+
# @option options [String] :remote deprecated and ignored; delete it from the call.
|
|
346
|
+
# Passing it emits a deprecation warning and it will be removed in a future
|
|
347
|
+
# major release.
|
|
340
348
|
#
|
|
341
|
-
# @option options [String] :branch the branch or tag to export instead of HEAD
|
|
349
|
+
# @option options [String] :branch the branch or tag to export instead of HEAD.
|
|
350
|
+
# Give the short name (`main`, `v1.0.0`); a full ref path such as
|
|
351
|
+
# `refs/tags/v1.0.0` or a commit SHA is not accepted. Use `:revision` to
|
|
352
|
+
# export a SHA.
|
|
342
353
|
#
|
|
343
354
|
# @return [void]
|
|
344
355
|
#
|
|
356
|
+
# @raise [SystemCallError] if the `.git` directory cannot be removed. The exported
|
|
357
|
+
# files are left in place, and the directory keeps whatever part of `.git` could
|
|
358
|
+
# not be deleted.
|
|
359
|
+
#
|
|
345
360
|
def self.export(repository_url, directory = nil, options = {})
|
|
346
|
-
options.
|
|
361
|
+
if options.key?(:remote)
|
|
362
|
+
Git::Deprecation.warn(
|
|
363
|
+
'The :remote option to Git.export is ignored, is deprecated, and will be removed in a future ' \
|
|
364
|
+
'major release. Delete it from the call.'
|
|
365
|
+
)
|
|
366
|
+
options.delete(:remote)
|
|
367
|
+
end
|
|
347
368
|
repo = clone(repository_url, directory, { depth: 1 }.merge(options))
|
|
348
|
-
repo.checkout("origin/#{options[:branch]}") if options[:branch]
|
|
349
369
|
FileUtils.rm_r File.join(repo.dir.to_s, '.git')
|
|
350
370
|
end
|
|
351
371
|
|
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.
|
|
4
|
+
version: 5.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Scott Chacon and others
|
|
@@ -548,8 +548,8 @@ licenses:
|
|
|
548
548
|
metadata:
|
|
549
549
|
homepage_uri: http://github.com/ruby-git/ruby-git
|
|
550
550
|
source_code_uri: http://github.com/ruby-git/ruby-git
|
|
551
|
-
changelog_uri: https://rubydoc.info/gems/git/5.
|
|
552
|
-
documentation_uri: https://rubydoc.info/gems/git/5.
|
|
551
|
+
changelog_uri: https://rubydoc.info/gems/git/5.6.0/file/CHANGELOG.md
|
|
552
|
+
documentation_uri: https://rubydoc.info/gems/git/5.6.0
|
|
553
553
|
rubygems_mfa_required: 'true'
|
|
554
554
|
rdoc_options: []
|
|
555
555
|
require_paths:
|