git 5.1.0 → 5.2.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.
Files changed (101) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +45 -0
  3. data/CONTRIBUTING.md +185 -165
  4. data/LICENSE +1 -1
  5. data/README.md +151 -151
  6. data/git.gemspec +35 -3
  7. data/lib/git/command_line/base.rb +1 -2
  8. data/lib/git/commands/base.rb +1 -1
  9. data/lib/git/commands/cat_file/raw.rb +8 -7
  10. data/lib/git/repository/branching.rb +79 -5
  11. data/lib/git/version.rb +1 -1
  12. metadata +5 -94
  13. data/.claude/commands/address-copilot-reviews.md +0 -14
  14. data/.claude/settings.json +0 -16
  15. data/.claude/skills +0 -1
  16. data/.commitlintrc.yml +0 -38
  17. data/.dockerignore +0 -27
  18. data/.github/copilot-instructions.md +0 -30
  19. data/.github/hooks/bin-setup-on-worktree.json +0 -11
  20. data/.github/hooks/run-bin-setup-once.sh +0 -20
  21. data/.github/issue_template.md +0 -15
  22. data/.github/prompts/iteratively-address-copilot-reviews.prompt.md +0 -188
  23. data/.github/pull_request_template.md +0 -21
  24. data/.github/skills/breaking-change-analysis/SKILL.md +0 -99
  25. data/.github/skills/ci-cd-troubleshooting/SKILL.md +0 -264
  26. data/.github/skills/command-implementation/REFERENCE.md +0 -994
  27. data/.github/skills/command-implementation/SKILL.md +0 -230
  28. data/.github/skills/command-test-conventions/SKILL.md +0 -664
  29. data/.github/skills/command-yard-documentation/SKILL.md +0 -434
  30. data/.github/skills/dependency-management/SKILL.md +0 -72
  31. data/.github/skills/development-workflow/SKILL.md +0 -512
  32. data/.github/skills/facade-implementation/REFERENCE.md +0 -837
  33. data/.github/skills/facade-implementation/SKILL.md +0 -269
  34. data/.github/skills/facade-test-conventions/SKILL.md +0 -391
  35. data/.github/skills/facade-yard-documentation/SKILL.md +0 -435
  36. data/.github/skills/make-skill-template/SKILL.md +0 -226
  37. data/.github/skills/pr-readiness-review/SKILL.md +0 -205
  38. data/.github/skills/project-context/SKILL.md +0 -306
  39. data/.github/skills/pull-request-review/SKILL.md +0 -168
  40. data/.github/skills/rebase/SKILL.md +0 -148
  41. data/.github/skills/refactor-command-to-commandlineresult/SKILL.md +0 -131
  42. data/.github/skills/release-management/SKILL.md +0 -125
  43. data/.github/skills/resolve-feedback/SKILL.md +0 -288
  44. data/.github/skills/review-arguments-dsl/CHECKLIST.md +0 -788
  45. data/.github/skills/review-arguments-dsl/SKILL.md +0 -214
  46. data/.github/skills/review-cross-command-consistency/SKILL.md +0 -139
  47. data/.github/skills/reviewing-skills/SKILL.md +0 -214
  48. data/.github/skills/rspec-unit-testing-standards/SKILL.md +0 -685
  49. data/.github/skills/tdd-refactor-step/SKILL.md +0 -236
  50. data/.github/skills/test-debugging/SKILL.md +0 -161
  51. data/.github/skills/yard-documentation/SKILL.md +0 -981
  52. data/.github/skills/yard-documentation/element-rules.md +0 -162
  53. data/.github/skills-deprecated/README.md +0 -21
  54. data/.github/skills-deprecated/extract-command-from-lib/SKILL.md +0 -487
  55. data/.github/skills-deprecated/extract-facade-from-base-lib/KEYWORD_ARG_REMEDIATION.md +0 -22
  56. data/.github/skills-deprecated/extract-facade-from-base-lib/SKILL.md +0 -600
  57. data/.github/skills-deprecated/review-backward-compatibility/SKILL.md +0 -275
  58. data/.github/workflows/continuous_integration.yml +0 -358
  59. data/.github/workflows/enforce_conventional_commits.yml +0 -35
  60. data/.github/workflows/experimental_continuous_integration.yml +0 -59
  61. data/.github/workflows/release.yml +0 -52
  62. data/.github/workflows/warm_bundler_caches.yml +0 -82
  63. data/.gitignore +0 -30
  64. data/.husky/commit-msg +0 -1
  65. data/.husky/pre-commit +0 -13
  66. data/.release-please-config.json +0 -36
  67. data/.release-please-manifest.json +0 -3
  68. data/.rspec +0 -2
  69. data/.rubocop.yml +0 -44
  70. data/.rubocop_todo.yml +0 -30
  71. data/.yard-lint.yml +0 -75
  72. data/CLAUDE.md +0 -11
  73. data/Gemfile +0 -22
  74. data/Rakefile +0 -41
  75. data/docker/test/Dockerfile +0 -32
  76. data/docker/test/docker-compose.yml +0 -0
  77. data/package.json +0 -10
  78. data/redesign/1_architecture_existing.md +0 -102
  79. data/redesign/2_architecture_redesign.md +0 -449
  80. data/redesign/3_architecture_implementation.md +0 -1623
  81. data/redesign/Phase 4 - Step A.md +0 -366
  82. data/redesign/Phase 4 - Step B.md +0 -921
  83. data/redesign/Phase 4 - Step C.md +0 -833
  84. data/redesign/beta_release.md +0 -107
  85. data/redesign/branch_parse_refactor_plan.md +0 -163
  86. data/redesign/c1a-public-api-scope.tsv +0 -256
  87. data/redesign/c1c2_audit.md +0 -566
  88. data/redesign/c1c2_bucket6_lib_orphans.md +0 -626
  89. data/redesign/config_design.rb +0 -501
  90. data/redesign/index.md +0 -34
  91. data/redesign/info_object_migration_plan.md +0 -126
  92. data/redesign/integration_test_analysis.md +0 -521
  93. data/redesign/phase-4-step-b-test-audit.tsv +0 -485
  94. data/redesign/remote_refactor_plan.md +0 -164
  95. data/redesign/reverse_dependencies.sql +0 -44
  96. data/tasks/gem_tasks.rake +0 -14
  97. data/tasks/npm_tasks.rake +0 -7
  98. data/tasks/rspec.rake +0 -111
  99. data/tasks/rubocop.rake +0 -5
  100. data/tasks/test_gem.rake +0 -12
  101. data/tasks/yard.rake +0 -57
@@ -1,449 +0,0 @@
1
- # Proposed Redesigned Architecture for the Git Gem
2
-
3
- This document outlines a proposal for a major redesign of the git gem, targeted for
4
- version 5.0.0. The goal of this redesign is to modernize the gem's architecture,
5
- making it more robust, maintainable, testable, and easier for new contributors to
6
- understand.
7
-
8
- - [1. Motivation](#1-motivation)
9
- - [2. The New Architecture: A Three-Layered Approach](#2-the-new-architecture-a-three-layered-approach)
10
- - [3. Key Design Principles](#3-key-design-principles)
11
- - [A. Clear Public vs. Private API](#a-clear-public-vs-private-api)
12
- - [B. Dependency Injection](#b-dependency-injection)
13
- - [C. Immutable Return Values](#c-immutable-return-values)
14
- - [D. Eliminate Custom Path Classes](#d-eliminate-custom-path-classes)
15
- - [4. Testing Strategy Overhaul](#4-testing-strategy-overhaul)
16
- - [5. Impact on Users: Breaking Changes for v5.0.0](#5-impact-on-users-breaking-changes-for-v500)
17
-
18
- ## 1. Motivation
19
-
20
- The current architecture, while functional, has several design issues that have
21
- accrued over time, making it difficult to extend and maintain.
22
-
23
- - **Unclear Separation of Concerns**: The responsibilities of the `Git`, `Git::Base`,
24
- and `Git::Lib` classes are "muddy." `Git::Base` acts as both a high-level API and a
25
- factory, while `Git::Lib` contains a mix of low-level command execution and
26
- high-level output parsing.
27
-
28
- - **Circular Dependency**: A key architectural flaw is the circular dependency
29
- between `Git::Base` and `Git::Lib`. `Git::Base` creates and depends on `Git::Lib`,
30
- but `Git::Lib`'s constructor requires an instance of Git::Base to access
31
- configuration. This tight coupling makes the classes difficult to reason about and
32
- test in isolation.
33
-
34
- - **Undefined Public API**: The boundary between the gem's public API and its
35
- internal implementation is not clearly defined. This has led some users to rely on
36
- internal classes like `Git::Lib`, making it difficult to refactor the internals
37
- without introducing breaking changes.
38
-
39
- - **Slow and Brittle Test Suite**: The current tests rely heavily on filesystem
40
- fixtures and shelling out to the git command line for almost every test case. This
41
- makes the test suite slow and difficult to maintain, especially on non-UNIX
42
- platforms.
43
-
44
- ## 2. The New Architecture: A Three-Layered Approach
45
-
46
- The new design is built on a clear separation of concerns, dividing responsibilities
47
- into three distinct layers: a Facade, an Execution Context, and Command Objects.
48
-
49
- 1. The Facade Layer: Git::Repository
50
-
51
- This is the primary public interface that users will interact with.
52
-
53
- **Renaming**: `Git::Base` will be renamed to `Git::Repository`. This name is more
54
- descriptive and intuitive.
55
-
56
- **Responsibility**: The facade layer is responsible for:
57
-
58
- 1. **Managing the Execution Context**: Holding and providing access to the
59
- configured execution context for command execution.
60
-
61
- 2. **Pre-processing Arguments**: Transforming user-provided arguments to fit the
62
- command API (e.g., path expansion, Ruby-idiomatic defaults).
63
-
64
- 3. **Collecting Data**: Gathering additional information before or after command
65
- execution that may be needed for building response objects.
66
-
67
- 4. **Calling Commands**: Invoking one or more `Git::Commands::*` classes as
68
- needed to fulfill the user's request.
69
-
70
- 5. **Building Rich Response Objects**: Using Parser classes (e.g., `Git::Parsers::Diff`)
71
- and Result class factory methods (e.g., `BranchDeleteResult.from(...)`) to
72
- assemble meaningful return values from raw command output.
73
-
74
- **Facade as Orchestration Layer**: The facade layer acts as glue and orchestration
75
- code. It coordinates the flow between components but contains minimal domain logic
76
- itself. The actual implementation work is delegated to specialized components:
77
-
78
- - **Commands** → handle argument building and execution, return `CommandLineResult`
79
- - **Parsers** → transform stdout/stderr into structured data
80
- - **Result classes** → assemble final objects via factory methods
81
-
82
- This separation means the facade's role is to *wire things together* (which
83
- component to call, in what order, with what inputs) rather than *implement
84
- behavior* (how to parse output, which arguments are valid). This keeps each
85
- component focused, independently testable, and reusable.
86
-
87
- **Scalability**: To prevent this class from growing too large, its methods will
88
- be organized into logical modules (e.g., `Git::Repository::Branching`,
89
- `Git::Repository::History`) which are then included in the main class. This keeps
90
- the core class definition small and the features well-organized. These categories
91
- will be inspired by (but not slavishly follow) the git command line reference in
92
- [this page](https://git-scm.com/docs).
93
-
94
- 2. The Execution Layer: Git::ExecutionContext
95
-
96
- This is the low-level, private engine for running commands.
97
-
98
- **Renaming**: `Git::Lib` will be renamed to `Git::ExecutionContext`.
99
-
100
- **Responsibility**: Its purpose is to provide a configured `command` method for
101
- executing git commands. This method wraps `Git::CommandLine` with essential
102
- functionality including default options (normalize, chomp, timeout), option
103
- validation, and a simplified interface that returns stdout. The execution context
104
- has no knowledge of any specific git command's arguments or output.
105
-
106
- **Two Context Types**: The execution layer will consist of an abstract base class
107
- with two concrete implementations:
108
-
109
- - **Git::ExecutionContext::Global**: For commands that do not require an existing repository
110
- (`init`, `clone`, `config --global`, `version`). These commands execute in a
111
- clean environment with no repository paths set. In the specific case of
112
- `init`/`clone`, the command itself runs in `ExecutionContext::Global`, but on success it
113
- yields a newly created `Git::Repository` instance backed by a
114
- `Git::ExecutionContext::Repository`.
115
-
116
- - **Git::ExecutionContext::Repository**: For repository-bound commands (`add`, `commit`,
117
- `status`, `log`, etc.). Manages the repository environment (working directory,
118
- .git path, index file) and provides the ability to override environment
119
- variables per-command (e.g., unsetting `GIT_INDEX_FILE` for worktree
120
- mutations).
121
-
122
- The base `ExecutionContext` class provides the common `command` method that wraps
123
- command execution with defaults, validation, and timeout handling. Subclasses
124
- implement environment-specific configuration (paths, environment variables) to
125
- create properly configured command execution contexts.
126
-
127
- 3. The Command Layer: Git::Commands
128
-
129
- This layer provides a structured interface to individual git commands.
130
-
131
- **New Classes**: For each git operation, a new command class will be created
132
- within the `Git::Commands` namespace (e.g., `Git::Commands::Commit`,
133
- `Git::Commands::Diff`).
134
-
135
- **Command Responsibilities**: Each command class is responsible for:
136
-
137
- 1. **Defining the Git CLI API**: Using `Arguments.define` to declaratively
138
- specify the command's accepted arguments. Command parameters should generally
139
- match the underlying git command's interface to keep this layer thin and
140
- transparent.
141
-
142
- 2. **Binding Arguments**: Exposing bound arguments publicly via the `#bind`
143
- method, allowing the facade layer to access argument values when needed for
144
- orchestration or result building.
145
-
146
- 3. **Executing the Command**: Running the git command via the execution context
147
- with any special setup/tweaking for expected results (e.g.,
148
- `raise_on_failure: false` for partial failures), returning a
149
- `Git::CommandLineResult`.
150
-
151
- **Note**: Parsing output and building rich response objects is **not** a command
152
- responsibility. That work belongs in separate Parser classes (e.g., `Git::Parsers::Diff`)
153
- and Result class factory methods, orchestrated by the Facade layer. See
154
- [issue #997](https://github.com/ruby-git/ruby-git/issues/997) for the work to
155
- migrate existing commands that currently parse output.
156
-
157
- **Commands::Base Pattern**: All command classes inherit from `Git::Commands::Base`.
158
- Implemented in [issue #996](https://github.com/ruby-git/ruby-git/issues/996).
159
-
160
- Simple commands declare `arguments do … end` and provide a YARD shim:
161
-
162
- ```ruby
163
- class Add < Base
164
- arguments do
165
- literal 'add'
166
- flag_option :all
167
- flag_option :force
168
- operand :paths, repeatable: true, default: [], separator: '--'
169
- end
170
-
171
- # Execute the git add command
172
- # ...YARD docs...
173
- def call(...) = super # rubocop:disable Lint/UselessMethodDefinition
174
- end
175
- ```
176
-
177
- Commands with non-zero successful exits declare their accepted range:
178
-
179
- ```ruby
180
- class Diff::Patch < Base
181
- arguments do
182
- literal 'diff'
183
- literal '--patch'
184
- # ...
185
- end
186
-
187
- # git diff exits 1 when differences are found (not an error)
188
- allow_exit_status 0..1
189
-
190
- def call(...) = super # rubocop:disable Lint/UselessMethodDefinition
191
- end
192
- ```
193
-
194
- This pattern provides:
195
-
196
- - Declarative argument definition via the class-level `arguments` DSL
197
- - Behavioral inheritance from `Base` (`#initialize` and `#call`)
198
- - Unified exit-status handling via `allow_exit_status <Range>` (default `0..0`)
199
- - Per-command YARD documentation via `def call(...) = super` shim
200
- - Automatic execution option forwarding (e.g., `timeout:`) via `Bound#execution_options`
201
-
202
- **Method Return Values**:
203
-
204
- - `#call` → Returns `Git::CommandLineResult` (stdout, stderr, status)
205
- - `#args_definition` → Returns the frozen `Arguments` instance (class-level metadata)
206
-
207
- **No Bind/Call Split**: Arguments are bound as a local variable inside `Base#call`.
208
- Commands remain stateless beyond `@execution_context` — there is no separate `#bind`
209
- method. If facade-layer access to bound argument values is needed in the future,
210
- a `#bind` method can be added as a backward-compatible addition. See the design
211
- rationale in [issue #996](https://github.com/ruby-git/ruby-git/issues/996).
212
-
213
- **Migration Strategy: Git::Lib as Adapter Layer**
214
-
215
- During the migration to this architecture, `Git::Lib` methods serve as **adapters**
216
- between the legacy public interface and the new `Git::Commands::*` classes. This
217
- separation ensures backward compatibility while enabling incremental migration:
218
-
219
- - **Legacy Interface Acceptance**: `Git::Lib` methods continue to accept the
220
- historical interface—positional arguments, deprecated options, and quirky
221
- parameter names.
222
-
223
- - **Interface Translation**: The adapter converts legacy patterns to the clean
224
- `Git::Commands::*` API (e.g., positional `message` → `:message` keyword,
225
- `:no_gpg_sign => true` → `:gpg_sign => false`).
226
-
227
- - **Deprecation Handling**: Warnings about deprecated options are issued in the
228
- adapter layer before delegating, ensuring users are informed even if they make
229
- other errors.
230
-
231
- - **Clean Command Classes**: `Git::Commands::*` classes remain free of legacy
232
- baggage with a consistent, modern API.
233
-
234
- - **Result Building**: The adapter layer is responsible for transforming
235
- `CommandLineResult` into rich response objects using Parser classes and Result
236
- factories. Commands return raw results; adapters build domain objects.
237
-
238
- Once all commands are migrated and deprecation periods end, the adapter logic can
239
- be simplified or moved to the new facade layer (`Git::Repository`).
240
-
241
- **Arguments DSL**: To standardize argument building across commands, a declarative
242
- `Git::Commands::Arguments` DSL is provided. This allows each command to define its
243
- accepted arguments in a clear, self-documenting way:
244
-
245
- ```ruby
246
- ARGS = Git::Commands::Arguments.define do
247
- flag_option :force # --force when true
248
- flag_option :all # --all when true
249
- value_option :branch # --branch <value>
250
- value_option :config, repeatable: true # --config <v1> --config <v2>
251
- flag_option :single_branch, negatable: true # --single-branch / --no-single-branch
252
- custom_option(:depth) { |v| ['--depth', v.to_i] }
253
- operand :paths, repeatable: true, separator: '--'
254
- end
255
- ```
256
-
257
- The DSL supports several option types (`flag_option`, `value_option`, `flag_or_value_option`, `literal`,
258
- `custom_option`, `execution_option`) and positional arguments, each with various modifiers. See
259
- [Git::Commands::Arguments](../lib/git/commands/arguments.rb) for full documentation.
260
-
261
- **Interface Convention**: With the `Base` pattern, all commands use
262
- `def call(...) = super` as a YARD documentation shim. `Base#call` handles
263
- argument binding and execution automatically; defaults defined in the DSL
264
- (e.g., `operand :paths, default: []`) are applied during binding, so no manual
265
- default checking is needed:
266
-
267
- ```ruby
268
- # All commands: YARD shim delegates to Base#call
269
- def call(...) = super # rubocop:disable Lint/UselessMethodDefinition
270
- ```
271
-
272
- The facade layer (`Git::Base`, `Git::Lib`) handles translation from the public API
273
- (which may accept single values or arrays) using `*Array(paths)`.
274
-
275
- **Return Value Convention**: The `#call` method returns `Git::CommandLineResult`
276
- by default. This is the standard return type for commands, containing stdout,
277
- stderr, and status information.
278
-
279
- **Important**: Rich objects (`StashInfo`, `BranchInfo`, `BranchDeleteResult`,
280
- etc.) are built by the **Facade layer** (currently `Git::Lib`, eventually
281
- `Git::Repository`), not by commands. The facade layer uses:
282
-
283
- - **Parser classes** (e.g., `Git::Parsers::Diff`, `Git::Parsers::Stash`) to transform raw
284
- stdout/stderr into structured data
285
- - **Result class factory methods** (e.g., `BranchDeleteResult.from(...)`) to
286
- assemble final objects from parsed data
287
-
288
- This separation keeps commands focused on execution and the facade responsible
289
- for building meaningful return values:
290
-
291
- ```ruby
292
- # Command layer: returns CommandLineResult
293
- class Git::Commands::Stash::List < Base
294
- arguments do
295
- literal 'stash'
296
- literal 'list'
297
- # ...
298
- end
299
-
300
- def call(...) = super # rubocop:disable Lint/UselessMethodDefinition
301
- end
302
-
303
- # Facade layer: builds rich objects
304
- def stashes
305
- result = Git::Commands::Stash::List.new(self).call
306
- StashListParser.parse(result.stdout).map { |info| Stash.new(self, info) }
307
- end
308
- ```
309
-
310
- **Naming Convention for Return Types**: Use the `-Info` suffix for data objects
311
- representing git entities (e.g., `TagInfo`, `BranchInfo`, `StashInfo`), and use
312
- `Result` for operation outcomes (e.g., `FsckResult`, `TagDeleteResult`).
313
-
314
- **Handling Complexity**: For commands with multiple behaviors (like git diff), we
315
- can use specialized subclasses (e.g., Git::Commands::Diff::NameStatus,
316
- Git::Commands::Diff::Stats) to keep each class focused on a single
317
- responsibility.
318
-
319
- ## 3. Key Design Principles
320
-
321
- The new architecture will be guided by the following modern design principles.
322
-
323
- ### A. Clear Public vs. Private API
324
-
325
- A primary goal of this redesign is to establish a crisp boundary between the public
326
- API and internal implementation details.
327
-
328
- - **Public Interface**: The public API will consist of the `Git` module (for
329
- factories), the `Git::Repository` class, and the specialized data/query objects it
330
- returns (e.g., `Git::Log`, `Git::Status`, `Git::Object::Commit`).
331
-
332
- - **Private Implementation**: All other components, including `Git::ExecutionContext`
333
- and all classes within the `Git::Commands` namespace, will be considered internal.
334
- They will be explicitly marked with the `@api private` YARD tag to discourage
335
- external use.
336
-
337
- ### B. Dependency Injection
338
-
339
- The circular dependency will be resolved by implementing a clear, one-way dependency
340
- flow.
341
-
342
- 1. The factory methods (`Git.open`, `Git.clone`) will create and configure an
343
- instance of the appropriate `Git::ExecutionContext` subclass (`Git::ExecutionContext::Global`
344
- for `init`/`clone`, `Git::ExecutionContext::Repository` for `open`/`bare`).
345
-
346
- 2. This context instance will then be wired into the system in two ways:
347
- - For commands that run before a repository exists (e.g., `Git::Commands::Init`,
348
- `Git::Commands::Clone`), the context will be passed directly into the
349
- constructor of the command object.
350
- - For repository-scoped commands (e.g., `Git::Commands::Log`,
351
- `Git::Commands::Status`), the context will be injected once into the
352
- `Git::Repository` constructor (for `open`/`bare`), and those command objects
353
- will access the context through the repository instance rather than receiving it
354
- directly.
355
-
356
- This decouples the `Repository` from its execution environment, making the system
357
- more modular and easier to test.
358
-
359
- ### C. Immutable Return Values
360
-
361
- To create a more predictable and robust API, methods will return structured,
362
- immutable data objects instead of raw strings or hashes.
363
-
364
- This will be implemented using `Data.define` or simple, frozen `Struct`s.
365
-
366
- For example, instead of returning a raw string, `repo.config('user.name')` will
367
- return a `Git::Config::Value` object containing the key, value, scope, and source
368
- path.
369
-
370
- **Value Objects vs Domain Objects**: A critical architectural distinction exists
371
- between:
372
-
373
- - **Value objects** (e.g., `Git::BranchInfo`): Pure data returned by commands. No
374
- repository context, no operations, no dependencies. Created by `Data.define`.
375
- These are the return types of `Git::Commands::*` classes.
376
-
377
- - **Domain objects** (e.g., `Git::Branch`): Rich objects with operations that require
378
- repository context (`@base`). These wrap value objects and provide methods like
379
- `checkout`, `merge`, `delete`.
380
-
381
- Commands return value objects. The facade layer (`Git::Repository`) or collection
382
- classes (`Git::Branches`) convert them to domain objects when needed. This separation
383
- keeps commands pure and testable while domain objects provide the rich API users
384
- expect.
385
-
386
- **Note on `Data.define` constraints**: Objects created with `Data.define` are frozen.
387
- This means memoization patterns like `@cached ||= ...` will raise `FrozenError`.
388
- Either accept repeated computation or use a different approach for caching.
389
-
390
- ### D. Eliminate Custom Path Classes
391
-
392
- The existing path wrapper classes (`Git::WorkingDirectory`, `Git::Index`,
393
- `Git::Repository`, and their base class `Git::Path`) provide minimal value over
394
- Ruby's standard library. These classes will be eliminated entirely.
395
-
396
- - `Git::Path` -> **Removed**
397
- - `Git::WorkingDirectory` -> **Removed**
398
- - `Git::Index` -> **Removed**
399
- - `Git::Repository` (the path class) -> **Removed**
400
-
401
- Instead, the `dir`, `repo`, and `index` accessors on the repository object will
402
- return `Pathname` objects directly. This provides:
403
-
404
- - Built-in `readable?` and `writable?` methods (preserving existing API)
405
- - Automatic path expansion and normalization
406
- - Seamless string coercion via `to_s` and `to_path`
407
- - No custom classes to maintain
408
-
409
- **Breaking change:** Code using `.path` (e.g., `g.dir.path`) must change to `.to_s`
410
- or use the `Pathname` directly. String interpolation and most other uses will
411
- continue to work unchanged.
412
-
413
- ## 4. Testing Strategy Overhaul
414
-
415
- The test suite will be modernized to be faster, more reliable, and easier to work
416
- with.
417
-
418
- - **Migration to RSpec**: The entire test suite will be migrated from TestUnit to
419
- RSpec to leverage its modern tooling and expressive DSL.
420
-
421
- - **Layered Testing**: A three-layered testing strategy will be adopted:
422
-
423
- 1. **Unit Tests**: The majority of tests will be fast, isolated unit tests for the
424
- `Command` classes, using mock `ExecutionContexts`.
425
-
426
- 2. **Integration Tests**: A small number of integration tests will verify that
427
- `ExecutionContext` correctly interacts with the system's `git` binary.
428
-
429
- 3. **Feature Tests**: A minimal set of high-level tests will ensure the public
430
- facade on `Git::Repository` works end-to-end.
431
-
432
- - **Reduced Filesystem Dependency**: This new structure will dramatically reduce the
433
- suite's reliance on slow and brittle filesystem fixtures.
434
-
435
- ## 5. Impact on Users: Breaking Changes for v5.0.0
436
-
437
- This redesign is a significant undertaking and will be released as version 5.0.0. It
438
- includes several breaking changes that users will need to be aware of when upgrading.
439
-
440
- - **`Git::Lib` is Removed**: Any code directly referencing `Git::Lib` will break.
441
-
442
- - **g.lib Accessor is Removed**: The `.lib` accessor on repository objects will be
443
- removed.
444
-
445
- - **Internal Methods Relocated**: Methods that were previously accessible via g.lib
446
- will now be private implementation details of the new command classes and will not
447
- be directly reachable.
448
-
449
- Users should only rely on the newly defined public interface.