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,512 +0,0 @@
1
- ---
2
- name: development-workflow
3
- description: "Follows a strict Test-Driven Development (TDD) workflow with four phases: triage, prepare, execute, and finalize. Use for bug fixes, feature implementation, refactoring, maintenance tasks, and issue triage / diagnosis (triage phase only for diagnosis without implementation)."
4
- ---
5
-
6
- # Development Workflow
7
-
8
- This skill implements a strict Test-Driven Development (TDD) workflow.
9
-
10
- **This project strictly follows TDD practices. All production code MUST be
11
- written using the TDD process described below.**
12
-
13
- ## Contents
14
-
15
- - [Contents](#contents)
16
- - [How to use this skill](#how-to-use-this-skill)
17
- - [Workflow Overview](#workflow-overview)
18
- - [Core TDD Principles](#core-tdd-principles)
19
- - [Phase 0: TRIAGE](#phase-0-triage)
20
- - [Phase 1: PREPARE](#phase-1-prepare)
21
- - [Phase 2: EXECUTE](#phase-2-execute)
22
- - [RED-GREEN Step](#red-green-step)
23
- - [REFACTOR Step](#refactor-step)
24
- - [VERIFY Step](#verify-step)
25
- - [COMMIT Step](#commit-step)
26
- - [REPLAN Step](#replan-step)
27
- - [Phase 3: FINALIZE](#phase-3-finalize)
28
- - [Per-Task Commits](#per-task-commits)
29
- - [Related skills](#related-skills)
30
- - [Additional Guidelines](#additional-guidelines)
31
- - [Example TDD Cycle](#example-tdd-cycle)
32
-
33
- ## How to use this skill
34
-
35
- Attach this file to your Copilot Chat context, then invoke it when implementing
36
- features, fixing bugs, refactoring, or maintaining code. Follow phases in order
37
- and stop after TRIAGE when the issue is non-actionable or needs clarification.
38
-
39
- ## Workflow Overview
40
-
41
- When assigned a task involving a GitHub issue, follow this workflow:
42
-
43
- 1. **Phase 0: TRIAGE** - Understand the issue and determine if action is needed
44
- 2. **Phase 1: PREPARE** - Set up the environment and plan the implementation
45
- 3. **Phase 2: EXECUTE** - Implement the solution using TDD
46
- 4. **Phase 3: FINALIZE** - Squash commits and create the PR
47
-
48
- **Note:** Not all issues require implementation. Phase 0 may result in requesting
49
- clarification, confirming the issue is a duplicate, or determining no changes are
50
- needed.
51
-
52
- ## Related skills
53
-
54
- - [RSpec Unit Testing Standards](../rspec-unit-testing-standards/SKILL.md) — RSpec rules for test structure, naming,
55
- setup patterns, stubbing, and coverage; apply when writing tests during TDD cycles
56
- - [TDD Refactor Step](../tdd-refactor-step/SKILL.md) — detailed guidance for the
57
- REFACTOR step: code smells, techniques, test cleanup, and rubocop integration
58
- - [Test Debugging](../test-debugging/SKILL.md) — focused diagnosis for failing or
59
- flaky tests
60
- - [CI/CD Troubleshooting](../ci-cd-troubleshooting/SKILL.md) — workflow for CI
61
- failures and environment-specific issues
62
- - [PR Readiness Review](../pr-readiness-review/SKILL.md) — final quality gate
63
- before opening a pull request
64
- - [Command Implementation](../command-implementation/SKILL.md) — scaffolding and
65
- reviewing `Git::Commands::*` classes during implementation
66
- - [Facade Implementation](../facade-implementation/SKILL.md) — scaffolding and
67
- reviewing `Git::Repository::*` facade methods during implementation
68
-
69
- ## Core TDD Principles
70
-
71
- Adhere to the following fundamental principles to ensure high code quality and test
72
- coverage:
73
-
74
- - **Never Write Production Code without a Failing Test**
75
- - **Bug Fixes Start with Tests:** Before fixing any bug, write a failing test that
76
- demonstrates the bug and fails in the expected way. Only then fix the code to make
77
- the test pass.
78
- - **Tests Drive Design:** Let the test dictate the API and architecture. If the test
79
- is hard to write, the design is likely wrong. When this happens, stop and suggest
80
- one or more design alternatives. Offer to stash any current changes and work on the
81
- design improvements first before continuing with the original task.
82
- - **Write Tests Incrementally:** Build tests in small steps, writing just enough to
83
- get the next expected failure. For example, first write a test that references a
84
- class that doesn't exist (fails), then define the empty class (passes), then extend
85
- the test to call a method (fails), then define the method (passes), etc.
86
- - **Tests Should Be Atomic:** Each test should verify exactly one logical behavior,
87
- making failures easy to diagnose and understand.
88
- - **Prefer the Simplest Solution:** Choose the simplest implementation that could
89
- possibly work, even if it seems naive. Complexity should only be added when driven
90
- by actual requirements in tests.
91
- - **No Implementation in Advance:** Only write the code strictly needed to pass the
92
- current test.
93
-
94
- ## Phase 0: TRIAGE
95
-
96
- The purpose of this phase is to understand what the issue is asking for, investigate
97
- the current state of the codebase, and determine whether implementation is needed.
98
-
99
- **Use this phase when the user references a GitHub issue number** (e.g., "Fix issue
100
- \#999", "Implement \#999", "Diagnose issue \#999").
101
-
102
- 1. **Fetch the Issue:** Use `gh issue view #999` to read the full issue content,
103
- including description, comments, and labels.
104
-
105
- 2. **Understand the Request:** Analyze what is being asked:
106
- - Is this a bug report? Feature request? Question? Documentation issue?
107
- - Is the issue clear and actionable, or does it need clarification?
108
- - Are there reproduction steps or examples provided?
109
-
110
- 3. **Search for Context:** Investigate the codebase to understand the area affected:
111
- - Use `grep_search` or `semantic_search` to find relevant code
112
- - Read related test files to understand existing behavior
113
- - Check if similar functionality already exists
114
- - Look for related issues or PRs that might be relevant
115
-
116
- 4. **Reproduce (if applicable):** For bug reports:
117
- - Try to reproduce the issue based on the provided steps
118
- - Run existing tests to see if they catch the issue
119
- - Verify the issue still exists in the current codebase
120
-
121
- 5. **Determine Next Steps and Report Findings:**
122
-
123
- **Option A: Issue needs clarification**
124
- - Comment on the issue using `gh issue comment #999 --body "..."`
125
- - Ask specific questions about reproduction steps, expected behavior, or use case
126
- - **STOP here** - wait for user/reporter response before proceeding
127
-
128
- **Option B: Issue is not actionable (duplicate, won't-fix, already resolved)**
129
- - Comment on the issue explaining your findings
130
- - Suggest closing the issue or linking to related issues
131
- - **STOP here** - no implementation needed
132
-
133
- **Option C: Issue is clear and actionable**
134
- - Comment on the issue confirming you understand the request and plan to implement
135
- - Summarize your understanding and proposed approach
136
- - **Proceed to Phase 1: PREPARE** to begin implementation
137
-
138
- **Option D: User asked only to diagnose (not implement)**
139
- - Comment on the issue with your diagnostic findings
140
- - Explain what you discovered (root cause, affected code, potential solutions)
141
- - **STOP here** - wait for confirmation to proceed with implementation
142
-
143
- **GitHub CLI Commands for Phase 0:**
144
-
145
- - View issue: `gh issue view #999`
146
- - View with comments: `gh issue view #999 --comments`
147
- - Comment on issue: `gh issue comment #999 --body "Your comment here"`
148
- - Search issues: `gh issue list --search "keyword"`
149
-
150
- ## Phase 1: PREPARE
151
-
152
- The purpose of this phase is to ensure the project environment is ready, establish a
153
- clean baseline, and create a clear implementation plan before writing any code.
154
-
155
- **Only proceed to this phase if Phase 0 determined that implementation is needed.**
156
-
157
- 1. **Check Uncommitted Changes:** If there are any uncommitted changes in the
158
- project, ask the user what to do with them before continuing: include them in the
159
- current implementation plan, ignore them, or stash them before continuing.
160
- 2. **Create Feature Branch:** Create a new branch from `origin/main` using the naming
161
- convention `<type>/<short-description>` (e.g., `fix/issue-999`).
162
- 3. **Verify Project Setup:** Run `bin/setup` to ensure that the project is ready
163
- for development.
164
- 4. **Verify Clean Baseline:** Ensure that all existing tests and linters pass by
165
- running `bundle exec rake default`.
166
- 5. **Analyze and Plan:** Understand the requirements, identify edge cases and
167
- potential challenges, and break the work into small, isolated tasks. Consider what
168
- tests will be needed and in what order they should be written.
169
- 6. **Consider Refactoring:** Look for ways to make the implementation of the feature
170
- or bug fix easier by performing one or more refactorings. If any are found,
171
- suggest them to the user. If the user confirms the refactoring, do the refactoring
172
- in a separate TDD process. Only once the refactoring is completed should the
173
- current feature or bug fix be worked on.
174
- 7. **Review Implementation Guidelines:** When implementing or modifying git command
175
- wrappers, read the "Wrapping a git command" section in CONTRIBUTING.md before
176
- proceeding. This ensures consistent API design
177
- for method placement, naming, parameters, and output processing.
178
-
179
- ## Phase 2: EXECUTE
180
-
181
- The purpose of this phase is to implement each planned task using strict TDD cycles,
182
- ensuring every line of production code is driven by a failing test.
183
-
184
- Execute each task by repeating the following cycle of steps until all tasks are
185
- complete:
186
-
187
- 1. **RED-GREEN:** Write failing tests and implement code to make them pass
188
- 2. **REFACTOR:** Improve code quality and design without changing behavior
189
- 3. **VERIFY:** Confirm the task is complete and code meets quality standards
190
- 4. **COMMIT:** Create a commit for the completed task
191
- 5. **REPLAN:** Review the implementation plan, then return to step 1 for the next
192
- task
193
-
194
- When all tasks are complete, proceed to **Phase 3: FINALIZE**.
195
-
196
- ### RED-GREEN Step
197
-
198
- 1. **RED Substep**
199
-
200
- The purpose of this substep is to write a failing test that you hypothesize will
201
- pass with the next incremental bit of task implementation.
202
-
203
- - **Write the Test:** Write a single, focused, failing test or extend an existing
204
- test for the current task.
205
- - **Keep It Minimal:** Only write enough of a test to get an expected, failing
206
- result (the test should fail for the *right* reason).
207
- - **Execute and Analyze:** Run the specific test file (e.g.,
208
- `bundle exec rspec spec/unit/git/commands/<command>_spec.rb`) and analyze the
209
- output.
210
- - **Confirm Expected Failure:** Confirm it fails with an expected error (e.g.,
211
- assertion failure or missing definition).
212
- - **Validate:** If the test passes without implementation, the test is invalid or
213
- the logic already exists. When that happens, revise or skip.
214
-
215
- 2. **GREEN Substep**
216
-
217
- The purpose of this substep is to write just enough production code to make the
218
- failing test(s) pass.
219
-
220
- - **Write Minimal Code:** Write the minimum amount of code required to make the
221
- test pass.
222
- - **Use Simple Solutions:** It is acceptable to use hardcoded values or "quick and
223
- dirty" logic here just to get to green, even if this means intentionally writing
224
- clearly suboptimal code that you will improve during the REFACTOR step.
225
- - **No Premature Optimization:** Do NOT optimize, clean up, or improve code style
226
- during GREEN—that work belongs in the REFACTOR step.
227
- - **Execute and Verify:** Run the specific test file
228
- - **If the test passes**, proceed to the REFACTOR step
229
- - **If the test fails**, read the FULL error output including the stack trace.
230
- Identify the exact failing line and assertion before modifying any code. Fix
231
- only what the error indicates, then re-run. Repeat until the test passes.
232
- - **Rollback on Repeated Failure:** If the test cannot be made to pass within 3
233
- attempts, revert all changes from this RED-GREEN cycle, report the issue to the
234
- user, and ask for guidance before proceeding.
235
- - **Stay Focused:** Do not implement future features or optimizations yet.
236
-
237
- ### REFACTOR Step
238
-
239
- The purpose of this step is to improve code quality and design without changing
240
- behavior, ensuring the codebase remains clean and maintainable.
241
-
242
- **You must consider refactoring before starting the next task.** Remove duplication,
243
- improve variable names, and apply design patterns. Skip this step only if the code is
244
- already clean and simple—avoid over-engineering.
245
-
246
- For detailed guidance on code smells, refactoring techniques, test cleanup, and
247
- rubocop integration, see the
248
- [TDD Refactor Step](../tdd-refactor-step/SKILL.md) skill.
249
-
250
- - **Generalize the Implementation:** Ensure the code solves the general case, not
251
- just the specific test case. Replace hardcoded values used to pass the test with
252
- actual logic.
253
- - **Limit Scope:** Do not perform refactorings that affect files outside the
254
- immediate scope of the current task. If a broader refactor is needed, add it to the
255
- task list during the REPLAN step as a separate task.
256
- - **Execute All Tests:** Run `bundle exec rake default` and verify they still pass.
257
- - **Verify Test Independence:** Verify tests can run independently in any order.
258
- - **Confirm Improvement:** Ensure the refactoring made the code clearer, simpler, or
259
- more maintainable.
260
-
261
- ### VERIFY Step
262
-
263
- The purpose of this step is to confirm that the current task is fully complete before
264
- moving to the next task.
265
-
266
- - **Confirm Implementation Complete:** Verify all functionality for the task is
267
- implemented.
268
- - **Run All Tests:** Run `bundle exec rspec` and `bundle exec rake test` to ensure
269
- all tests pass.
270
- - **Run Linters:** Run `bundle exec rubocop` and `bundle exec rake yard` to verify
271
- code style and documentation standards.
272
- - **Check Code Quality:** Confirm the code is clean and well-factored.
273
- - **Audit Command Tests (command tasks only):** If this task added or modified tests
274
- for any `Git::Commands::*` class, apply the
275
- [Command Test Conventions](../command-test-conventions/SKILL.md) skill to every new or
276
- changed spec file before committing. Fix any violations found before moving to the
277
- COMMIT step.
278
- - **Audit Command YARD Docs (command tasks only):** If this task added or modified
279
- any `Git::Commands::*` source file, apply the
280
- [Command YARD Documentation](../command-yard-documentation/SKILL.md)
281
- skill to each changed source file. Fix any documentation gaps before committing.
282
- - **STOP on Unexpected Failure:** If any test unexpectedly fails during VERIFY, STOP
283
- immediately and report the failure to the user. Do not attempt to fix the failure
284
- without first explaining what went wrong and getting confirmation to proceed.
285
-
286
- ### COMMIT Step
287
-
288
- The purpose of this step is to create a checkpoint after successfully completing a
289
- task, providing a safe rollback point.
290
-
291
- - **Create Commit:** Commit all changes from this task using the appropriate
292
- conventional commit type (see the **Per-Task Commits** section below for guidance).
293
- - **Keep Commits Atomic:** Each commit should represent one completed task with all
294
- tests passing and linters clean.
295
-
296
- ### REPLAN Step
297
-
298
- The purpose of this step is to review progress and adjust the implementation plan
299
- based on what was learned during the current task.
300
-
301
- - **Review Implementation Plan:** Assess whether the remaining tasks are still valid
302
- and appropriately scoped based on what was learned.
303
- - **Identify New Tasks:** If the implementation revealed new requirements, edge
304
- cases, or necessary refactorings, add them to the task list.
305
- - **Reprioritize if Needed:** Adjust task order if dependencies or priorities have
306
- changed.
307
- - **Sync Redesign Tracker (required for command migrations):** If the task adds,
308
- migrates, or rewires any `Git::Commands::*` usage, update
309
- `redesign/3_architecture_implementation.md` in the same task commit:
310
- - mark migrated command checklist entries (`[ ]` → `[x]`)
311
- - update Phase 2 migrated count in the Progress Tracker
312
- - update "Next Task" to the next unchecked command in list order
313
- - ensure command spec paths use `spec/unit/...` or `spec/integration/...` (never
314
- stale `spec/git/...` paths)
315
- - run a stale-doc sanity check by comparing unchecked `Git::Commands::*` entries
316
- against files under `lib/git/commands/`; resolve any mismatches before moving on
317
- - **Report Progress:** Briefly summarize what was completed and what remains.
318
- **ALWAYS** print the updated task list with status (e.g., `[x] Task 1`, `[ ] Task
319
- 2`).
320
- - **Continue or Complete:** If tasks remain, return to RED-GREEN for the next task.
321
- If all tasks are complete, proceed to **Phase 3: FINALIZE**.
322
-
323
- ## Phase 3: FINALIZE
324
-
325
- The purpose of this phase is to consolidate all task commits into a single, clean
326
- commit and complete the feature or bug fix.
327
-
328
- 1. **Run Final Verification:** Run `bundle exec rake default` one final time to
329
- ensure everything passes.
330
- 2. **Safety Check:** Run `git log --oneline HEAD~N..HEAD` (where N is the number of
331
- task commits) to list the commits included in the squash. Verify these are
332
- strictly the commits generated during the current session. If unexpected commits
333
- appear, STOP and ask the user for the correct value of N.
334
- 3. **Capture Commit Messages:** Run `git log --format="- %s" HEAD~N..HEAD` to capture
335
- individual commit messages for inclusion in the final commit body.
336
- 4. **Draft the Squash Message:** Prepare a commit message with:
337
- - **Subject:** A single line summarizing the entire feature or fix (e.g.,
338
- `feat(branch): add Branch#create method`)
339
- - **Body:** A summary of what was implemented, the captured commit messages from
340
- step 2, key decisions made, and any relevant context. Wrap lines at 100
341
- characters.
342
- 5. **Propose the Squash:** Present the drafted message and the commands to squash to
343
- the user:
344
- - `git reset --soft HEAD~N` (where N is the number of task commits)
345
- - `git commit -m "<drafted message>"`
346
- 6. **Wait for Confirmation:** Do NOT execute the squash until the user reviews the
347
- commits and confirms. The user may want to adjust the message or keep some commits
348
- separate.
349
- 7. **Execute on Confirmation:** Once confirmed, run `git reset --soft HEAD~N` to
350
- unstage the task commits while preserving all changes, then commit with the
351
- approved message.
352
- 8. **Handle Commit Hook Failure:** If the commit fails due to a `commit-msg` hook
353
- rejection (e.g., commitlint error):
354
- - Read the error message carefully to identify the formatting issue.
355
- - To validate a message file before committing:
356
- ```bash
357
- npx commitlint --format @commitlint/format < commit_msg.txt
358
- ```
359
- - To diagnose *why* a message is rejected (e.g., unexpected body/footer split),
360
- inspect how the parser tokenizes it:
361
- ```bash
362
- cat commit_msg.txt | node -e "
363
- const parse = require('@commitlint/parse');
364
- let msg = '';
365
- process.stdin.on('data', d => msg += d);
366
- process.stdin.on('end', () =>
367
- parse.default(msg.trim()).then(r => console.log(JSON.stringify(r, null, 2)))
368
- );
369
- " | jq
370
- ```
371
- - Fix the commit message to comply with the project's commit conventions.
372
- - Retry the commit. The changes remain staged after a hook failure, so only the
373
- `git commit` command needs to be re-run.
374
- - If the commit fails 3 times, STOP and report the issue to the user with the
375
- exact error message.
376
- 9. **Create the Pull Request:** Push the branch and open the PR. **CRITICAL:** The
377
- terminal tool mangles multi-line markdown (backticks, asterisks, newlines) in any
378
- shell command — including heredocs and inline `--body "..."` arguments. Always
379
- write the PR body using the **`create_file` tool** (not the terminal), then
380
- reference that file:
381
- - Use `create_file` to write the body to `./pr_body.md` (repo-relative path,
382
- works on all platforms)
383
- - Then run in the terminal: `git push origin <branch>`
384
- - Then run in the terminal: `gh pr create --title "<title>" --base <target-branch> --body-file ./pr_body.md`
385
- (choose `main` or `4.x` per the [branch strategy](/CONTRIBUTING.md))
386
-
387
- After creating the PR, verify the stored body with
388
- `gh pr view <number> --json body --jq '.body'`. If it is garbled, rewrite
389
- `./pr_body.md` with `create_file` and fix with
390
- `gh pr edit <number> --body-file ./pr_body.md`.
391
-
392
-
393
- ### Per-Task Commits
394
-
395
- In the COMMIT step, create a commit for the completed task following these
396
- guidelines:
397
-
398
- - **Use Appropriate Types:**
399
- - `test:` for adding or modifying tests (RED step)
400
- - `feat:` for new **user-facing** functionality (triggers MINOR version bump)
401
- - `fix:` for bug fixes (GREEN step for bugs)
402
- - `refactor:` for code improvements without behavior change
403
- - `chore:` for internal tooling or maintenance
404
- - **Use Scope When Relevant:** Include a scope to indicate the affected component
405
- (e.g., `feat(branch):`, `test(remote):`).
406
- - **Write Clear Subjects:** Use imperative mood, lowercase, no period (e.g.,
407
- `feat(branch): add create method`).
408
- - **Issue and PR References in the Body:** Do not use `#<number>` in the commit
409
- body — write `issue 1000` not `issue #1000`. A commitlint parser flaw treats
410
- any line containing `#<number>` as a footer token, permanently breaking the
411
- body/footer split for all subsequent lines.
412
- - To **close** an issue/PR, use `Closes`/`Fixes`/`Resolves` with `#` in the
413
- footer — e.g. `Closes #1000`.
414
- - To **mention** an issue for context only, omit the `#` in the body and no
415
- footer line is needed.
416
-
417
- ## Additional Guidelines
418
-
419
- These guidelines supplement the TDD process:
420
-
421
- - **Justify Test Modifications:** If an existing test needs to be modified, STOP and
422
- report to the user before making the change. Explain which test needs modification,
423
- why the expected behavior is changing, and whether this represents a breaking
424
- change. Wait for user confirmation before proceeding.
425
- - **Unrelated Test Failures:** If you need to modify a test file that is not related
426
- to the current task to make the build pass, STOP and report to the user. This
427
- usually indicates a deeper regression, environment issue, or flawed assumption. Do
428
- not attempt to fix unrelated tests without user guidance.
429
- - **Handle Discovered Complexity:** If the implementation reveals a complex logic
430
- gap, add it to your task list but finish the current cycle first.
431
- - **Test Names Describe Behavior:** Name tests to clearly describe what behavior they
432
- verify (e.g., `test_creates_new_branch` not `test_branch`).
433
- - **Ask for Clarification:** Stop and ask for clarification if requirements or
434
- expectations are ambiguous.
435
- - **Do NOT Update CHANGELOG.md:** The CHANGELOG is auto-generated from commit
436
- messages. Never edit it manually.
437
- - **Bulk File Text Substitutions:** When renaming classes, methods, or files across
438
- many files simultaneously, avoid complex chained `sed` commands — the terminal tool
439
- can mangle multi-pattern substitutions with non-trivial quoting or multi-line
440
- heredocs. Instead, write the substitution logic to a temporary Ruby script and
441
- execute it:
442
-
443
- ```ruby
444
- # tmp_rename.rb
445
- files = Dir.glob('lib/**/*.rb') +
446
- Dir.glob('spec/**/*.rb') +
447
- Dir.glob('tests/**/*.rb')
448
- files.each do |f|
449
- src = File.read(f)
450
- # Apply most-specific patterns first to avoid partial matches
451
- new_src = src
452
- .gsub('OldClassName', 'NewClassName')
453
- .gsub("require_relative 'old_path'", "require_relative 'new_path'")
454
- File.write(f, new_src) if new_src != src
455
- end
456
- ```
457
-
458
- Run the script, then delete it:
459
-
460
- ```
461
- ruby tmp_rename.rb
462
- rm tmp_rename.rb # macOS/Linux
463
- del tmp_rename.rb # Windows (cmd)
464
- Remove-Item tmp_rename.rb # Windows (PowerShell)
465
- ```
466
-
467
- Apply substitutions from most-specific to least-specific to prevent partial
468
- matches (e.g., replace `FooBarBaz` before `FooBar`).
469
-
470
- ## Example TDD Cycle
471
-
472
- Each task follows this cycle: **RED → GREEN → REFACTOR → VERIFY → COMMIT → REPLAN**
473
-
474
- **RED:** Write a failing test that describes the desired behavior.
475
-
476
- ```ruby
477
- # spec/unit/git/commands/example_spec.rb
478
- it 'passes the --force flag when force: true is given' do
479
- expect_command_capturing('example', '--force').and_return(command_result(''))
480
-
481
- described_class.new(execution_context).call(force: true)
482
- end
483
- # Run: bundle exec rspec spec/unit/git/commands/example_spec.rb
484
- # → fails: NameError (Git::Commands::Example is not defined yet)
485
- ```
486
-
487
- **GREEN:** Write minimal code to make the test pass.
488
-
489
- ```ruby
490
- # lib/git/commands/example.rb
491
- module Git
492
- module Commands
493
- class Example < Base
494
- arguments do
495
- literal 'example'
496
- flag_option :force
497
- end
498
- end
499
- end
500
- end
501
- # Run: bundle exec rspec spec/unit/git/commands/example_spec.rb → passes
502
- ```
503
-
504
- **REFACTOR:** Improve code quality without changing behavior, then run all tests.
505
-
506
- **VERIFY:** Run `bundle exec rake default` to confirm tests and linters pass.
507
-
508
- **COMMIT:** `git commit -m "feat(branch): add Branch#create method"`
509
-
510
- **REPLAN:** Report progress, update task list, proceed to next task or FINALIZE.
511
-
512
- **FINALIZE (after all tasks):** Propose squash commit with captured messages, wait