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,1623 +0,0 @@
1
- # Implementation Plan for Git Gem Redesign (v5.0.0)
2
-
3
- This document outlines a step-by-step plan to implement the proposed architectural
4
- redesign. The plan is structured to be incremental, ensuring that the gem remains
5
- functional and passes its test suite after each major step. This approach minimizes
6
- risk and allows for a gradual, controlled migration to the new architecture.
7
-
8
- - [Progress Tracker](#progress-tracker)
9
- - [Facade Modules Completed](#facade-modules-completed)
10
- - [Facade module naming convention](#facade-module-naming-convention)
11
- - [Next Task](#next-task)
12
- - [Phase 4 complete — architectural redesign is done 🎉](#phase-4-complete--architectural-redesign-is-done-)
13
- - [Phase 3 Overview](#phase-3-overview)
14
- - [Workstream A — Fill facade coverage gaps](#workstream-a--fill-facade-coverage-gaps)
15
- - [Workstream B — C0: Redirect `Git::Base` factory methods to `facade_repository`](#workstream-b--c0-redirect-gitbase-factory-methods-to-facade_repository)
16
- - [Workstream C — C1: Prepare and flip top-level entry points to return `Git::Repository`](#workstream-c--c1-prepare-and-flip-top-level-entry-points-to-return-gitrepository)
17
- - [Workstream D — C3: Remove compatibility fallbacks](#workstream-d--c3-remove-compatibility-fallbacks)
18
- - [Workstream E — Migrate or deprecate instance helper methods](#workstream-e--migrate-or-deprecate-instance-helper-methods)
19
- - [Workstream F — `Git` module utility methods still using `Git::Lib` directly](#workstream-f--git-module-utility-methods-still-using-gitlib-directly)
20
- - [Phase 3 dependency order](#phase-3-dependency-order)
21
- - [Phase 3 steps and release compatibility](#phase-3-steps-and-release-compatibility)
22
- - [Phase 3 completion criteria](#phase-3-completion-criteria)
23
- - [Facade coverage checklist](#facade-coverage-checklist)
24
- - [Quality gates (per step)](#quality-gates-per-step)
25
- - [Reference Files](#reference-files)
26
- - [Phase 1: Foundation and Scaffolding](#phase-1-foundation-and-scaffolding)
27
- - [Phase 2: The Strangler Fig Pattern - Migrating Commands](#phase-2-the-strangler-fig-pattern---migrating-commands)
28
- - [Key Architectural Insight: Git::Lib as the Adapter Layer](#key-architectural-insight-gitlib-as-the-adapter-layer)
29
- - [Architectural Insights from Command Migrations](#architectural-insights-from-command-migrations)
30
- - [Command Migration Checklist](#command-migration-checklist)
31
- - [✅ Migrated Commands](#-migrated-commands)
32
- - [⏳ Commands To Migrate](#-commands-to-migrate)
33
- - [Phase 3: Refactoring the Public Interface](#phase-3-refactoring-the-public-interface)
34
- - [Phase 4: Final Cleanup and Release Preparation](#phase-4-final-cleanup-and-release-preparation)
35
- - [Phase 4 step graph](#phase-4-step-graph)
36
- - [Step A — Remove old code](#step-a--remove-old-code)
37
- - [Step B — Finalize test suite](#step-b--finalize-test-suite)
38
- - [Step C — Update documentation](#step-c--update-documentation)
39
-
40
- ## Progress Tracker
41
-
42
- | Phase | Status | Description | Estimated Effort | Percent Complete |
43
- | ----- | ------ | ----------- | :--------------: | :--------------: |
44
- | Phase 1 | ✅ Complete | Foundation and scaffolding | 5% | 100% |
45
- | Phase 2 | ✅ Complete | Migrating commands (all checklist items done) | 40% | 100% |
46
- | Phase 3 | ✅ Complete | Refactoring public interface — see [Facade Modules Completed](#facade-modules-completed) and [Facade coverage checklist](#facade-coverage-checklist) | 45% | 100% |
47
- | Phase 4 | ✅ Complete | Final cleanup and release — Steps A, B, and C all complete | 10% | 100% |
48
- | **TOTAL** | ✅ **Complete** | -- | **100%** | **100%** |
49
-
50
- ### Facade Modules Completed
51
-
52
- | Module | File | Included in `Git::Repository` | `Git::Base` delegates |
53
- | ------ | ---- | ------------------------------ | --------------------- |
54
- | `Git::Repository::Staging` | `lib/git/repository/staging.rb` | ✅ | `add`, `reset`, `reset_hard`, `apply`, `apply_mail`, `read_tree`, `rm`, `mv`, `clean`, `ignored_files` |
55
- | `Git::Repository::Committing` | `lib/git/repository/committing.rb` | ✅ | `commit`, `commit_all`, `write_tree`; `commit_tree` and `write_and_commit_tree` wrap the SHA result in `Git::Object::Commit.new(self, ...)` |
56
- | `Git::Repository::Branching` | `lib/git/repository/branching.rb` | ✅ | `checkout`, `checkout_file`, `checkout_index`, `current_branch`, `current_branch_state`, `local_branch?`, `remote_branch?`, `branch?`, `branch`, `branches`, `branch_delete`, `branch_new`, `change_head_branch`, `branch_contains`, `branches_all`, `update_ref` |
57
- | `Git::Repository::ContextHelpers` | `lib/git/repository/context_helpers.rb` | ✅ | `chdir`, `with_index`, `with_temp_index`, `with_working`, `with_temp_working`, `set_index`, `set_working` |
58
- | `Git::Repository::Merging` | `lib/git/repository/merging.rb` | ✅ | `merge`, `revert`, `each_conflict`; `merge_base` wraps the returned SHA strings in `Git::Object::Commit.new(self, ...)` instances |
59
- | `Git::Repository::RemoteOperations` | `lib/git/repository/remote_operations.rb` | ✅ | `fetch`, `pull`, `push`, `remote_add` (alias: `add_remote`), `remote_remove` (alias: `remove_remote`), `remote_set_url` (alias: `set_remote_url`), `config_remote`, `remote`, `remotes`, `ls_remote`, `remote_set_branches` |
60
- | `Git::Repository::Stashing` | `lib/git/repository/stashing.rb` | ✅ | `stash_list`, `stash_save`, `stash_apply`, `stash_clear`, `stashes_all` |
61
- | `Git::Repository::Diffing` | `lib/git/repository/diffing.rb` | ✅ | `diff_full`, `diff_numstat`, `diff_stats`, `diff`, `diff_path_status` (alias: `diff_name_status`), `diff_files`, `diff_index` |
62
- | `Git::Repository::Inspecting` | `lib/git/repository/inspecting.rb` | ✅ | `describe`, `show`, `fsck` |
63
- | `Git::Repository::Logging` | `lib/git/repository/logging.rb` | ✅ | `log`, `full_log_commits` |
64
- | `Git::Repository::Maintenance` | `lib/git/repository/maintenance.rb` | ✅ | `repack`, `gc` |
65
- | `Git::Repository::ObjectOperations` | `lib/git/repository/object_operations.rb` | ✅ | `cat_file_contents`, `cat_file_size`, `cat_file_type`, `cat_file_commit`, `cat_file_tag`, `rev_parse`, `tag_sha`, `full_tree`, `tree_depth`, `name_rev`, `ls_tree`, `grep`, `archive`, `gblob`, `gcommit`, `gtree`, `tag`, `object`, `tags`, `add_tag`, `delete_tag` |
66
- | `Git::Repository::StatusOperations` | `lib/git/repository/status_operations.rb` | ✅ | `ls_files`, `no_commits?` / `empty?`, `untracked_files`, `status` |
67
- | `Git::Repository::Configuring` | `lib/git/repository/configuring.rb` | ✅ | `config`, `config_get`, `config_list`, `config_set`, `global_config`, `global_config_get`, `global_config_list`, `global_config_set` |
68
- | `Git::Repository::WorktreeOperations` | `lib/git/repository/worktree_operations.rb` | ✅ | `worktrees_all`, `worktree_add`, `worktree_remove`, `worktree_prune`, `worktree`, `worktrees` |
69
-
70
- #### Facade module naming convention
71
-
72
- New topic modules follow a **three-tier** convention:
73
-
74
- - **Gerund** (verb-ing) when a single action word clearly names the whole module:
75
- `Staging`, `Committing`, `Branching`, `Merging`, `Logging`, `Diffing`, `Stashing`,
76
- `Configuring`, `Inspecting`.
77
- - **Noun + `Operations`** when the module is a mixed bag of methods grouped by git
78
- concept rather than a single action: `RemoteOperations`, `ObjectOperations`,
79
- `StatusOperations`, `WorktreeOperations`.
80
- - **Descriptive utility names** for cross-cutting helpers or housekeeping APIs that
81
- are not domain-object names: `ContextHelpers`, `Maintenance`.
82
-
83
- Do **not** use plain nouns that clash with existing domain-object class names
84
- such as `Branch`, `Diff`, `Log`, `Object`, `Remote`, `Status`, `Worktree`, etc.
85
-
86
- ### Next Task
87
-
88
- #### Phase 4 complete — architectural redesign is done 🎉
89
-
90
- Phase 4 **Step A — Remove old code** is ✅ complete. The atomic removal landed in
91
- [PR #1456](https://github.com/ruby-git/ruby-git/pull/1456) (commit `c1c53999`),
92
- which deleted `Git::Base` and `Git::Lib`, removed the `base_object` / `from_base`
93
- bridge from `Git::ExecutionContext::Repository`, and dropped the legacy `require`
94
- lines from `lib/git.rb`. This also satisfies the long-standing **D2** redesign
95
- item. The only remaining `Git::Base` / `Git::Lib` strings in `lib/` are YARD/comment
96
- references to historical 4.x behavior, which the Step A done-criteria explicitly
97
- allow.
98
-
99
- Phase 4 **Step B — Finalize test suite** is ✅ complete. All 159 PORT rows (after dedup) were ported
100
- to RSpec (batches U1–U21), `tests/` and the Test::Unit tooling were removed (W3), the
101
- `extract-*` skills were deprecated (W4a), Test::Unit documentation references were
102
- removed (W4b), the full quality gate was verified green (W5 — 5668 unit + 893
103
- integration examples, 0 failures), and stale `Git::Base`/`Git::Lib` references were
104
- removed from active Copilot skills (W6 — [PR #1509](https://github.com/ruby-git/ruby-git/pull/1509)).
105
-
106
- Phase 4 **Step C — Update documentation** is ✅ complete. C1a–C1d (YARD audit and
107
- coverage gate), C2a–C2b (`UPGRADING.md` and `README.md`), and C3 (documentation
108
- completeness verification) are all done. Final state: all unit and integration examples
109
- pass, 0 failures; 100.00% documented; `yard:lint` no offenses; gem builds.
110
- One gap found and fixed during C3b: `Git::Status` was missing a class-level
111
- `@example` (added in this PR).
112
-
113
- All Phase 4 steps are now complete:
114
-
115
- | Step | Status | Summary |
116
- | ---- | ------ | ------- |
117
- | A — Remove old code | ✅ Complete | `Git::Base`/`Git::Lib` and the bridge deleted ([PR #1456](https://github.com/ruby-git/ruby-git/pull/1456)) |
118
- | B — Finalize test suite | ✅ Complete | W2 ✅ (all 159 PORT rows ported and merged after dedup, batches U1–U21); W3 ✅ (removed `tests/` and Test::Unit tooling); W4a ✅ (deprecated `extract-*` skills); W4b ✅ (removed Test::Unit doc references); W5 ✅ (gate green: 5668 unit + 893 integration, 0 failures); W6 ✅ (removed stale `Git::Base`/`Git::Lib` skill refs, [PR #1509](https://github.com/ruby-git/ruby-git/pull/1509)) |
119
- | C — Update documentation | ✅ Complete | C1a–C1d ✅ (YARD audit + coverage gate); C2a ✅ (`UPGRADING.md`); C2b ✅ (`README.md`); C3 ✅ (docs verification: CI green, spot-check passed, links valid) |
120
-
121
- The architectural redesign is now **fully complete**. The codebase is ready for the
122
- v5.0.0 release process (see the
123
- [release-management](../.github/skills/release-management/SKILL.md) skill).
124
-
125
- The following earlier prerequisites are all ✅ complete:
126
-
127
- | Step | Status |
128
- | ---- | ------ |
129
- | C1c-2: public-API parity audit and remediation sweep | ✅ |
130
- | E: block-based helper/path-context methods migrated | ✅ |
131
- | D2: remove the `base_object` / `from_base` bridge | ✅ |
132
-
133
- Steps C1d-1, C1d-2, and C1d-3 are ✅ complete (see their detail sections below for full specs).
134
-
135
- ---
136
-
137
- #### Phase 3 Overview
138
-
139
- All 9 domain-object migrations are ✅ complete:
140
-
141
- | Domain objects | PRs |
142
- | -------------- | --- |
143
- | `Git::Stash` + `Git::Stashes` | [PR #1306](https://github.com/ruby-git/ruby-git/pull/1306) |
144
- | `Git::DiffPathStatus` | — |
145
- | `Git::Object::*` | — |
146
- | `Git::Log` | [PR #1327](https://github.com/ruby-git/ruby-git/pull/1327) |
147
- | `Git::Diff` + `Git::DiffStats` | — |
148
- | `Git::Status` | — |
149
- | `Git::Branch` + `Git::Remote` | — |
150
- | `Git::Branches` | [PR #1356](https://github.com/ruby-git/ruby-git/pull/1356), [PR #1357](https://github.com/ruby-git/ruby-git/pull/1357), [PR #1358](https://github.com/ruby-git/ruby-git/pull/1358), [PR #1359](https://github.com/ruby-git/ruby-git/pull/1359) |
151
- | `Git::Worktree` + `Git::Worktrees` | — |
152
-
153
- The work was organized into six workstreams (A–F). All workstreams are ✅ complete.
154
- F1 and F2 are both ✅ complete — F2 moved the remaining `Git` module utility methods
155
- off `Git::Lib`. Phase 4 Steps A, B, and C are all ✅ complete (see
156
- [Next Task](#next-task)).
157
-
158
- **Sequencing** (see [Phase 3 dependency order](#phase-3-dependency-order) for the
159
- reasoning behind each edge):
160
-
161
- ```mermaid
162
- graph LR
163
- A1 --> C1c-2
164
- A2 --> C1c-2
165
- A3 --> B --> C1c-2
166
- A3 --> C1c-2
167
- A4 --> C1c-2
168
- C1a-1 --> C1a-2
169
- C1a-1 --> E --> C1c-2
170
- C1a-1 --> C1c-2
171
- C1a-2 --> C1c-2
172
- C1b --> C1c-2
173
- C1c-1 --> C1c-2
174
- C1c-2 --> C1d-1
175
- C1d-1 --> C1d-2 --> C1d-3 --> D1 --> Phase4["Phase 4"]
176
- D2 --> Phase4
177
- F1 --> Phase4
178
- F2 --> Phase4
179
- ```
180
-
181
- ---
182
-
183
- #### Workstream A — Fill facade coverage gaps
184
-
185
- `Git::Base` still calls `lib.*` directly for 11 high-priority methods that have no
186
- `Git::Repository` counterpart yet. Each step below adds the missing facade methods and
187
- updates `Git::Base` to delegate.
188
-
189
- **Step A1 — Extend `Git::Repository::Staging`: `rm`, `clean`, `ignored_files`** ✅
190
-
191
- | `Git::Base` method | Facade to add |
192
- | --- | --- |
193
- | `rm(path, opts)` | `Git::Repository::Staging#rm` → `Commands::Rm` |
194
- | `clean(opts)` | `Git::Repository::Staging#clean` → `Commands::Clean`; the `migrate_clean_legacy_options` deprecation adapter (`:ff`/`:force_force`) moves into the facade |
195
- | `ignored_files` | `Git::Repository::Staging#ignored_files` → `Commands::LsFiles` |
196
-
197
- Files touched: `lib/git/repository/staging.rb`, `spec/unit/git/repository/staging_spec.rb`, `lib/git/base.rb`
198
-
199
- **Step A2 — Extend `Git::Repository::RemoteOperations`: `remotes`, `set_remote_url`, `remote_set_branches`** ✅
200
-
201
- | `Git::Base` method | Facade to add |
202
- | --- | --- |
203
- | `remotes` | `Git::Repository::RemoteOperations#remotes` → `Commands::Remote::List`; returns `Array<Git::Remote>` |
204
- | `set_remote_url(name, url)` | `Git::Repository::RemoteOperations#set_remote_url` → `Commands::Remote::SetUrl`; coerce local-repo `Git::Base` url to string in facade pre-processing; return `Git::Remote` |
205
- | `remote_set_branches(name, *branches, add:)` | `Git::Repository::RemoteOperations#remote_set_branches` → `Commands::Remote::SetBranches` |
206
-
207
- Files touched: `lib/git/repository/remote_operations.rb`, `spec/unit/git/repository/remote_operations_spec.rb`, `lib/git/base.rb`
208
-
209
- **Step A3 — Extend `Git::Repository::ObjectOperations`: `tags`, `add_tag`, `delete_tag`** ✅
210
-
211
- | `Git::Base` method | Facade to add |
212
- | --- | --- |
213
- | `tags` | `Git::Repository::ObjectOperations#tags` → `Commands::Tag::List` + `Parsers::Tag`; returns `Array<Git::Object::Tag>` |
214
- | `add_tag(name, *options)` | `Git::Repository::ObjectOperations#add_tag` → `Commands::Tag::Create`; `validate_tag_options!` validation logic moves into the facade |
215
- | `delete_tag(name)` | `Git::Repository::ObjectOperations#delete_tag` → `Commands::Tag::Delete` |
216
-
217
- Files touched: `lib/git/repository/object_operations.rb`, `spec/unit/git/repository/object_operations_spec.rb`, `lib/git/base.rb`
218
-
219
- **Step A4 — New `Git::Repository::Inspecting` module: `show`, `fsck`** ✅
220
-
221
- These are read-only repository inspection operations that don't fit an existing topic module.
222
-
223
- | `Git::Base` method | Facade to add |
224
- | --- | --- |
225
- | `show(objectish, path)` | `Git::Repository::Inspecting#show` → `Commands::Show`; returns `String` |
226
- | `fsck(*objects, **opts)` | `Git::Repository::Inspecting#fsck` → `Commands::Fsck` + `Parsers::Fsck`; returns `Git::FsckResult` |
227
-
228
- Files touched: `lib/git/repository/inspecting.rb` (new), `lib/git/repository.rb` (add `include Git::Repository::Inspecting`), `spec/unit/git/repository/inspecting_spec.rb` (new), `lib/git/base.rb`
229
-
230
- **Later covered by C1c-2:** lower-level public methods such as `describe`,
231
- `repack`, `gc`, `apply`, `apply_mail`, `read_tree`, and `cat_file_*` were
232
- subsequently migrated into `Inspecting`, `Maintenance`, `Staging`, and
233
- `ObjectOperations` before `Git.open` started returning `Git::Repository`.
234
-
235
- ---
236
-
237
- #### Workstream B — C0: Redirect `Git::Base` factory methods to `facade_repository`
238
-
239
- These `Git::Base` methods construct domain objects directly with `self` instead of
240
- delegating. All corresponding facade methods already exist — this is pure delegation
241
- wiring with no new facade code needed. Ship as one PR (`feat/c0-delegate-base-factories`).
242
-
243
- ⚠️ Depends on A3 (`tags`/`add_tag`/`delete_tag`) before `tag` can be redirected.
244
-
245
- **Step B — Redirect `Git::Base` domain-object factories to `facade_repository`** ✅
246
-
247
- | `Git::Base` method | Current | Replace with |
248
- | --- | --- | --- |
249
- | `branch(branch_name)` [L936] | `Git::Branch.new(self, ...)` | `facade_repository.branch(branch_name)` |
250
- | `branches` [L950] | `Git::Branches.new(self)` | `facade_repository.branches` |
251
- | `gblob(objectish)` [L993] | `Git::Object.new(self, objectish, 'blob')` | `facade_repository.gblob(objectish)` |
252
- | `gcommit(objectish)` [L998] | `Git::Object.new(self, objectish, 'commit')` | `facade_repository.gcommit(objectish)` |
253
- | `gtree(objectish)` [L1003] | `Git::Object.new(self, objectish, 'tree')` | `facade_repository.gtree(objectish)` |
254
- | `object(objectish)` [L1030] | `Git::Object.new(self, objectish)` | `facade_repository.object(objectish)` |
255
- | `remote(remote_name)` [L1035] | `Git::Remote.new(self, remote_name)` | `facade_repository.remote(remote_name)` |
256
- | `tag(tag_name)` [L1045] | `Git::Object::Tag.new(self, tag_name)` | `facade_repository.tag(tag_name)` |
257
-
258
- ---
259
-
260
- #### Workstream C — C1: Prepare and flip top-level entry points to return `Git::Repository`
261
-
262
- ⚠️ C1d, the actual return-type flip, depends on all of Workstreams A, B, and E plus
263
- C1a-1/C1a-2/C1b/C1c being complete.
264
-
265
- This workstream has six sub-tasks. C1a-1, C1a-2, and C1b can land early; C1c-1 and C1c-2 must run after
266
- facade/helper coverage; C1d is the final step.
267
-
268
- **C1a — Add factory class methods to `Git::Repository`** (group: Step C1a-1 and Step C1a-2)
269
-
270
- The construction logic currently in `Git::Base.open`, `.bare`, `.clone`, and
271
- `Git.init` must move to equivalent factory class methods on `Git::Repository` so
272
- that `Git.open` etc. can call `Git::Repository.open` instead of `Git::Base.open`.
273
- The notable complexity is clone result parsing/path resolution: `Git::Base.clone`
274
- currently delegates to `Git::Lib#clone`, which already wraps `Git::Commands::Clone`.
275
- Move that adapter behavior into `Git::Repository.clone` without reintroducing a
276
- `Git::Lib` dependency.
277
-
278
- This workstream is intentionally split into two PRs because the path/accessor
279
- state work is independent of the clone/init work, and combining them would make a
280
- very large PR.
281
-
282
- **Step C1a-1 — Path state, accessors, and `.open`/`.bare` factories** ✅
283
-
284
- | `Git::Base` class method | Target |
285
- | --- | --- |
286
- | `.open(working_dir, options)` | `Git::Repository.open` — path validation + `resolve_paths` + constructor |
287
- | `.bare(git_dir, options)` | `Git::Repository.bare` — bare path resolution + constructor |
288
-
289
- Also move `resolve_paths` and `root_of_worktree` private helpers from `Git::Base`
290
- to `Git::Repository` (or a private `RepositoryPaths` helper module). `Git::Repository`
291
- must also expose the path/accessor surface currently provided by `Git::Base`: `dir`,
292
- `repo`, `index`, and `repo_size`.
293
-
294
- Files touched: `lib/git/repository.rb`, `lib/git/base.rb`
295
-
296
- **Step C1a-2 — `.clone` and `.init` factories** ✅
297
-
298
- | `Git::Base` / `Git` method | Target |
299
- | --- | --- |
300
- | `.clone(url, dir, options)` | `Git::Repository.clone` — delegates to `Commands::Clone`, resolves paths, constructs instance |
301
- | `Git.init(dir, options)` | `Git::Repository.init` — delegates to `Commands::Init` using `Git::ExecutionContext::Global` (not `Git::Lib`), then calls `.open`/`.bare` |
302
-
303
- Note: `Git.init` in `lib/git.rb` currently passes `Git::Lib.new` into
304
- `Git::Commands::Init`. That `Git::Lib.new` call is removed here by routing
305
- through `Git::Repository.init` instead.
306
-
307
- Note: `.repository_default_branch` is **not** part of C1a. That class method
308
- routes through `Git::Lib` and belongs with the `LsRemote` parser migration in
309
- Workstream F.
310
-
311
- Files touched: `lib/git/repository.rb`, `lib/git/base.rb`, `lib/git.rb`
312
-
313
- **Step C1b — Move global config singleton ownership off `Git::Base`** ✅
314
-
315
- `Git.configure` and `Git.config` both delegate to `Base.config`, which returns the
316
- `Git::Base`-owned `Git::Config` singleton. When `Git::Base` is deleted, these break.
317
- The fix is to move `config` to `Git::Config` itself as a class-level singleton (or to
318
- the `Git` module directly) and update `Git.configure`, `Git.config`,
319
- `Git.git_version`, `Git.binary_version`, and the surviving `Git::ExecutionContext`
320
- classes to reference it without going through `Git::Base`. While `Git::Base` exists,
321
- `Git::Base.config` can remain as a delegator for compatibility.
322
-
323
- Note: Both `Git.git_version` and the deprecated `Git.binary_version` in `lib/git.rb`
324
- currently evaluate `Git::Base.config.binary_path` at call time (not definition time),
325
- so both method bodies must be updated in this PR.
326
-
327
- Files touched: `lib/git/config.rb`, `lib/git.rb`, `lib/git/base.rb`,
328
- `lib/git/execution_context.rb`, `lib/git/execution_context/global.rb`,
329
- `lib/git/execution_context/repository.rb`
330
-
331
- **C1c — Public API parity/deprecation audit before the flip** (group: Step C1c-1 and Step C1c-2)
332
-
333
- Before `Git.open`, `Git.clone`, `Git.init`, and `Git.bare` return
334
- `Git::Repository`, every public `Git::Base` method that should survive in v5.0 must
335
- exist on `Git::Repository`; every method that should not survive must be explicitly
336
- documented as a v5 breaking change or already deprecated for removal. This audit is
337
- the gate that prevents the entry-point flip from silently dropping public methods
338
- just because `Git::Base` still exists in the tree.
339
-
340
- **Step C1c-1 — Signature-compatibility guidance and process** ✅
341
-
342
- Update extraction and review skills to document the signature-compatibility
343
- classification policy (legacy-contract vs 5.x-native), parity-check requirements,
344
- and test-creation expectations so that all future extraction work follows consistent
345
- rules before the remediation sweep begins.
346
-
347
- | Artifact | Change |
348
- | --- | --- |
349
- | `extract-facade-from-base-lib/SKILL.md` | Add `## Signature compatibility policy` section with legacy-contract vs 5.x-native classification table and four rules (legacy-contract preserves exact 4.x signatures, including rare `**opts`; 5.x-native uses `opts = {}` for consistency) |
350
- | `facade-implementation/SKILL.md` | Add policy classification check to review workflow (step 4) |
351
- | `facade-test-conventions/SKILL.md` | Add `context 'signature compatibility'` grouping convention and review checks |
352
-
353
- Files touched: `.github/skills/extract-facade-from-base-lib/SKILL.md`,
354
- `.github/skills/facade-implementation/SKILL.md`,
355
- `.github/skills/facade-test-conventions/SKILL.md`
356
-
357
- Tracked as [Issue #1369](https://github.com/ruby-git/ruby-git/issues/1369).
358
-
359
- **Step C1c-2 — End-of-Phase-3 public-API parity audit and remediation sweep** ✅
360
-
361
- Compare every public `Git::Base` method against `Git::Repository`; fix mismatches
362
- or explicitly record each as a documented v5 breaking change. No unclassified
363
- compatibility gap may remain before C1d.
364
-
365
- Required audit buckets:
366
-
367
- | Surface | Required decision before C1d |
368
- | --- | --- |
369
- | Path/accessors | `dir`, `repo`, `index`, `repo_size` must exist on `Git::Repository` (C1a-1 owns this) |
370
- | Compatibility aliases/wrappers | `remove`, `revparse`, `diff_name_status`, `reset_hard`, `is_local_branch?`, `is_remote_branch?`, `is_branch?`, `checkout` must be migrated or intentionally removed with upgrade notes (`checkout` is called by `Git.export` on the `Git.clone` result) |
371
- | Low-level public methods | Resolved in the current tree: `describe` → `Inspecting`; `repack`/`gc` → `Maintenance`; `apply`/`apply_mail`/`read_tree` → `Staging`; `cat_file_*` → `ObjectOperations`. Any intentional removals still require upgrade notes. |
372
- | Factory/domain-object returns | Confirm B plus A2/A3 cover `branch`, `branches`, `remote`, `remotes`, `tag`, `tags`, object factories, and tag create/delete return shapes |
373
- | Keyword-arg facades | For `legacy-contract` methods, preserve the exact 4.x call shape (including rare `**opts` signatures); for `5.x-native` methods, use `opts = {}` style for consistency |
374
-
375
- Files touched: `lib/git/repository/*.rb` (topic modules for migrated methods),
376
- `lib/git/base.rb`, upgrade notes / CHANGELOG for documented removals
377
-
378
- Tracked as [Issue #1370](https://github.com/ruby-git/ruby-git/issues/1370).
379
-
380
- ##### Step C1d-1 — Flip entry points
381
-
382
- With C1a, C1b, C1c, A, B, and E in place, update `Git.open`, `Git.clone`,
383
- `Git.init`, and `Git.bare` in `lib/git.rb` to call `Git::Repository.*` and return
384
- `Git::Repository` directly, bypassing `Git::Base` entirely.
385
-
386
- **Prerequisite fix before landing C1d-1:** delete `spec/integration/git/lib/config_spec.rb`
387
- after confirming behavior coverage exists in `spec/integration/git/repository/configuring_spec.rb`.
388
- The `def lib = self` shim causes `subject(:lib) { repo.lib }` to return `Git::Repository` (self),
389
- which triggers deprecation warnings from every deprecated alias call (config_set, config_get,
390
- global_config_set, etc.) in that spec.
391
-
392
- ##### Step C1d-2 — Eliminate internal `.lib` callers
393
-
394
- Clean up all `.lib` callers from tests while the silent `def lib = self` shim is still in
395
- place, then add `Git::Deprecation.behavior = :raise` to both test suites. See the phase table
396
- in the [Next Task](#next-task) section for the full per-phase breakdown.
397
-
398
- ##### Step C1d-3 — Remove dead fallbacks and add deprecation warning
399
-
400
- - Add `diff_numstat` delegator to `Git::Base` (prerequisite: not currently defined there)
401
- - Remove dead `respond_to?` + `.lib` fallback branches from `lib/git/diff.rb`,
402
- `lib/git/diff_stats.rb`, `lib/git/diff_path_status.rb`, `lib/git/status.rb`
403
- - Replace `def lib = self` in `lib/git/repository.rb` with a `Git::Deprecation.warn` body
404
- (removal version: v6.0.0; returns `self`)
405
- - Remove `command_capturing`, `command_streaming`, and private `env_overrides` from
406
- `lib/git/repository.rb` — these were added only to feed the silent shim
407
- - Add unit test asserting the deprecation warning and `self` return
408
-
409
- ---
410
-
411
- #### Workstream D — C3: Remove compatibility fallbacks
412
-
413
- ⚠️ These are v5-only cleanup steps. They are not 4.x-compatible and must be kept out
414
- of 4.x release candidates unless an explicit breaking-change decision has already
415
- been recorded.
416
-
417
- ##### Step D1 — Remove domain-object compatibility fallbacks
418
-
419
- ⚠️ Depends on C1d. This can be a releasable v5 cleanup PR after `Git.open` returns
420
- `Git::Repository`, because normal construction paths no longer pass `Git::Base` into
421
- domain objects. It is breaking for callers that directly construct domain objects
422
- with a `Git::Base` provider, so that removal must be documented in the upgrade notes.
423
-
424
- Remove `is_a?(Git::Base)` guards. Current sites:
425
-
426
- | File | Line |
427
- | --- | --- |
428
- | `lib/git/branch.rb` | L478 (`branch_repository` helper) |
429
- | `lib/git/branches.rb` | L150 (`branches_repository` helper) |
430
- | `lib/git/log.rb` | L170 (`log_repository` helper) |
431
- | `lib/git/object.rb` | L137, L329, L405 |
432
- | `lib/git/remote.rb` | L149 (`remote_repository` helper) |
433
- | `lib/git/stash.rb` | L104 (`stash_repository` helper) |
434
- | `lib/git/stashes.rb` | L170 (`stashes_repository` helper) |
435
- | `lib/git/worktree.rb` | L151 (`worktree_repository` helper) |
436
- | `lib/git/worktrees.rb` | L144 (`worktrees_repository` helper) |
437
- | `lib/git/repository/remote_operations.rb` | L418 (`url.is_a?(Git::Base)` coercion — handled in A2 facade pre-processing instead) |
438
-
439
- Each guard simplifies to just the `Git::Repository` branch — the `Git::Base` branch is deleted.
440
-
441
- Verify no guards remain: `grep -r 'is_a?(Git::Base)' lib/`
442
-
443
- Also remove legacy `@base.lib` fallback paths that only exist to support
444
- `Git::Base`/`Git::Lib`-backed domain objects:
445
-
446
- | File | Fallback |
447
- | --- | --- |
448
- | `lib/git/diff.rb` | `@base.lib.diff_full` |
449
- | `lib/git/diff_stats.rb` | `@base.lib.diff_stats` |
450
- | `lib/git/diff_path_status.rb` | `@base.lib.diff_path_status` |
451
-
452
- After D1, domain objects should assume their provider is `Git::Repository` (or a
453
- compatible object that implements the repository facade methods directly), not an
454
- object with a `.lib` escape hatch.
455
-
456
- ---
457
-
458
- #### Workstream E — Migrate or deprecate instance helper methods
459
-
460
- ⚠️ Depends on C1a (factory/path state must exist so the helpers have a home). E must
461
- complete before C1d, because `Git.open` returning `Git::Repository` without these
462
- helpers would drop existing public `Git::Base` behavior.
463
-
464
- `Git::Base` exposes several block-based helper methods that have no counterpart on
465
- `Git::Repository`. They must either be migrated before `Git::Base` can be deleted,
466
- or explicitly deprecated with removal in v6.0. The recommended path is migration.
467
-
468
- **Step E — Migrate block-based helper/path-context methods to `Git::Repository`** ✅
469
-
470
- | `Git::Base` method | Proposed destination | Notes |
471
- | --- | --- | --- |
472
- | `#chdir(&block)` | `Git::Repository#chdir` | `Dir.chdir(dir.to_s) { yield dir }` — trivial; just needs the `dir` accessor on `Git::Repository` |
473
- | `#with_index(new_index, &block)` | `Git::Repository#with_index` | Invalidates and restores `@index`; rebuilds the repository execution context |
474
- | `#with_temp_index(&block)` | `Git::Repository#with_temp_index` | Creates a `Tempfile`-backed index, delegates to `with_index` |
475
- | `#with_working(work_dir, &block)` | `Git::Repository#with_working` | Invalidates and restores `@working_directory`; rebuilds the repository execution context |
476
- | `#with_temp_working(&block)` | `Git::Repository#with_temp_working` | Creates a `Dir.mktmpdir`-backed working dir, delegates to `with_working` |
477
-
478
- `set_index` and `set_working` (the non-block mutators) must also be migrated or
479
- removed at the same time, since `with_index`/`with_working` depend on the same
480
- invalidation logic.
481
-
482
- Files touched: `lib/git/repository/context_helpers.rb`, `lib/git/base.rb`,
483
- `spec/unit/git/repository/` (new or extended spec)
484
-
485
- ---
486
-
487
- #### Workstream F — `Git` module utility methods still using `Git::Lib` directly
488
-
489
- ⚠️ These are **Phase 4 prerequisites** — they do not block A–E but must be done
490
- before `Git::Lib` can be deleted.
491
-
492
- Three `Git`-module-level methods bypass `Git::Repository` entirely and call
493
- `Git::Lib` directly. The required command classes already exist; each method needs a
494
- non-`Git::Lib` adapter path using `Git::ExecutionContext::Global` plus existing
495
- parsing logic.
496
-
497
- **Step F1 — Move `Git.ls_remote` and `Git.default_branch` off `Git::Lib`** ✅
498
-
499
- | `Git` module method | Current path | Required work |
500
- | --- | --- | --- |
501
- | `Git.default_branch(repo, options)` | `Base.repository_default_branch` → `Git::Lib.new.repository_default_branch` | Use `Git::Commands::LsRemote` with `symref: true` and migrate the default-branch parser out of `Git::Lib` |
502
- | `Git.ls_remote(location, options)` | `Git::Lib.new.ls_remote` | Migrate to `Git::Commands::LsRemote` (shared with `default_branch`) |
503
-
504
- Also migrate `Git::Base.repository_default_branch` to use `Git::Commands::LsRemote`
505
- directly (sharing the `LsRemote` parser with `Git.ls_remote`). This is the call
506
- chain behind `Git.default_branch` and can be migrated in the same F1 PR since both
507
- use the same command class.
508
-
509
- Files touched: `lib/git.rb`, `lib/git/base.rb`, and parser/helper code extracted
510
- from `Git::Lib` as needed
511
-
512
- **Step F2 — Move `Git.global_config`, `#config`, and `#global_config` off `Git::Lib`** ✅
513
-
514
- | `Git` module method | Current path | Required work |
515
- | --- | --- | --- |
516
- | `Git.global_config(name, value)` | `Git::Lib.new.global_config_{get,set,list}` | Use `Git::Commands::ConfigOptionSyntax::{Get,List,Set}` with `global: true` |
517
-
518
- Also audit the `Git` module instance methods `#config` and `#global_config` for
519
- callers that `include Git`; `#global_config` should continue delegating to the class
520
- method, while `#config` must either be reimplemented without `Git::Lib.new` or
521
- documented as removed.
522
-
523
- Files touched: `lib/git.rb`, `lib/git/base.rb`, and parser/helper code extracted
524
- from `Git::Lib` as needed
525
-
526
- ---
527
-
528
- #### Phase 3 dependency order
529
-
530
- 1. **Parallel starters**: A1–A4, C1a, C1b, F1, and F2 can begin independently.
531
- 2. **B after A3**: B can start once A3 supplies facade tag factories.
532
- 3. **E after C1a**: helper/path-context methods need `Git::Repository` path state.
533
- 4. **C1c-2 after A+B+E+C1c-1**: API parity remediation can only be actioned after facade and helper coverage exists and the guidance/policy (C1c-1) is in place.
534
- 5. **C1d is the v5 boundary step**: the `Git.open`/`.clone`/`.init`/`.bare` return-type flip waits for A, B, C1a, C1b, C1c-1, C1c-2, and E, and is explicitly not a 4.x-compatible change.
535
- 6. **D1 after C1d**: domain-object fallback removal waits until normal construction no longer passes `Git::Base` into domain objects.
536
- 7. **Phase 4 after D1+F1+F2**: deleting `Git::Base`/`Git::Lib` waits for domain-object fallback removal and `Git` module utilities to stop using `Git::Lib`; D2 lands with that deletion, not before it.
537
-
538
- ---
539
-
540
- #### Phase 3 steps and release compatibility
541
-
542
- Default rule: every step before C1d that produces code must be small, independently releasable on the
543
- 4.x-compatible line, and must preserve public signatures, return values, deprecation
544
- warnings, and top-level factory behavior. Any intentional break must be explicitly
545
- classified as a v5-only PR with upgrade-note coverage before it lands.
546
-
547
- **GitHub PR column:** ⬜ = not yet opened; replace with a PR link (e.g. `[#1234](…)`) when opened, then append ✅ when merged.
548
-
549
- | Step | GitHub PR | Scope | Release lane | Backward-compatibility rule |
550
- | --- | --- | --- | --- | --- |
551
- | A1 | ✅ | Add `rm`, `clean`, `ignored_files` facade coverage | 4.x-compatible | `Git::Base` public methods keep the same signatures, return values, and deprecation behavior. |
552
- | A2 | ✅ | Add `remotes`, `set_remote_url`, `remote_set_branches` facade coverage | 4.x-compatible | `Git::Base` remote methods keep the same return objects and validation behavior. |
553
- | A3 | ✅ | Add `tags`, `add_tag`, `delete_tag` facade coverage | 4.x-compatible | Tag list/create/delete return contracts match 4.x behavior. |
554
- | A4 | ✅ | Add `Inspecting#show` and `#fsck` | 4.x-compatible | `Git::Base#show` and `#fsck` remain behavior-compatible and delegate internally. |
555
- | B | ✅ | Redirect `Git::Base` domain-object factories | 4.x-compatible | Method signatures and return types stay the same; only the internal provider changes to `Git::Repository`. Split into object/tag factories and branch/remote factories if the PR grows. |
556
- | C1a-1 | ✅ | Add `Git::Repository.open`/`.bare`, path state, and `dir`/`repo`/`index`/`repo_size` | 4.x-compatible additive | `Git.open`/`.bare` still return `Git::Base`; new repository factories are additive until C1d. |
557
- | C1a-2 | ✅ | Add `Git::Repository.clone`/`.init` | 4.x-compatible additive | `Git.clone`/`.init` still return `Git::Base`; clone/init behavior is duplicated behind new factories without changing public entry points. |
558
- | C1b | [#1385](https://github.com/ruby-git/ruby-git/pull/1385) ✅ | Move global config ownership | 4.x-compatible | `Git.config`, `Git.configure`, and `Git::Base.config` keep working; `Git::Base.config` remains as a delegator. |
559
- | E | ✅ | Add repository helper/path-context methods | 4.x-compatible additive | `Git::Base` helpers keep working; `Git::Repository` gains equivalent behavior before any top-level return-type change. Split index helpers and working-directory helpers if needed. |
560
- | F1 | ✅ | Move `Git.ls_remote` and `Git.default_branch` off `Git::Lib` | 4.x-compatible | Return formats and error behavior match current 4.x-compatible behavior. |
561
- | F2 | ✅ | Move `Git.global_config`, module `#config`, and module `#global_config` off `Git::Lib` | 4.x-compatible | Config methods keep the same return formats and write behavior. |
562
- | C1c-1 | ✅ | Guidance/process: signature-compatibility policy for extraction and review ([#1369](https://github.com/ruby-git/ruby-git/issues/1369)) | 4.x-compatible / docs-only | Guidance and review checklists define legacy-contract vs 5.x-native signatures, including test expectations. |
563
- | C1c-2 | ✅ | End-of-Phase-3 public-API parity audit and remediation sweep ([#1370](https://github.com/ruby-git/ruby-git/issues/1370)) | 4.x-compatible | All four parity audit buckets resolved (fix or documented removal) before C1d; no unclassified compatibility gap remains. |
564
- | C1d | ✅ | Flip `Git.open`/`.clone`/`.init`/`.bare` to return `Git::Repository` | v5 boundary | Explicit breaking change because class identity changes from `Git::Base` to `Git::Repository`; method-level parity must be complete first. Split into C1d-1 (entry point flip), C1d-2 (eliminate internal .lib callers + add deprecation enforcement to both test suites), and C1d-3 (remove dead fallbacks + replace silent lib shim with real deprecation warning). |
565
- | D1 | ✅ | Remove domain-object `Git::Base` guards and `@base.lib` fallbacks | v5 cleanup | Explicitly drops direct `Git::Base` provider support in domain-object constructors; normal factory-created objects remain supported. |
566
- #### Phase 3 completion criteria
567
-
568
- Use this table to decide whether a checklist item can be marked complete. A step is
569
- done only when its code, focused specs, and delegation/cleanup checks are all true.
570
-
571
- | Step | Done when |
572
- | --- | --- |
573
- | A1: `Staging` — `rm`, `clean`, `ignored_files` | `Git::Repository::Staging` implements all three methods; `Git::Base#rm`, `#clean`, and `#ignored_files` delegate to `facade_repository`; legacy clean option deprecations still fire; focused staging specs cover success, option validation, and return values. |
574
- | A2: `RemoteOperations` — `remotes`, `set_remote_url`, `remote_set_branches` | `Git::Repository::RemoteOperations` implements all three methods; returned remotes are `Git::Remote` objects backed by `Git::Repository`; local repository URL coercion no longer requires a `Git::Base` branch after D1; focused remote-operation specs cover branch validation, return values, and command arguments. |
575
- | A3: `ObjectOperations` — `tags`, `add_tag`, `delete_tag` | `Git::Repository::ObjectOperations` implements all three methods; tag parsing/validation matches the legacy `Git::Lib` behavior; `tags`/`add_tag` return repository-backed tag objects; `delete_tag` preserves the legacy return contract; focused object-operation specs cover create/delete/list paths. |
576
- | A4: `Inspecting` — `show`, `fsck` | `Git::Repository::Inspecting` exists, is required and included by `Git::Repository`, and implements both methods; `show` returns the expected string output; `fsck` returns `Git::FsckResult`; `Git::Base#show` and `#fsck` delegate to the facade; focused inspecting specs cover parser and command wiring. |
577
- | B: `Git::Base` factory delegation wiring | Every listed `Git::Base` factory delegates to `facade_repository`; constructed domain objects receive a `Git::Repository` provider, not `self`; legacy method signatures and default arguments stay unchanged; focused specs prove each factory return type and provider. |
578
- | C1a-1: `Git::Repository.open`/`.bare` + path state | `Git::Repository.open` and `.bare` exist; `resolve_paths` and `root_of_worktree` helpers are on `Git::Repository`; repository instances expose `dir`, `repo`, `index`, and `repo_size`; focused specs cover working and bare construction. |
579
- | C1a-2: `Git::Repository.clone`/`.init` | `Git::Repository.clone` and `.init` exist and preserve legacy path resolution, `git_ssh:`, `binary_path:`, `log:`, `index:`, and `repository:` behavior; clone/init use `Git::ExecutionContext::Global`, not `Git::Lib`; `Git.init` in `lib/git.rb` no longer passes `Git::Lib.new` into `Commands::Init`; focused specs cover clone and init construction. |
580
- | C1b: global config ownership | `Git.config`, `Git.configure`, `Git.git_version`, `Git.binary_version`, and `Git::ExecutionContext` resolve global config without referencing `Git::Base.config`; both the method body of `git_version` and the default-parameter expression of `binary_version` are updated; `Git::Base.config` remains only as a compatibility delegator while `Git::Base` exists; specs prove runtime changes to global `binary_path` and `git_ssh` are still honored. |
581
- | C1c-1: signature-compatibility guidance | Skill updates merged (Issue #1369): `extract-facade-from-base-lib`, `facade-implementation`, and `facade-test-conventions` skills document the legacy-contract vs 5.x-native classification policy, parity-check requirements, and test-creation expectations; legacy-contract methods preserve exact 4.x call shapes while 5.x-native methods use `opts = {}`; keyword-arg remediation list for C1c-2 is established. |
582
- | C1c-2: public-API parity audit and remediation | End-of-Phase-3 sweep complete (Issue #1370): a public-method inventory compares `Git::Base` and `Git::Repository`; every surviving public method has a repository implementation and focused coverage; every intentional removal has an upgrade-note/deprecation decision; no unclassified compatibility gap remains. |
583
- | C1d: entry-point flip | `Git.open`, `Git.clone`, `Git.init`, and `Git.bare` return `Git::Repository`; common existing workflows still pass through those entry points; YARD return docs are updated; no top-level factory method calls `Git::Base.*`; full suite passes. |
584
- | D1: domain-object fallback removal | No `is_a?(Git::Base)` guards remain; no `@base.lib` fallback remains in domain objects; direct `Git::Base` provider support is documented as a v5-only removal; full suite passes. |
585
- | E: instance helper methods | `Git::Repository` implements or explicitly deprecates `chdir`, `with_index`, `with_temp_index`, `with_working`, `with_temp_working`, `set_index`, and `set_working`; context rebuilding after index/worktree changes is covered by specs; helpers yield the same values and restore state after block exit/errors. |
586
- | F: `Git` module utilities off `Git::Lib` | `Git.default_branch`, `Git.global_config`, `Git.ls_remote`, module instance `#config`, and module instance `#global_config` no longer call `Git::Lib.new`; `Git::Base.repository_default_branch` migrated to use `Git::Commands::LsRemote` directly; existing `LsRemote` and `ConfigOptionSyntax` commands provide the behavior; parser/helper code needed from `Git::Lib` has moved; `grep -n 'Lib.new' lib/git.rb` returns no matches. |
587
-
588
- ---
589
-
590
- #### Facade coverage checklist
591
-
592
- | Step | Status |
593
- | --- | --- |
594
- | A1: `Staging` — `rm`, `clean`, `ignored_files` | ✅ |
595
- | A2: `RemoteOperations` — `remotes`, `set_remote_url`, `remote_set_branches` | ✅ |
596
- | A3: `ObjectOperations` — `tags`, `add_tag`, `delete_tag` | ✅ |
597
- | A4: new `Inspecting` — `show`, `fsck` | ✅ |
598
- | B (C0): `Git::Base` factory delegation wiring | ✅ |
599
- | C1a-1: `Git::Repository.open`/`.bare`, path state (`dir`, `repo`, `index`, `repo_size`) | ✅ |
600
- | C1a-2: `Git::Repository.clone`/`.init` (no `Git::Lib` dependency) | ✅ |
601
- | C1b: Global config ownership (`Base.config` → `Git::Config`) | ✅ |
602
- | C1c-1: Guidance/process updates for signature compatibility (#1369) | ✅ |
603
- | C1c-2: End-of-Phase-3 public-API parity audit and remediation (#1370) | ✅ |
604
- | C1d: Entry-point flip (`Git.open` etc. → `Git::Repository`) | ✅ |
605
- | D1 (C3): Remove `is_a?(Git::Base)` guards + `@base.lib` fallbacks | ✅ |
606
- | E: Instance helpers (`#chdir`, `#with_index`, `#with_temp_index`, `#with_working`, `#with_temp_working`) | ✅ |
607
- | F: `Git` module utilities (`default_branch`, `global_config`, `ls_remote`) off `Git::Lib` | ✅ |
608
-
609
- #### Quality gates (per step)
610
-
611
- 1. Run the focused spec for the touched module: `bundle exec rspec spec/unit/git/repository/<topic>_spec.rb`
612
- 2. Run the full suite: `bundle exec rake default:parallel` — CI-equivalent aggregate task covering Test::Unit, RSpec, RuboCop, YARD, and build
613
- 3. For every 4.x-compatible step before C1d: confirm no public `Git`, `Git::Base`, or `Git::Lib` method signature/return contract changes unless the step explicitly documents a compatible deprecation path
614
- 4. After C1b: confirm `Git.configure`, `Git.config`, `Git.git_version`, and `Git::ExecutionContext` no longer depend on `Git::Base.config`
615
- 5. After C1c-2: compare `Git::Base` public methods against `Git::Repository` and record every intentional removal in upgrade notes
616
- 6. After C1d: confirm `Git.open(...)` returns a `Git::Repository` instance and common legacy call sites still work or fail with documented breaking-change coverage
617
- 7. After D1: confirm no guards or legacy lib fallbacks remain: `grep -r 'is_a?(Git::Base)\|@base\.lib' lib/`
618
- 8. After D2: confirm no `base_object` or `from_base` bridge remains and `Git::Base` is deleted or retired in the same releasable PR
619
- 9. After F: confirm no `Git::Lib.new` calls remain in `lib/git.rb`: `grep -n 'Lib.new' lib/git.rb`
620
-
621
- #### Reference Files
622
-
623
- - Facade shell: `lib/git/repository.rb`
624
- - Staging module (pattern reference): `lib/git/repository/staging.rb`
625
- - Staging spec (pattern reference): `spec/unit/git/repository/staging_spec.rb`
626
- - RemoteOperations (more complex example): `lib/git/repository/remote_operations.rb`
627
- - Command classes: `lib/git/commands/` (especially `clone.rb`, `ls_remote.rb`, and `config_option_syntax/*`)
628
-
629
- ## Phase 1: Foundation and Scaffolding
630
-
631
- ***Goal**: Set up the new file structure and class names without altering existing
632
- logic. The gem will be fully functional after this phase.*
633
-
634
- 1. **Create New Directory Structure**
635
-
636
- - `lib/git/commands/` ✅
637
- - `lib/git/repository/` ✅ — populated with 15 included modules in Phase 3 (see [Facade Modules Completed](#facade-modules-completed))
638
-
639
- 2. **Eliminate Custom Path Classes**
640
-
641
- Path wrapper classes removed and replaced with `Pathname` objects:
642
-
643
- - `Git::Path` ✅
644
- - `Git::WorkingDirectory` ✅
645
- - `Git::Index` ✅
646
- - `Git::Repository` (the path class) ✅
647
-
648
- `Git::Base` now stores paths as `Pathname` objects directly via
649
- `@working_directory`, `@repository`, and `@index` instance variables.
650
-
651
- 3. **Introduce New Core Classes (Empty Shells)**
652
-
653
- - `Git::ExecutionContext` in `lib/git/execution_context.rb` ✅
654
- - Real base class with `command_capturing`, `command_streaming`, `git_version`
655
- - `Git::ExecutionContext::Repository` subclass in `lib/git/execution_context/repository.rb` ✅
656
- - `Git::ExecutionContext::Global` subclass in `lib/git/execution_context/global.rb` ✅
657
-
658
- - `Git::Repository` in `lib/git/repository.rb` ✅
659
- - Now includes 15 modules via `include` (see [Facade Modules Completed](#facade-modules-completed))
660
-
661
- - `Git::Commands::Arguments` DSL in `lib/git/commands/arguments.rb` ✅
662
- - Provides declarative argument definition for command classes
663
-
664
- 4. **Set Up RSpec Environment**
665
-
666
- RSpec configured and working alongside Test::Unit. Specs live in `spec/` and can be
667
- run with `bundle exec rspec`. ✅
668
-
669
- ## Phase 2: The Strangler Fig Pattern - Migrating Commands
670
-
671
- ***Goal**: Incrementally move the implementation of each git command from `Git::Lib`
672
- to a new `Command` class, strangling the old implementation one piece at a time using
673
- a Test-Driven Development workflow.*
674
-
675
- **Important Note**: During this phase, `Git::Lib` acts as a stand-in for the
676
- `ExecutionContext` hierarchy:
677
-
678
- - `Git::Lib.new(nil, logger)` effectively acts like `ExecutionContext::Global` (no repository
679
- paths set)
680
- - `Git::Lib.new(base, logger)` effectively acts like `ExecutionContext::Repository` (repository
681
- paths set)
682
-
683
- All new `Git::Commands::*` classes should accept any object that responds to
684
- `command` (duck typing), not a specific context class. This allows them to work with
685
- `Git::Lib` during migration and the proper context classes in Phase 3.
686
-
687
- The `command` method provides important functionality including default options
688
- (normalize, chomp, timeout), option validation, and a simplified interface that
689
- returns just stdout. Commands should call `@execution_context.command('subcommand',
690
- *args, **opts)` rather than working with `CommandLine` instances directly.
691
-
692
- ### Key Architectural Insight: Git::Lib as the Adapter Layer
693
-
694
- A fundamental principle of this migration is that `Git::Lib` methods serve as
695
- **adapters** between the legacy public interface and the new `Git::Commands::*`
696
- classes. This separation of concerns provides several benefits:
697
-
698
- 1. **Legacy Interface Acceptance**: `Git::Lib` methods continue to accept the
699
- historical interface—positional arguments, deprecated options, and quirky
700
- parameter names that users have come to rely on.
701
-
702
- 2. **Interface Translation**: The adapter converts legacy patterns to the clean
703
- `Git::Commands::*` API. For example:
704
- - Positional `message` argument → `:message` keyword
705
- - `:no_gpg_sign => true` → `:gpg_sign => false`
706
- - Options hash → keyword arguments via `**options`
707
-
708
- 3. **Deprecation Handling**: Warnings about deprecated options are issued in the
709
- adapter layer, *before* delegating to the command class. This ensures users are
710
- informed even if they're making other errors.
711
-
712
- 4. **Clean Command Classes**: `Git::Commands::*` classes remain free of legacy
713
- baggage. They have a consistent, modern API that:
714
- - Uses keyword arguments with sensible defaults
715
- - Matches the underlying git command's interface closely
716
- - Is easier to test in isolation
717
- - Could potentially be used directly by advanced users
718
-
719
- Example adapter pattern:
720
-
721
- ```ruby
722
- # Git::Lib#commit - the adapter layer
723
- def commit(message, opts = {})
724
- # Legacy: positional message → keyword argument
725
- opts = opts.merge(message: message) if message
726
-
727
- # Legacy: :no_gpg_sign → :gpg_sign => false (with deprecation warning)
728
- if opts[:no_gpg_sign]
729
- Git::Deprecation.warn(':no_gpg_sign option is deprecated...')
730
- raise ArgumentError, '...' if opts.key?(:gpg_sign)
731
- opts.delete(:no_gpg_sign)
732
- opts[:gpg_sign] = false
733
- end
734
-
735
- # Delegate to clean interface
736
- Git::Commands::Commit.new(self).call(**opts)
737
- end
738
- ```
739
-
740
- This pattern makes future cleanup straightforward—once deprecation periods end, the
741
- adapter logic can be simplified or removed entirely.
742
-
743
- **Parameter Design Principle**: Command class `#call` method parameters should
744
- generally match the underlying git command's interface. This keeps the Commands layer
745
- thin and transparent—directly mapping to git documentation. The public facade API
746
- (Git.*, Git::Repository#*) can add convenience features like:
747
-
748
- - Path expansion or normalization
749
- - Ruby-idiomatic defaults
750
- - Parameter validation specific to the Ruby context
751
- - Combining multiple git operations into one public method
752
-
753
- Keep Command parameters matching git closely for simplicity, maintainability, and
754
- easier testing. Allow the public API to diverge when it adds real value, but without
755
- obscuring what's actually happening underneath.
756
-
757
- **Method Signature Convention**: The `#call` signature SHOULD, if possible, use
758
- anonymous repeatable arguments for both positional and keyword arguments:
759
-
760
- ```ruby
761
- # ✅ Preferred: anonymous forwarding with ARGS.bind
762
- # Note: defaults defined in the DSL (e.g., `positional :paths, default: ['.']`)
763
- # are applied automatically by ARGS.bind
764
- def call(*, **)
765
- @execution_context.command('add', *ARGS.bind(*, **))
766
- end
767
-
768
- # ✅ Acceptable: assign bound_args when you need to access argument values
769
- def call(*, **)
770
- bound_args = ARGS.bind(*, **)
771
- output = @execution_context.command('diff', *bound_args).stdout
772
- Parsers::Diff.parse(output, include_dirstat: !bound_args.dirstat.nil?)
773
- end
774
-
775
- # ❌ Incorrect: options hash parameter
776
- def call(paths = '.', options = {})
777
- @execution_context.command('add', *ARGS.bind(*Array(paths), **options))
778
- end
779
- ```
780
-
781
- This convention provides:
782
-
783
- - **Better IDE support**: Editors can autocomplete and validate keyword arguments
784
- - **Clearer method signatures**: The `#call` signature documents available options
785
- - **Centralized validation**: `ARGS.bind` enforces allowed options and raises errors for unknown or invalid keywords
786
- - **Consistency**: All command classes follow the same pattern
787
-
788
- The facade layer (`Git::Lib`, `Git::Base`) may accept either keyword arguments or an
789
- options hash for backward compatibility, but must use `**options` when delegating to
790
- command classes.
791
-
792
- ### Architectural Insights from Command Migrations
793
-
794
- The following insights were discovered during command migrations and should guide
795
- future work:
796
-
797
- 1. **`Data.define` creates frozen objects—no memoization allowed**
798
-
799
- Ruby's `Data.define` creates immutable, frozen objects. This means patterns like
800
- `@cached ||= expensive_computation` will raise `FrozenError`. When using
801
- `Data.define` for value objects, either:
802
- - Accept repeated computation (preferred for simple operations)
803
- - Move caching outside the value object
804
- - Use a regular class with `freeze` called explicitly after initialization
805
-
806
- 2. **Parsing logic duplication is unavoidable when one path needs repository context**
807
-
808
- Value objects like `BranchInfo` cannot create domain objects like `Remote` because
809
- they lack repository context. This leads to seemingly duplicate parsing:
810
-
811
- ```ruby
812
- # Value object (pure, no context)
813
- BranchInfo#short_name # → returns String
814
-
815
- # Domain object (has @base context)
816
- Branch#parse_name # → returns [Remote, String]
817
- ```
818
-
819
- This is **intentional duplication**, not a code smell. Eliminating it would couple
820
- the value object to the repository, defeating its purpose.
821
-
822
- 3. **The command's return type shapes the entire downstream architecture**
823
-
824
- When a command returns primitive types (`Array<Array>`), all consumers need magic
825
- index knowledge. Changing to value objects (`Array<BranchInfo>`) ripples through
826
- every consumer. Plan return types carefully—they define contracts across the
827
- system.
828
-
829
- 4. **Constructor polymorphism enables gradual deprecation**
830
-
831
- When changing a constructor's expected argument type, accept both old and new
832
- types with a deprecation warning for the legacy path:
833
-
834
- ```ruby
835
- def initialize(base, branch_info_or_name)
836
- if branch_info_or_name.is_a?(Git::BranchInfo)
837
- initialize_from_branch_info(branch_info_or_name)
838
- else
839
- Git::Deprecation.warn('...')
840
- initialize_from_name(branch_info_or_name)
841
- end
842
- end
843
- ```
844
-
845
- This allows migrating internal code first while external users continue working.
846
-
847
- 5. **The boundary between "pure data" and "contextualized operations" is the most
848
- important architectural decision**
849
-
850
- Commands should return pure value objects (no repository context needed).
851
- Domain objects wrap those value objects and add operations requiring context.
852
- This single decision determines where parsing lives, what types flow where, and
853
- how the system layers together.
854
-
855
- 6. **Use `flag_or_value_option ..., negatable: true` for options with positive, negative, and value forms**
856
-
857
- When a git option supports `--flag`, `--no-flag`, AND `--flag=value` forms (like
858
- `--track`/`--no-track`/`--track=inherit`), use `flag_or_value_option` with
859
- `negatable: true` instead of defining separate options with conflict declarations.
860
- Under the companion-key model this registers two entries (`:track` and
861
- `:no_track`), each following standard boolean semantics, with an automatic
862
- conflict between them:
863
-
864
- ```ruby
865
- # ✅ Preferred: single declaration registers the companion-key pair
866
- flag_or_value_option :track, negatable: true, inline: true
867
- # track: nil → (omitted)
868
- # track: true → --track
869
- # track: 'inherit' → --track=inherit
870
- # no_track: true → --no-track
871
- # track: false → (omitted; false is always absent)
872
-
873
- # ❌ Avoid: separate definitions require manual conflict management
874
- flag_option :track
875
- flag_option :no_track
876
- conflicts :track, :no_track
877
- ```
878
-
879
- **Validation delegation policy — constraint DSL declarations are not used in
880
- command classes.** The Arguments DSL provides `conflicts`, `requires`,
881
- `requires_one_of`, `requires_exactly_one_of`, `forbid_values`, and
882
- `allowed_values` for declaring inter-option constraints. Command classes
883
- generally do **not** use these declarations. Git is the single source of truth
884
- for its own option semantics. Command classes use per-argument validation
885
- parameters (`required:`, `type:`, `allow_nil:`, etc.) and operand format
886
- validation (option-like operand rejection before `--`). The narrow exception is
887
- arguments that git cannot observe — see the exception policy below.
888
-
889
- **What command classes validate:**
890
-
891
- | Validation | Mechanism | Rationale |
892
- | --- | --- | --- |
893
- | Unknown options | `validate_unsupported_options!` in Arguments DSL | Catches typos/misspellings before spawning a process. Git would also reject these, but the error message would be less clear about the Ruby-side fix needed. |
894
- | Required options | `required: true` in Arguments DSL | Enforces the minimum contract for a command to be meaningful. Avoids spawning a process that will certainly fail. |
895
- | Type checking | `type:` in Arguments DSL | Catches programming errors (e.g., passing an Integer where a String is expected) that would produce confusing git errors or silent coercion. |
896
- | Option-like operand rejection | Automatic for operands before `--` | Security concern: prevents user-supplied strings like `'-s'` from being misinterpreted as git flags. |
897
-
898
- **What command classes do NOT validate (semantic concerns — delegated to git):**
899
-
900
- | Validation | Delegated to | Rationale |
901
- | --- | --- | --- |
902
- | Option conflicts (`--soft` vs `--hard`) | Git (stderr → `Git::FailedError`) | Git is the authority on which options conflict. Constraints drift as git evolves. |
903
- | Option dependencies (`--all-match` requires `--grep`) | Git (stderr or silent behavior) | Same drift risk. Some dependencies are version-specific. |
904
- | At-least-one-of groups | Git (stderr → `Git::FailedError`) | Git enforces its own required-argument semantics. |
905
- | Value-set membership (`--chmod` only accepts `+x`/`-x`) | Git (stderr → `Git::FailedError`) | Git may expand accepted values in future versions. |
906
- | Forbidden value combinations | Git (stderr → `Git::FailedError`) | Specific to git's internal semantics. |
907
-
908
- **Design rationale:**
909
-
910
- 1. **Git is the single source of truth.** Git validates its own option
911
- interactions and reports clear errors via stderr, surfaced as
912
- `Git::FailedError`. Ruby-side constraints duplicate this validation and risk
913
- becoming stale — potentially blocking valid usage when git relaxes a
914
- restriction in a newer version.
915
-
916
- 2. **Partial coverage is worse than none.** Inconsistent constraint coverage
917
- creates a false promise of safety: users can't know whether the absence of
918
- an `ArgumentError` means "this combination is valid" or "this command
919
- doesn't have constraints."
920
-
921
- 3. **Constraint violations are programming errors.** When a developer passes
922
- conflicting options, they must stop and fix their code regardless of whether
923
- the error is `ArgumentError` or `Git::FailedError`. The cost difference is
924
- negligible.
925
-
926
- 4. **Uniform error semantics.** All invalid-option errors surface uniformly as
927
- `Git::FailedError` with git's actual error message, rather than a mix of
928
- `ArgumentError` (Ruby constraint) and `Git::FailedError` (git rejection).
929
-
930
- 5. **The DSL infrastructure remains available.** The constraint methods in
931
- `Git::Commands::Arguments` are kept intact. If a compelling case arises for
932
- a specific constraint (e.g., preventing data loss that git silently allows),
933
- it can be added on a case-by-case basis with documented justification.
934
-
935
- **Exception policy — declare constraints only for arguments git cannot observe:**
936
-
937
- The test: *does this argument appear in git's argv?*
938
- - **Yes** (normal `flag_option`, `value_option`, etc.) → git can observe it and
939
- report the error → do not declare a constraint.
940
- - **No** (`skip_cli: true` arguments, or arguments transformed before reaching
941
- argv) → git has no mechanism to detect incompatibilities → Ruby must enforce
942
- them with a constraint declaration.
943
-
944
- The canonical case is `skip_cli: true` operands routed via stdin. `cat-file
945
- --batch` commands declare both `conflicts :objects, :batch_all_objects` and
946
- `requires_one_of :objects, :batch_all_objects`. `:objects` is `skip_cli: true`
947
- — git never sees it, only `:batch_all_objects` reaches argv. Git cannot detect
948
- that you passed both (silent wrong result: dumps entire object database) or
949
- neither (empty output with exit 0), so Ruby must enforce those constraints.
950
-
951
- A secondary exception: if a combination of **git-visible** arguments causes
952
- git to **silently discard data** (no error, wrong result), a `conflicts`
953
- declaration MAY be added with: a code comment explaining why, a reference to
954
- the git version(s) where the behavior was verified, and a test. As of this
955
- writing, no such case has been identified.
956
-
957
- 7. **Adapter methods should forward all positional arguments, not just options**
958
-
959
- **BUT ONLY IF BACKWARD COMPATIBILITY IS MAINTAINED**
960
-
961
- When `Git::Lib` methods delegate to command classes, ensure the method signature
962
- supports ALL positional arguments the command class accepts:
963
-
964
- ```ruby
965
- # ❌ Wrong: loses start_point positional argument
966
- def branch_new(branch, options = {})
967
- Git::Commands::Branch::Create.new(self).call(branch, **options)
968
- end
969
-
970
- # ✅ Correct: forwards all positional arguments
971
- def branch_new(branch, start_point = nil, options = {})
972
- Git::Commands::Branch::Create.new(self).call(branch, start_point = nil, **options)
973
- end
974
- ```
975
-
976
- Review the command class's `#call` signature when writing the adapter to ensure
977
- no arguments are lost in translation.
978
-
979
- 8. **Arguments are rendered in definition order**
980
-
981
- The Arguments DSL outputs arguments in the exact order they are defined,
982
- regardless of type. This allows precise control over argument positioning,
983
- which is important for commands like `git checkout` where `--` must appear
984
- between options and pathspecs only when pathspecs are present:
985
-
986
- ```ruby
987
- # Arguments render in definition order; end_of_options emits '--' only when
988
- # at least one following operand produces output
989
- ARGS = Arguments.define do
990
- flag_option :force
991
- operand :tree_ish
992
- end_of_options
993
- operand :paths, repeatable: true
994
- end
995
- # bind('HEAD', 'file.txt', force: true) => ['--force', 'HEAD', '--', 'file.txt']
996
- # bind('HEAD', force: true) => ['--force', 'HEAD'] (no trailing --)
997
-
998
- # Common pattern: static flags first for subcommands like branch --delete
999
- ARGS = Arguments.define do
1000
- literal '--delete'
1001
- flag_option %i[force f], args: '--force'
1002
- operand :branch_names, repeatable: true, required: true
1003
- end
1004
- # build('feature', force: true) => ['--delete', '--force', 'feature']
1005
- ```
1006
-
1007
- 9. **Use `%i[long short]` array syntax for flag aliases**
1008
-
1009
- When defining flags with short aliases, use the `%i[]` symbol array syntax with
1010
- the long (canonical) name first. This provides a clean, consistent pattern:
1011
-
1012
- ```ruby
1013
- flag_option %i[force f], args: '--force' # force: true OR f: true
1014
- flag_option %i[remotes r], args: '--remotes' # remotes: true OR r: true
1015
- flag_option %i[quiet q], args: '--quiet' # quiet: true OR q: true
1016
- ```
1017
-
1018
- The first symbol becomes the primary name used in documentation and error
1019
- messages; subsequent symbols are aliases.
1020
-
1021
- 10. **Consider repeatable support in adapter methods when command supports it**
1022
-
1023
- When a command class supports repeatable positional arguments (e.g., deleting
1024
- multiple branches), consider whether the `Git::Lib` adapter should expose this
1025
- capability:
1026
-
1027
- ```ruby
1028
- # Command class supports multiple branches
1029
- def call(*, **) # repeatable positional
1030
- @execution_context.command('branch', *ARGS.bind(*, **))
1031
- end
1032
-
1033
- # ❌ Adapter only accepts single branch
1034
- def branch_delete(branch, options = {})
1035
- Git::Commands::Branch::Delete.new(self).call(branch, **options)
1036
- end
1037
-
1038
- # ✅ Adapter exposes repeatable capability
1039
- def branch_delete(*branches, **options)
1040
- options = { force: true }.merge(options)
1041
- Git::Commands::Branch::Delete.new(self).call(*branches, **options)
1042
- end
1043
- ```
1044
-
1045
- This allows callers to delete multiple branches efficiently in one git command.
1046
-
1047
- 11. **Use `def call(*, **)` when Arguments DSL handles all validation**
1048
-
1049
- When using the Arguments DSL with patterns where optional positionals precede
1050
- required ones (matching Ruby's parameter binding semantics), prefer the
1051
- catch-all signature `def call(*, **)` and let `ARGS.bind(*, **)` handle
1052
- all validation.
1053
-
1054
- Note: `ARGS.bind` validates per-argument parameters (unknown options,
1055
- `required:`, `type:`, `allow_nil:`, and operand format) and also evaluates
1056
- any declared cross-argument constraints (`conflicts`, `requires`,
1057
- `requires_one_of`, `requires_exactly_one_of`, `forbid_values`, `allowed_values`).
1058
- Command classes generally do not declare cross-argument constraints (see Insight
1059
- 6 validation delegation policy) — inter-option constraint enforcement is
1060
- delegated to git, with the exception of `skip_cli: true` arguments that never
1061
- reach git's argv (see the `cat-file --batch` example above).
1062
-
1063
- ```ruby
1064
- # git branch -m [<old-branch>] <new-branch>
1065
- ARGS = Arguments.define do
1066
- literal '--move'
1067
- flag_option :force
1068
- operand :old_branch # optional (no required: true)
1069
- operand :new_branch, required: true # required
1070
- end.freeze
1071
-
1072
- # ✅ Preferred: let ARGS.bind handle validation
1073
- def call(*, **)
1074
- @execution_context.command('branch', *ARGS.bind(*, **))
1075
- end
1076
-
1077
- # ❌ Avoid: explicit params trigger RuboCop Style/OptionalArguments
1078
- def call(old_branch = nil, new_branch, **)
1079
- # ...
1080
- end
1081
- ```
1082
-
1083
- The Arguments DSL with Ruby-like positional allocation correctly fills
1084
- required parameters before optional ones, so `move.call('new-name')` works
1085
- as expected.
1086
-
1087
- 12. **Arguments DSL supports Ruby-like positional parameter allocation**
1088
-
1089
- The `PositionalAllocator` in the Arguments DSL follows Ruby's method parameter
1090
- binding semantics. When optional positionals precede required ones, values are
1091
- allocated to required parameters first:
1092
-
1093
- ```ruby
1094
- # Ruby method: def foo(a = 'default', b); end
1095
- # foo('value') → a='default', b='value' (required b filled first)
1096
-
1097
- # Arguments DSL equivalent:
1098
- operand :old_branch # optional
1099
- operand :new_branch, required: true # required
1100
-
1101
- # Single value: ARGS.bind('new-name')
1102
- # → old_branch=nil, new_branch='new-name'
1103
-
1104
- # Two values: ARGS.bind('old-name', 'new-name')
1105
- # → old_branch='old-name', new_branch='new-name'
1106
- ```
1107
-
1108
- This enables command interfaces that match git CLI patterns like
1109
- `git branch -m [<old-branch>] <new-branch>` without awkward workarounds.
1110
-
1111
- 13. **Commands layer maps option semantics, not argument ergonomics**
1112
-
1113
- The Commands layer should strictly mirror git CLI semantics. When git uses
1114
- `--option=value` syntax, the Commands class should use a keyword argument—even
1115
- if a positional would feel more natural in Ruby:
1116
-
1117
- ```ruby
1118
- # Git CLI: git branch --set-upstream-to=<upstream> [<branch>]
1119
- # ↑ <upstream> is the VALUE of --set-upstream-to option, not a positional
1120
-
1121
- # ✅ Commands layer: strict CLI mapping
1122
- class SetUpstream
1123
- ARGS = Arguments.define do
1124
- value_option :set_upstream_to, inline: true # keyword, not positional
1125
- operand :branch_name
1126
- end
1127
-
1128
- def call(*, **)
1129
- @execution_context.command('branch', *ARGS.bind(*, **))
1130
- end
1131
- end
1132
-
1133
- # ✅ Higher-layer facade: ergonomic Ruby API (Phase 3)
1134
- # This wrapper belongs in Git::Repository or Git::Branch, NOT in Git::Lib.
1135
- # Git::Lib only adapts methods that existed in v4.3.0.
1136
- def branch_set_upstream(upstream, branch_name = nil)
1137
- SetUpstream.new(@execution_context).call(branch_name, set_upstream_to: upstream)
1138
- end
1139
- ```
1140
-
1141
- This separation keeps Commands classes predictable (they mirror git 1:1) while
1142
- allowing higher layers to provide intuitive Ruby interfaces. Ergonomic
1143
- transformations—like reordering arguments or converting keywords to
1144
- positionals—belong in higher layers (`Git::Repository`, `Git::Base`, `Git::Branch`),
1145
- not in `Git::Lib` (which only adapts pre-existing methods for backward compatibility).
1146
-
1147
- 14. **Use `allow_nil: true` for positional arguments that can be intentionally omitted**
1148
-
1149
- Some git commands have positional arguments that are semantically present but
1150
- should not appear in the command line. For example, `git checkout -- file.txt`
1151
- restores from the index (no tree-ish), while `git checkout HEAD -- file.txt`
1152
- restores from a commit.
1153
-
1154
- Use `allow_nil: true` to mark a positional that can accept `nil` as a valid
1155
- "present but empty" value:
1156
-
1157
- ```ruby
1158
- ARGS = Arguments.define do
1159
- operand :tree_ish, required: true, allow_nil: true
1160
- end_of_options
1161
- operand :paths, repeatable: true
1162
- end
1163
-
1164
- # Restore from index (tree_ish intentionally nil)
1165
- ARGS.bind(nil, 'file.txt')
1166
- # → ['--', 'file.txt']
1167
-
1168
- # Restore from commit
1169
- ARGS.bind('HEAD', 'file.txt')
1170
- # → ['HEAD', '--', 'file.txt']
1171
- ```
1172
-
1173
- Without `allow_nil: true`, passing `nil` would either skip the positional slot
1174
- (causing argument misalignment) or raise a validation error for required
1175
- arguments.
1176
-
1177
- 15. **Namespace commands by mode, not just by operation**
1178
-
1179
- When a git command has fundamentally different modes (not just different
1180
- operations on the same concept), use nested namespaces that reflect the mode:
1181
-
1182
- ```ruby
1183
- # ✅ Different modes of git checkout → separate namespaces
1184
- Git::Commands::Checkout::Branch # branch switching, creation
1185
- Git::Commands::Checkout::Files # file restoration from tree-ish/index
1186
-
1187
- # ✅ Different operations on same concept → flat namespace with operation suffix
1188
- Git::Commands::Branch::Create
1189
- Git::Commands::Branch::Delete
1190
- Git::Commands::Branch::Move
1191
- ```
1192
-
1193
- The distinction: `Checkout::Branch` and `Checkout::Files` accept fundamentally
1194
- different arguments and have different semantics. `Branch::Create` and
1195
- `Branch::Delete` operate on the same conceptual entity (a branch) with the same
1196
- core argument (branch name).
1197
-
1198
- 16. **Subclass by operation, not output mode; `literal` is for operation selectors only**
1199
-
1200
- Early command migrations created output-mode subclasses (`Diff::Patch`,
1201
- `Diff::Numstat`, `Diff::Raw`, `Stash::ShowPatch`, etc.) that hardcoded format
1202
- flags as `literal` entries. This was an anti-pattern: those subclasses were
1203
- differentiated only by which output format they requested, not by which git
1204
- operation they performed. The result was that every format change required a
1205
- new class, the facade had to choose between them by type, and the parser
1206
- contract was invisible.
1207
-
1208
- **Correct subclass criterion:** Create a subclass (or a separate class in a
1209
- namespace) only when the git operation itself differs — e.g.,
1210
- `Branch::Create` vs `Branch::Delete` (different `--delete` flag makes them
1211
- different operations). Do **not** create subclasses for the same operation
1212
- with different `--format`, `--patch`, `--numstat`, `--raw`, etc. flags.
1213
-
1214
- **Correct `literal` criterion:** A `literal` entry is justified only when it
1215
- is an operation selector that defines what the class does — e.g.,
1216
- `literal 'stash'` and `literal 'show'` in `Stash::Show`, or
1217
- `literal '--delete'` in `Branch::Delete`. Output-mode flags (`--patch`,
1218
- `--numstat`, `--raw`, `--no-color`, `--format=…`) are never operation
1219
- selectors; they are options the facade passes to fulfill its own parsing or
1220
- display requirements.
1221
-
1222
- **Correct option placement:** Output-mode flags and parser-contract options
1223
- belong at the facade call site, not inside the command class as `literal`
1224
- entries. Declare them with `flag_option` or `value_option` in the DSL so the
1225
- facade can pass them explicitly:
1226
-
1227
- ```ruby
1228
- # ❌ Anti-pattern: output mode hardcoded as literal
1229
- class Diff::Patch < Git::Commands::Base
1230
- arguments do
1231
- literal 'diff'
1232
- literal '--patch' # ← hides the parser contract; wrong layer
1233
- ...
1234
- end
1235
- end
1236
-
1237
- # ✅ Correct: single class; facade controls output mode
1238
- class Diff < Git::Commands::Base
1239
- arguments do
1240
- literal 'diff'
1241
- flag_option :patch # facade passes patch: true when it needs patch output
1242
- flag_option :numstat # facade passes numstat: true when it needs numstat
1243
- flag_option :raw # facade passes raw: true when it needs raw output
1244
- ...
1245
- end
1246
- end
1247
-
1248
- # lib/git/lib.rb — parser contract is now explicit and auditable:
1249
- Git::Commands::Diff.new(self).call(patch: true, numstat: true, ...)
1250
- ```
1251
-
1252
- **Known anti-patterns (now fixed):** `Git::Commands::Diff::Patch`,
1253
- `Git::Commands::Diff::Numstat`, `Git::Commands::Diff::Raw`,
1254
- `Git::Commands::Stash::ShowPatch`, `Git::Commands::Stash::ShowNumstat`,
1255
- `Git::Commands::Stash::ShowRaw` — all collapsed in this refactor.
1256
- Additionally, `literal '--no-color'` in `Log` and `Grep`, and
1257
- `literal "--format=…"` in `Branch::List` and `Tag::List` were moved to
1258
- their respective facade call sites.
1259
-
1260
- 17. **Command classes are neutral; the facade owns policy**
1261
-
1262
- Command classes are faithful, neutral representations of the git CLI. They
1263
- never hardcode `literal` entries for output-control, editor-suppression, or
1264
- progress flags. The facade (`Git::Lib`) sets safe defaults at each call site
1265
- (e.g. `edit: false`, `progress: false`); callers may override when needed.
1266
- The execution layer (`GIT_EDITOR='true'`) is an unconditional safety net.
1267
-
1268
- ```ruby
1269
- # ❌ Anti-pattern: policy embedded in command class
1270
- class Pull < Git::Commands::Base
1271
- arguments do
1272
- literal 'pull'
1273
- literal '--no-edit' # ← wrong layer
1274
- literal '--no-progress' # ← same problem
1275
- end
1276
- end
1277
-
1278
- # ✅ Correct: command is neutral; facade passes policy options
1279
- class Pull < Git::Commands::Base
1280
- arguments do
1281
- literal 'pull'
1282
- flag_option :edit, negatable: true
1283
- flag_option :progress, negatable: true
1284
- end
1285
- end
1286
-
1287
- # lib/git/lib.rb — facade sets safe defaults:
1288
- Git::Commands::Pull.new(self).call(edit: false, progress: false)
1289
- ```
1290
-
1291
- See "Command-layer neutrality" in CONTRIBUTING.md for the full policy.
1292
-
1293
- - **1. Migrate the First Command (`add`)**:
1294
-
1295
- - **Write Unit Tests First**: Write comprehensive RSpec unit tests for the
1296
- *proposed* `Git::Commands::Add` class. These tests will fail initially because
1297
- the class doesn't exist yet. The tests should be fast and mock an object with a
1298
- `command` method that returns stdout strings.
1299
-
1300
- - **Create Command Class**: Implement `Git::Commands::Add` to make the tests pass.
1301
- This class will contain all the logic for building git add arguments and parsing
1302
- its output. It will accept an execution context (any object responding to
1303
- `command`) in its constructor and call `@execution_context.command('add', *args,
1304
- **opts)` to execute commands.
1305
-
1306
- - **Delegate from `Git::Lib`**: Modify the `add` method within the existing
1307
- `Git::Lib` class. Instead of containing the implementation, it will now
1308
- instantiate and call the new `Git::Commands::Add` object, passing `self` as the
1309
- context.
1310
-
1311
- - **Verify**: Run the full test suite (both Test::Unit and RSpec). The existing tests
1312
- for `g.add` should still pass, but they will now be executing the new, refactored
1313
- code.
1314
-
1315
- - **2. Incrementally Migrate Remaining Commands:**
1316
-
1317
- - Repeat the process from the previous step for all other commands, one by one or
1318
- in logical groups (e.g., all `diff` related commands, then all `log` commands).
1319
-
1320
- - For each command (`add`, `commit`, `log`, `diff`, `status`, etc.):
1321
-
1322
- 1. Create the corresponding Git::Commands::* class.
1323
-
1324
- 2. Write isolated RSpec unit tests for the new class.
1325
-
1326
- 3. Change the method in Git::Lib to delegate to the new command object.
1327
-
1328
- 4. Run the full test suite to ensure no regressions have been introduced.
1329
-
1330
- ### Command Migration Checklist
1331
-
1332
- The following tracks the migration status of commands from `Git::Lib` to
1333
- `Git::Commands::*` classes.
1334
-
1335
- **Reference implementations** (use these as templates):
1336
-
1337
- - Simple command: `lib/git/commands/add.rb` + `spec/unit/git/commands/add_spec.rb`
1338
- - Command with output parsing: `lib/git/commands/fsck.rb` +
1339
- `spec/unit/git/commands/fsck_spec.rb`
1340
- - Command with complex options: `lib/git/commands/clone.rb` +
1341
- `spec/unit/git/commands/clone_spec.rb`
1342
-
1343
- #### ✅ Migrated Commands
1344
-
1345
- | Git::Lib Method | Command Class | Spec | Git Command |
1346
- | --------------- | ------------- | ---- | ----------- |
1347
- | `add` | `Git::Commands::Add` | `spec/unit/git/commands/add_spec.rb` | `git add` |
1348
- | `clone` | `Git::Commands::Clone` | `spec/unit/git/commands/clone_spec.rb` | `git clone` |
1349
- | `commit` | `Git::Commands::Commit` | `spec/unit/git/commands/commit_spec.rb` | `git commit` |
1350
- | `fsck` | `Git::Commands::Fsck` | `spec/unit/git/commands/fsck_spec.rb` | `git fsck` |
1351
- | `init` | `Git::Commands::Init` | `spec/unit/git/commands/init_spec.rb` | `git init` |
1352
- | `mv` | `Git::Commands::Mv` | `spec/unit/git/commands/mv_spec.rb` | `git mv` |
1353
- | `reset` | `Git::Commands::Reset` | `spec/unit/git/commands/reset_spec.rb` | `git reset` |
1354
- | `rm` | `Git::Commands::Rm` | `spec/unit/git/commands/rm_spec.rb` | `git rm` |
1355
- | `clean` | `Git::Commands::Clean` | `spec/unit/git/commands/clean_spec.rb` | `git clean` |
1356
- | `branches_all` | `Git::Commands::Branch::List` | `spec/unit/git/commands/branch/list_spec.rb` | `git branch --list` |
1357
- | `branch_new` | `Git::Commands::Branch::Create` | `spec/unit/git/commands/branch/create_spec.rb` | `git branch <name>` |
1358
- | `branch_delete` | `Git::Commands::Branch::Delete` | `spec/unit/git/commands/branch/delete_spec.rb` | `git branch --delete <branch>` |
1359
- | N/A (new) | `Git::Commands::Branch::Move` | `spec/unit/git/commands/branch/move_spec.rb` | `git branch --move <old-name> <new-name>` |
1360
- | `branch_current` | `Git::Commands::Branch::ShowCurrent` | `spec/unit/git/commands/branch/show_current_spec.rb` | `git branch --show-current` |
1361
- | N/A (new) | `Git::Commands::Branch::Copy` | `spec/unit/git/commands/branch/copy_spec.rb` | `git branch --copy <old-name> <new-name>` |
1362
- | N/A (new) | `Git::Commands::Branch::SetUpstream` | `spec/unit/git/commands/branch/set_upstream_spec.rb` | `git branch --set-upstream-to <upstream> [<branch>]` |
1363
- | N/A (new) | `Git::Commands::Branch::UnsetUpstream` | `spec/unit/git/commands/branch/unset_upstream_spec.rb` | `git branch --unset-upstream [<branch>]` |
1364
- | `diff_full` / `diff_stats` / `diff_path_status` / `diff_index` | `Git::Commands::Diff` | `spec/unit/git/commands/diff_spec.rb` | `git diff` |
1365
- | `stashes_list` | `Git::Commands::Stash::List` | `spec/unit/git/commands/stash/list_spec.rb` | `git stash list` |
1366
- | `stash_save` | `Git::Commands::Stash::Push` | `spec/unit/git/commands/stash/push_spec.rb` | `git stash push` |
1367
- | `stash_pop` | `Git::Commands::Stash::Pop` | `spec/unit/git/commands/stash/pop_spec.rb` | `git stash pop` |
1368
- | `stash_apply` | `Git::Commands::Stash::Apply` | `spec/unit/git/commands/stash/apply_spec.rb` | `git stash apply` |
1369
- | `stash_drop` | `Git::Commands::Stash::Drop` | `spec/unit/git/commands/stash/drop_spec.rb` | `git stash drop` |
1370
- | `stash_clear` | `Git::Commands::Stash::Clear` | `spec/unit/git/commands/stash/clear_spec.rb` | `git stash clear` |
1371
- | `checkout` / `checkout_file` | `Git::Commands::Checkout::Branch` / `Git::Commands::Checkout::Files` | `spec/unit/git/commands/checkout/branch_spec.rb` / `spec/unit/git/commands/checkout/files_spec.rb` | `git checkout` (branch) / `git checkout` (files) |
1372
- | `merge` | `Git::Commands::Merge::Start` | `spec/unit/git/commands/merge/start_spec.rb` | `git merge` |
1373
- | `tag` | `Git::Commands::Tag::*` | `spec/unit/git/commands/tag/*_spec.rb` | `git tag` |
1374
- | N/A (new) | `Git::Commands::Merge::Abort` | `spec/unit/git/commands/merge/abort_spec.rb` | `git merge --abort` |
1375
- | N/A (new) | `Git::Commands::Merge::Continue` | `spec/unit/git/commands/merge/continue_spec.rb` | `git merge --continue` |
1376
- | N/A (new) | `Git::Commands::Merge::Quit` | `spec/unit/git/commands/merge/quit_spec.rb` | `git merge --quit` |
1377
- | `merge_base` | `Git::Commands::MergeBase` | `spec/unit/git/commands/merge_base_spec.rb` | `git merge-base <commit> <commit>...` |
1378
- | N/A (new) | `Git::Commands::Stash::Create` | `spec/unit/git/commands/stash/create_spec.rb` | `git stash create` |
1379
- | N/A (new) | `Git::Commands::Stash::Store` | `spec/unit/git/commands/stash/store_spec.rb` | `git stash store` |
1380
- | N/A (new) | `Git::Commands::Stash::Branch` | `spec/unit/git/commands/stash/branch_spec.rb` | `git stash branch` |
1381
- | N/A (new) | `Git::Commands::Stash::Show` | `spec/unit/git/commands/stash/show_spec.rb` | `git stash show` |
1382
- | `cat_file_*` | `Git::Commands::CatFile::*` | `spec/unit/git/commands/cat_file/*_spec.rb` | `git cat-file` |
1383
- | `checkout_index` | `Git::Commands::CheckoutIndex` | `spec/unit/git/commands/checkout_index_spec.rb` | `git checkout-index` |
1384
- | `archive` | `Git::Commands::Archive` | `spec/unit/git/commands/archive_spec.rb` | `git archive` |
1385
- | `grep` | `Git::Commands::Grep` | `spec/unit/git/commands/grep_spec.rb` | `git grep` |
1386
- | `log_commits` / `full_log_commits` | `Git::Commands::Log` | `spec/unit/git/commands/log_spec.rb` | `git log` |
1387
- | `show` | `Git::Commands::Show` | `spec/unit/git/commands/show_spec.rb` | `git show` |
1388
- | `describe` | `Git::Commands::Describe` | `spec/unit/git/commands/describe_spec.rb` | `git describe` |
1389
- | `ls_files` | `Git::Commands::LsFiles` | `spec/unit/git/commands/ls_files_spec.rb` | `git ls-files` |
1390
- | `ls_tree` / `full_tree` / `tree_depth` | `Git::Commands::LsTree` | `spec/unit/git/commands/ls_tree_spec.rb` | `git ls-tree` |
1391
- | `fetch` | `Git::Commands::Fetch` | `spec/unit/git/commands/fetch_spec.rb` | `git fetch` |
1392
- | `pull` | `Git::Commands::Pull` | `spec/unit/git/commands/pull_spec.rb` | `git pull` |
1393
- | `push` | `Git::Commands::Push` | `spec/unit/git/commands/push_spec.rb` | `git push` |
1394
- | `ls_remote` / `repository_default_branch` | `Git::Commands::LsRemote` | `spec/unit/git/commands/ls_remote_spec.rb` | `git ls-remote` |
1395
- | `unmerged` | `Git::Commands::Diff` (existing) | — | `git diff --cached` |
1396
- | N/A (index refresh for `diff_files`/`diff_index`) | `Git::Commands::Status` | `spec/unit/git/commands/status_spec.rb` | `git status` |
1397
- | N/A (ref listing namespace) | `Git::Commands::ShowRef::List` | `spec/unit/git/commands/show_ref/list_spec.rb` | `git show-ref` |
1398
- | N/A (ref verification namespace) | `Git::Commands::ShowRef::Verify` | `spec/unit/git/commands/show_ref/verify_spec.rb` | `git show-ref --verify` |
1399
- | N/A (stdin filter namespace) | `Git::Commands::ShowRef::ExcludeExisting` | `spec/unit/git/commands/show_ref/exclude_existing_spec.rb` | `git show-ref --exclude-existing` |
1400
- | N/A (existence check namespace) | `Git::Commands::ShowRef::Exists` | `spec/unit/git/commands/show_ref/exists_spec.rb` | `git show-ref --exists` |
1401
- | `tag_sha` | `Git::Commands::ShowRef::List` | `spec/unit/git/lib_command_spec.rb` | `git show-ref --tags --hash` |
1402
- | `apply` | `Git::Commands::Apply` | `spec/unit/git/commands/apply_spec.rb` | `git apply` |
1403
- | `apply_mail` | `Git::Commands::Am::Apply` | `spec/unit/git/commands/am/apply_spec.rb` | `git am` |
1404
- | N/A (new) | `Git::Commands::Am::Abort` | `spec/unit/git/commands/am/abort_spec.rb` | `git am --abort` |
1405
- | N/A (new) | `Git::Commands::Am::Continue` | `spec/unit/git/commands/am/continue_spec.rb` | `git am --continue` |
1406
- | N/A (new) | `Git::Commands::Am::Skip` | `spec/unit/git/commands/am/skip_spec.rb` | `git am --skip` |
1407
- | N/A (new) | `Git::Commands::Am::Quit` | `spec/unit/git/commands/am/quit_spec.rb` | `git am --quit` |
1408
- | N/A (new) | `Git::Commands::Am::Retry` | `spec/unit/git/commands/am/retry_spec.rb` | `git am --retry` |
1409
- | N/A (new) | `Git::Commands::Am::ShowCurrentPatch` | `spec/unit/git/commands/am/show_current_patch_spec.rb` | `git am --show-current-patch` |
1410
- | `name_rev` | `Git::Commands::NameRev` | `spec/unit/git/commands/name_rev_spec.rb` | `git name-rev` |
1411
- | `commit_tree` | `Git::Commands::CommitTree` | `spec/unit/git/commands/commit_tree_spec.rb` | `git commit-tree` |
1412
- | `update_ref` | `Git::Commands::UpdateRef::Update` | `spec/unit/git/commands/update_ref/update_spec.rb` | `git update-ref` |
1413
- | N/A (new) | `Git::Commands::UpdateRef::Delete` | `spec/unit/git/commands/update_ref/delete_spec.rb` | `git update-ref -d` |
1414
- | N/A (new) | `Git::Commands::UpdateRef::Batch` | `spec/unit/git/commands/update_ref/batch_spec.rb` | `git update-ref --stdin` |
1415
- | `gc` | `Git::Commands::Gc` | `spec/unit/git/commands/gc_spec.rb` | `git gc` |
1416
- | `repack` | `Git::Commands::Repack` | `spec/unit/git/commands/repack_spec.rb` | `git repack` |
1417
- | `config_get` / `global_config_get` | `Git::Commands::ConfigOptionSyntax::Get` | `spec/unit/git/commands/config_option_syntax/get_spec.rb` | `git config --get` |
1418
- | `config_list` / `global_config_list` / `parse_config` | `Git::Commands::ConfigOptionSyntax::List` | `spec/unit/git/commands/config_option_syntax/list_spec.rb` | `git config --list` |
1419
- | `config_set` / `global_config_set` | `Git::Commands::ConfigOptionSyntax::Set` | `spec/unit/git/commands/config_option_syntax/set_spec.rb` | `git config` (set value) |
1420
- | N/A (new) | `Git::Commands::ConfigOptionSyntax::Add` | `spec/unit/git/commands/config_option_syntax/add_spec.rb` | `git config --add` |
1421
- | N/A (new) | `Git::Commands::ConfigOptionSyntax::GetAll` | `spec/unit/git/commands/config_option_syntax/get_all_spec.rb` | `git config --get-all` |
1422
- | N/A (new) | `Git::Commands::ConfigOptionSyntax::GetColor` | `spec/unit/git/commands/config_option_syntax/get_color_spec.rb` | `git config --get-color` |
1423
- | N/A (new) | `Git::Commands::ConfigOptionSyntax::GetColorBool` | `spec/unit/git/commands/config_option_syntax/get_color_bool_spec.rb`, `spec/integration/git/commands/config_option_syntax/get_color_bool_spec.rb` | `git config --get-colorbool` |
1424
- | N/A (new) | `Git::Commands::ConfigOptionSyntax::GetRegexp` | `spec/unit/git/commands/config_option_syntax/get_regexp_spec.rb` | `git config --get-regexp` |
1425
- | N/A (new) | `Git::Commands::ConfigOptionSyntax::GetUrlmatch` | `spec/unit/git/commands/config_option_syntax/get_urlmatch_spec.rb` | `git config --get-urlmatch` |
1426
- | N/A (new) | `Git::Commands::ConfigOptionSyntax::RemoveSection` | `spec/unit/git/commands/config_option_syntax/remove_section_spec.rb` | `git config --remove-section` |
1427
- | N/A (new) | `Git::Commands::ConfigOptionSyntax::RenameSection` | `spec/unit/git/commands/config_option_syntax/rename_section_spec.rb` | `git config --rename-section` |
1428
- | N/A (new) | `Git::Commands::ConfigOptionSyntax::ReplaceAll` | `spec/unit/git/commands/config_option_syntax/replace_all_spec.rb` | `git config --replace-all` |
1429
- | N/A (new) | `Git::Commands::ConfigOptionSyntax::Unset` | `spec/unit/git/commands/config_option_syntax/unset_spec.rb` | `git config --unset` |
1430
- | N/A (new) | `Git::Commands::ConfigOptionSyntax::UnsetAll` | `spec/unit/git/commands/config_option_syntax/unset_all_spec.rb` | `git config --unset-all` |
1431
-
1432
- | `worktrees_all` / `worktree_add` / `worktree_remove` / `worktree_prune` | `Git::Commands::Worktree::List` / `Git::Commands::Worktree::Add` / `Git::Commands::Worktree::Remove` / `Git::Commands::Worktree::Prune` (+ `Lock`, `Unlock`, `Move`, `Repair`) | `spec/unit/git/commands/worktree/*_spec.rb` | `git worktree` |
1433
- | `change_head_branch` | `Git::Commands::SymbolicRef::Update` (+ `Read`, `Delete`) | `spec/unit/git/commands/symbolic_ref/*_spec.rb` | `git symbolic-ref` |
1434
- | `current_command_version` | `Git::Commands::Version` | `spec/unit/git/commands/version_spec.rb` | `git version` |
1435
- | `diff_as_hash` (private) | `Git::Commands::DiffFiles` / `Git::Commands::DiffIndex` | `spec/unit/git/commands/diff_files_spec.rb` / `spec/unit/git/commands/diff_index_spec.rb` | `git diff-files` / `git diff-index` |
1436
- | `remote_add` / `remote_remove` / `remote_set_url` / `remote_set_branches` | `Git::Commands::Remote::*` | `spec/unit/git/commands/remote/*_spec.rb` | `git remote` |
1437
- | `revert` | `Git::Commands::Revert::*` | `spec/unit/git/commands/revert/*_spec.rb` | `git revert` |
1438
- | `rev_parse` | `Git::Commands::RevParse` | `spec/unit/git/commands/rev_parse_spec.rb` | `git rev-parse` |
1439
- | `read_tree` | `Git::Commands::ReadTree` | `spec/unit/git/commands/read_tree_spec.rb` | `git read-tree` |
1440
- | `write_tree` | `Git::Commands::WriteTree` | `spec/unit/git/commands/write_tree_spec.rb` | `git write-tree` |
1441
- | N/A (new) | `Git::Commands::Maintenance::*` | `spec/unit/git/commands/maintenance/*_spec.rb` ⚠️ missing — needs specs | `git maintenance` |
1442
-
1443
- #### ⏳ Commands To Migrate
1444
-
1445
- Commands are listed in recommended migration order within each group. Migrate in
1446
- order: Basic Snapshotting → Branching & Merging → etc.
1447
-
1448
- **Basic Snapshotting**:
1449
-
1450
- - [x] `rm` → `Git::Commands::Rm` — `git rm`
1451
- - [x] `mv` → `Git::Commands::Mv` — `git mv`
1452
- - [x] `commit` → `Git::Commands::Commit` — `git commit`
1453
- - [x] `reset` → `Git::Commands::Reset` — `git reset`
1454
- - [x] `clean` → `Git::Commands::Clean` — `git clean`
1455
-
1456
- **Branching & Merging:**
1457
-
1458
- - [x] `branches_all` → `Git::Commands::Branch::List` — `git branch --list` (returns `BranchInfo` value objects)
1459
- - [x] `branch_new` → `Git::Commands::Branch::Create` — `git branch <name> [start-point]`
1460
- - [x] `branch_delete` → `Git::Commands::Branch::Delete` — `git branch --delete <branch>`
1461
- - [x] N/A (new) → `Git::Commands::Branch::Move` — `git branch --move <old-name> <new-name>`
1462
- - [x] `branch_current` → `Git::Commands::Branch::ShowCurrent` — `git branch --show-current`
1463
- - [x] N/A (new) → `Git::Commands::Branch::Copy` — `git branch --copy <old-name> <new-name>`
1464
- - [x] N/A (new) → `Git::Commands::Branch::SetUpstream` — `git branch --set-upstream-to <upstream> [<branch>]`
1465
- - [x] N/A (new) → `Git::Commands::Branch::UnsetUpstream` — `git branch --unset-upstream [<branch>]`
1466
- - [x] `merge_base` → `Git::Commands::MergeBase` — `git merge-base <commit> <commit>...`
1467
- - [x] `checkout` / `checkout_file` → `Git::Commands::Checkout::Branch` / `Git::Commands::Checkout::Files` — `git checkout`
1468
- - [x] `merge` → `Git::Commands::Merge::Start` — `git merge`
1469
- - [x] N/A (new) → `Git::Commands::Merge::Abort` / `Git::Commands::Merge::Continue` / `Git::Commands::Merge::Quit` — `git merge --abort/--continue/--quit`
1470
- - [x] `tag` → `Git::Commands::Tag::*` — `git tag` (implemented as `List`, `Create`, `Delete`, and `Verify`)
1471
- - [x] `stash_*` → `Git::Commands::Stash::*` — `git stash` (List, Push, Pop, Apply, Drop, Clear, Create, Store, Branch, Show)
1472
-
1473
- **Inspection & Comparison:**
1474
-
1475
- - [x] `log_commits` / `full_log_commits` → `Git::Commands::Log` — `git log`
1476
- - [x] `diff_full` / `diff_stats` / `diff_path_status` / `diff_index` →
1477
- `Git::Commands::Diff` — `git diff`
1478
- - [x] `unmerged` → (use existing `Git::Commands::Diff` class) — `git diff`
1479
- (one unmigrated call site in `Git::Lib#unmerged`; command class already exists)
1480
- - [x] `diff_as_hash` (private) → `Git::Commands::DiffFiles` / `Git::Commands::DiffIndex`
1481
- — `git diff-files` / `git diff-index`
1482
- - [x] `status` → `Git::Commands::Status` — `git status`
1483
- - [x] `tag_sha` (uses `show-ref` internally) → `Git::Commands::ShowRef::List` — `git show-ref`
1484
- - [x] `show` → `Git::Commands::Show` — `git show`
1485
- - [x] `describe` → `Git::Commands::Describe` — `git describe`
1486
- - [x] `grep` → `Git::Commands::Grep` — `git grep`
1487
- - [x] `ls_files` → `Git::Commands::LsFiles` — `git ls-files`
1488
- - [x] `ls_tree` / `full_tree` / `tree_depth` → `Git::Commands::LsTree` — `git ls-tree`
1489
-
1490
- **Sharing & Updating:**
1491
-
1492
- - [x] `fetch` → `Git::Commands::Fetch` — `git fetch`
1493
- - [x] `pull` → `Git::Commands::Pull` — `git pull`
1494
- - [x] `push` → `Git::Commands::Push` — `git push`
1495
- - [x] `remote_add` / `remote_remove` / `remote_set_url` / `remote_set_branches` →
1496
- `Git::Commands::Remote` — `git remote`
1497
- - [x] `ls_remote` / `repository_default_branch` → `Git::Commands::LsRemote` — `git ls-remote`
1498
-
1499
- **Patching:**
1500
-
1501
- - [x] `apply` / `apply_mail` → `Git::Commands::Apply` / `Git::Commands::Am::Apply` — `git apply` / `git am`
1502
- - [x] `revert` → `Git::Commands::Revert::*` — `git revert` (implemented as `Start`, `Continue`, `Skip`, `Abort`, and `Quit`)
1503
-
1504
- **Plumbing:**
1505
-
1506
- - [x] `rev_parse` → `Git::Commands::RevParse` — `git rev-parse`
1507
- - [x] `name_rev` → `Git::Commands::NameRev` — `git name-rev`
1508
- - [x] `cat_file_*` → `Git::Commands::CatFile::*` — `git cat-file` (implemented as `Full`, `Meta`, `Pretty`, and `Typed`, with `Git::Lib#cat_file_*` delegating through these classes)
1509
- - [x] `read_tree` → `Git::Commands::ReadTree` — `git read-tree`
1510
- - [x] `commit_tree` → `Git::Commands::CommitTree` — `git commit-tree`
1511
- - [x] `update_ref` → `Git::Commands::UpdateRef::*` — `git update-ref` (implemented as `Update`, `Delete`, and `Batch`)
1512
- - [x] `checkout_index` → `Git::Commands::CheckoutIndex` — `git checkout-index`
1513
- - [x] `archive` → `Git::Commands::Archive` — `git archive`
1514
- - [x] `write_tree` → `Git::Commands::WriteTree` — `git write-tree`
1515
-
1516
- **Administration:**
1517
-
1518
- - [x] `gc` → `Git::Commands::Gc` — `git gc`
1519
- - [x] `repack` → `Git::Commands::Repack` — `git repack`
1520
-
1521
- **Setup & Config:**
1522
-
1523
- - [x] `config_get` / `config_set` / `global_config_*` / `config_list` →
1524
- `Git::Commands::ConfigOptionSyntax::*` — `git config`
1525
-
1526
- **Other:**
1527
-
1528
- - [x] `worktree_add` / `worktree_remove` → `Git::Commands::Worktree` — `git worktree`
1529
- - [x] `branch_contains` → (part of `Git::Commands::Branch`)
1530
- - [x] `change_head_branch` → `Git::Commands::SymbolicRef` — `git symbolic-ref`
1531
- - [x] `repository_default_branch` → (part of `Git::Commands::LsRemote`)
1532
- - [x] `current_command_version` → `Git::Commands::Version` — `git version`
1533
- - [x] N/A (new) → `Git::Commands::Maintenance::*` — `git maintenance` (Register, Run, Start, Stop, Unregister) ⚠️ missing specs
1534
-
1535
- ## Phase 3: Refactoring the Public Interface
1536
-
1537
- ***Goal**: Switch the public-facing classes to use the new architecture directly,
1538
- breaking the final ties to the old implementation.*
1539
-
1540
- > **Status**: Phase 3 is ✅ complete. Tasks 1 and 2 are both complete; the remaining
1541
- > redesign work is the Phase 4 cleanup described in the [Next Task](#next-task)
1542
- > section above.
1543
-
1544
- 1. **Add `binary_path:` to `Git::ExecutionContext`** ✅
1545
-
1546
- `Git::ExecutionContext` gained `binary_path:` in its constructor; all subclasses
1547
- forward it. `command_line_capturing`/`command_line_streaming` use `@binary_path`.
1548
- `Git::ExecutionContext::Repository.from_base` forwards `binary_path:`. The `Open3`
1549
- stopgap in `Git.run_git_version` was replaced with
1550
- `Git::Commands::Version.new(Git::ExecutionContext::Global.new(...)).call`.
1551
-
1552
- 2. **Implement the Facade** ✅
1553
-
1554
- `Git::Repository` now includes 15 modules via `include` in
1555
- `lib/git/repository.rb` (see [Facade Modules Completed](#facade-modules-completed)).
1556
- `Git::Base` wraps the corresponding methods via `facade_repository`, and the
1557
- end-of-Phase-3 parity sweep landed the remaining low-level facade coverage
1558
- needed before the entry-point flip — including `describe`, `show`, `fsck`,
1559
- `apply`, `apply_mail`, `read_tree`, `cat_file_*`, `repack`, `gc`, helper/path
1560
- context methods, and the remaining remote/tag convenience APIs.
1561
-
1562
- ## Phase 4: Final Cleanup and Release Preparation
1563
-
1564
- ***Goal**: Remove all old code, finalize the test suite, and prepare for the v5.0.0
1565
- release.*
1566
-
1567
- ### Phase 4 step graph
1568
-
1569
- ```mermaid
1570
- graph LR
1571
- A["A ✅ Remove old code"] --> B["B ✅ Finalize test suite"]
1572
- B --> C["C 🚧 Update documentation"]
1573
- ```
1574
-
1575
- #### Step A — Remove old code
1576
-
1577
- **Status: ✅ Complete.** Completed in [PR #1456](https://github.com/ruby-git/ruby-git/pull/1456)
1578
- (commit `c1c53999`).
1579
-
1580
- - Delete `attr_reader :base_object`, remove `base_object:` from `#initialize`, and remove or convert `from_base`.
1581
- - Delete the `Git::Lib` class entirely.
1582
- - Delete the `Git::Base` class file.
1583
- - Remove any other dead code that was part of the old implementation.
1584
-
1585
- **Done when**: `lib/git/lib.rb` and `lib/git/base.rb` are deleted; `Git::ExecutionContext::Repository` no longer accepts or exposes `base_object`; no runtime references to `Git::Lib` or `Git::Base` remain in `lib/` (YARD/comment references to historical 4.x behavior are allowed). ✅ Met — the only surviving `Git::Lib`/`Git::Base` strings in `lib/` are such doc/comment references.
1586
-
1587
- **Planning tip**: Before generating a deletion plan, audit all remaining callers of `Git::Lib`, `Git::Base`, and `from_base` across `lib/` and `spec/`. The bridge removal and `Git::Base` deletion must land atomically in the same PR — plan for a single large deletion commit rather than incremental removals.
1588
-
1589
- #### Step B — Finalize test suite
1590
-
1591
- **Status: ✅ Complete.**
1592
-
1593
- All 159 PORT rows (after dedup) from the W1/W1.5 audit were ported to RSpec across batches U1–U21
1594
- (W2). The `tests/` directory and all Test::Unit tooling were removed (W3). The
1595
- `extract-*` skills were deprecated (W4a). All Test::Unit documentation references
1596
- were removed (W4b). The full quality gate was verified green (W5): 5668 unit examples
1597
- + 893 integration examples, 0 failures; RuboCop clean; YARD 83.6% (threshold 75%);
1598
- gem build successful. W6 (remove stale `Git::Base`/`Git::Lib` skill references from
1599
- active skills) is complete — both plan ([PR #1506](https://github.com/ruby-git/ruby-git/pull/1506)) and execution ([PR #1509](https://github.com/ruby-git/ruby-git/pull/1509)) have merged.
1600
-
1601
- See the detailed execution plan in
1602
- [Phase 4 - Step B.md](Phase%204%20-%20Step%20B.md).
1603
-
1604
- #### Step C — Update documentation
1605
-
1606
- **Status: 🚧 Partial.** See detailed execution plan in
1607
- [Phase 4 - Step C.md](Phase%204%20-%20Step%20C.md).
1608
-
1609
- - ✅ Thoroughly document the new public API (`Git`, `Git::Repository`, etc.) and all
1610
- of `lib/` — **done**: every file passes `yard-lint` (which replaced the retired
1611
- `yardstick` tooling) with no offenses.
1612
- - Set correct `@api` tags across `lib/` (including flipping the `Git::Repository::*`
1613
- topic modules to `@api private`).
1614
- - Update the `README.md` and expand the existing `UPGRADING.md` guide explaining the
1615
- breaking changes for v5.0.0.
1616
-
1617
- **Done when**: the criteria in the Step C execution plan
1618
- ([Phase 4 - Step C.md](Phase%204%20-%20Step%20C.md) → "Done-When Criteria") are all
1619
- met. In brief: documentation coverage is complete and enforced by `yard-lint`
1620
- (`.yard-lint.yml`; `rake yard:lint` passes with no offenses) — already done — the
1621
- `@api`-visibility tags are correct, `UPGRADING.md` covers all breaking changes,
1622
- `README.md` reflects the new entry points, and the full CI pipeline is green. This
1623
- tracker defers to the Step C plan as the single source of truth to avoid drift.