Skip to content

Commit 99bd636

Browse files
committed
docs(workflow): improve commit message workflow to prevent corruption
Problem: Using `git commit -m` with multi-line messages causes terminal corruption. The terminal can corrupt messages during echo/display, leading to corrupted commit objects with garbled text in the git history. Root Cause: Terminal character handling issues when processing long multi-line strings passed via `-m` flag. The corruption occurs during command execution and gets permanently stored in the git commit object. Solution: Updated copilot instructions to mandate file-based commit workflow. Write message to scratch/commit-msg.txt, validate it, then use `git commit -F` to read from file. This bypasses terminal string handling entirely. Changes: - .github/copilot-instructions.md: Replaced `-m` approach with file-based workflow - Added detailed commit workflow section with validation step - Updated "During Work" section to reference new approach - Emphasized WHY this prevents corruption Testing: ✅ Documentation: Clear step-by-step workflow ✅ Validation: Built-in message review step ✅ This commit: Used the new workflow successfully Impact: Prevents corrupted commit messages in git history. Ensures all commit messages are clean, readable, and maintainable. Makes git log reliable for tracking project history.
1 parent 96c1928 commit 99bd636

1 file changed

Lines changed: 51 additions & 12 deletions

File tree

.github/copilot-instructions.md

Lines changed: 51 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -248,24 +248,60 @@ that should NEVER be in the public repository. This is a HARD REQUIREMENT.
248248
2. If any handoff files appear, use `git reset HEAD ai-assisted/` to unstage them
249249
3. ONLY commit actual code, documentation, and configuration changes
250250

251-
**Standard Commit Format:**
251+
**Commit Workflow (MANDATORY):**
252+
253+
**CRITICAL: NEVER use `git commit -m` - terminals can corrupt multi-line messages!**
254+
255+
**✅ CORRECT APPROACH - Write to file first:**
256+
252257
```bash
253-
git add -A && git commit -m "type(scope): description
258+
# 1. Write commit message to scratch/ directory
259+
cat > scratch/commit-msg.txt << 'EOF'
260+
type(scope): brief description
254261
255-
**Problem:**
256-
[what was broken or missing]
262+
Problem: What was broken or missing. Be specific about the issue,
263+
symptoms, and impact on users or functionality.
257264
258-
**Solution:**
259-
[how you fixed or built it]
265+
Root Cause: Why the problem existed. What architectural or implementation
266+
detail caused this issue.
260267
261-
**Testing:**
268+
Solution: How you fixed it. What changes were made and why this approach
269+
was chosen over alternatives.
270+
271+
Changes:
272+
- File1.swift: Specific change and why
273+
- File2.swift: Specific change and why
274+
275+
Testing:
262276
✅ Build: PASS
263-
✅ Manual: [what you tested]
264-
✅ Edge cases: [what you verified]"
277+
✅ Manual: What you tested and results
278+
✅ Edge cases: What scenarios you verified
279+
280+
Impact: How this improves the codebase, what users can now do, or what
281+
problems are prevented.
282+
EOF
283+
284+
# 2. Validate the message (read it back)
285+
cat scratch/commit-msg.txt
286+
287+
# 3. Stage changes
288+
git add -A
289+
290+
# 4. Commit using the file
291+
git commit -F scratch/commit-msg.txt
292+
293+
# 5. Clean up
294+
rm scratch/commit-msg.txt
265295
```
266296

267297
**Commit types:** feat, fix, refactor, docs, test, chore
268298

299+
**Why this approach:**
300+
- Avoids terminal corruption of multi-line messages with `-m`
301+
- Allows validation before commit
302+
- Prevents truncation or special character issues
303+
- Ensures commit message is exactly what you wrote
304+
269305
### Architecture Overview
270306

271307
**Key Components:**
@@ -352,9 +388,12 @@ User Input → ChatWidget → ConversationEngine → MessageBus → API Provider
352388
- WAIT for approval
353389

354390
6. **COMMIT**
355-
- Add changes: `git add -A`
356-
- Commit with full message (see Code Standards)
357-
- Include testing details in commit message
391+
- Write commit message to `scratch/commit-msg.txt`
392+
- Validate message: `cat scratch/commit-msg.txt`
393+
- Stage changes: `git add -A`
394+
- Commit: `git commit -F scratch/commit-msg.txt`
395+
- Clean up: `rm scratch/commit-msg.txt`
396+
- (See "Commit Workflow" in Code Standards section for full details)
358397

359398
7. **CONTINUE** (MANDATORY - Do not stop here!)
360399
- Immediately identify next task

0 commit comments

Comments
 (0)