Repository navigation
Commit 7fa5e73
* Start fix for #1476
Assisted-by: Claude Code:claude-opus-5-5
* Test gem unwind after x = if … end in source block
A gem declared in the user's own source "…" do block loses its
DEPENDENCIES `!` on hosted rollback/remove when an assignment-form
keyword construct (v = if/case/begin … end) precedes it, so frozen
installs fail on Bundler 4.0.19+ (#1476). Add unit cases for the
block scanner and the restore round trip, and an e2e Bundler case.
Assisted-by: Claude Code:claude-opus-5-5
* Keep gem source-block bang after x = if … end
The hosted gem unwind only counted if/case/begin/… as opening a block
when the keyword started its line. In `v = if …` nothing was opened,
but the matching `end` still closed the user's source block, so the
restored lock dropped its `!` pin and Bundler 4.0.19+ frozen installs
failed after rollback or remove. The restored declaration also came
back at column 0 after a blank line.
Count keywords word by word wherever they start an expression (after
=, (, ',', ;, …), treat `end` as closing one, net out one-line
constructs, skip modifiers, names like x.class or if:, and endless
defs. Derive the restored declaration's indent from the same block
stack.
Fixes #1476
Assisted-by: Claude Code:claude-opus-5-5
* Indent restored gem from its enclosing block
After an `end` indented deeper than the block's body (a case/when
laid out under its assignment), the restored declaration copied that
`end`'s indent, so the Gemfile did not come back byte for byte. Take
the indent of the line that opened the enclosing block + 2 instead.
Assisted-by: Claude Code:claude-opus-5-5
* Skip literals, comments, heredocs in gem scan
Review follow-ups for the source-block scanner (#1476):
- a keyword after a label (require: if), =>, a ternary, and/or/not or
an operator starts an expression, so its end is counted;
- %w[]/%i[] arrays, regexps, backticks, =begin/=end comments and
heredoc bodies are no longer read as code;
- a ; ends a loop's statement, so a later do opens its own block;
- def begin / x.then if treat the keyword-like word as a name;
- the restored declaration keeps a blank line before a following
declaration after an inner end, as before;
- the stack is computed once per restore, with opener line offsets.
Assisted-by: Claude Code:claude-opus-5-5
* Carry literals across lines in gem block scan
Second review pass on the source-block scanner (#1476):
- mask strings and %-literals that span lines, and find the comment
with the same literal rules (a ' in a regexp, # in %q());
- add %s() / %x() literals;
- class <<self and list <<name are not heredocs;
- a modifier on a backslash-continued line stays a modifier;
- endless defs with operator names or nested parens;
- a multi-line block opener indents from its first line.
Assisted-by: Claude Code:claude-opus-5-5
---------
Co-authored-by: Claude <noreply@anthropic.com>
1 parent e6ef4c1 commit 7fa5e73
2 files changed
Lines changed: 637 additions & 64 deletions
File tree
- crates
- socket-patch-cli/tests
- socket-patch-core/src/patch/redirect/upstream
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
436 | 436 | | |
437 | 437 | | |
438 | 438 | | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
439 | 443 | | |
440 | 444 | | |
441 | 445 | | |
| |||
518 | 522 | | |
519 | 523 | | |
520 | 524 | | |
| 525 | + | |
| 526 | + | |
| 527 | + | |
521 | 528 | | |
522 | 529 | | |
523 | 530 | | |
| |||
815 | 822 | | |
816 | 823 | | |
817 | 824 | | |
| 825 | + | |
| 826 | + | |
| 827 | + | |
| 828 | + | |
| 829 | + | |
| 830 | + | |
818 | 831 | | |
819 | 832 | | |
820 | 833 | | |
| |||
1063 | 1076 | | |
1064 | 1077 | | |
1065 | 1078 | | |
| 1079 | + | |
1066 | 1080 | | |
1067 | 1081 | | |
1068 | 1082 | | |
| |||
1267 | 1281 | | |
1268 | 1282 | | |
1269 | 1283 | | |
| 1284 | + | |
1270 | 1285 | | |
1271 | 1286 | | |
1272 | 1287 | | |
| |||
2334 | 2349 | | |
2335 | 2350 | | |
2336 | 2351 | | |
| 2352 | + | |
| 2353 | + | |
2337 | 2354 | | |
2338 | 2355 | | |
2339 | 2356 | | |
2340 | 2357 | | |
2341 | | - | |
| 2358 | + | |
| 2359 | + | |
| 2360 | + | |
| 2361 | + | |
| 2362 | + | |
| 2363 | + | |
| 2364 | + | |
| 2365 | + | |
| 2366 | + | |
| 2367 | + | |
2342 | 2368 | | |
2343 | | - | |
| 2369 | + | |
2344 | 2370 | | |
2345 | 2371 | | |
2346 | 2372 | | |
2347 | 2373 | | |
2348 | | - | |
| 2374 | + | |
2349 | 2375 | | |
2350 | 2376 | | |
2351 | 2377 | | |
| |||
2408 | 2434 | | |
2409 | 2435 | | |
2410 | 2436 | | |
2411 | | - | |
| 2437 | + | |
2412 | 2438 | | |
2413 | 2439 | | |
2414 | 2440 | | |
| |||
0 commit comments