Skip to content

Conversation

@kevalyq
Copy link
Contributor

@kevalyq kevalyq commented Nov 9, 2025

Purpose

Add automated detection of Git merge conflict markers to prevent accidentally committing unresolved conflicts.

Changes

New Files:

  • scripts/check-conflict-markers.sh (95 lines) - Shell script that scans all tracked files
  • .github/workflows/check-conflict-markers.yml - CI integration (runs on PRs and main pushes)
  • docs/scripts/CHECK_CONFLICT_MARKERS.md - Complete usage guide (197 lines)

Modified:

  • CHANGELOG.md - Document new feature

Features

  • ✅ Detects 4 conflict marker patterns: <<<<<<<, =======, >>>>>>>, |||||||
  • ✅ Scans only Git-tracked files (respects .gitignore)
  • ✅ Colored output with exact line numbers
  • ✅ Exit codes: 0 = clean, 1 = conflicts found
  • ✅ CI integration prevents merging PRs with conflicts
  • ✅ Can be used in pre-commit hooks

Example Output

$ ./scripts/check-conflict-markers.sh
═══════════════════════════════════════════════════════════════
Git Conflict Marker Detection
═══════════════════════════════════════════════════════════════

─────────────────────────────────────────────────────
Checked files: 168
✓ No conflict markers found
═══════════════════════════════════════════════════════════════

Testing

# Test script locally
chmod +x scripts/check-conflict-markers.sh
./scripts/check-conflict-markers.sh  # Exit code 0 = success

# Quality checks passed
npx prettier --check .
npx markdownlint-cli2 '**/*.md'
reuse lint

Related

Quality

  • ✅ All 207 tests passed
  • ✅ PHPStan level max - no errors
  • ✅ Pint formatting clean
  • ✅ Markdownlint passed
  • ✅ REUSE compliant (155/155 files)
  • ✅ Pre-push hook succeeded

- Add check-conflict-markers.sh script (95 lines)
- Integrate CI workflow for automated checks
- Document usage and troubleshooting
- Scans for <<<<<<, =======, >>>>>>>, ||||||| markers
- Prevents commits with unresolved merge conflicts
- Update CHANGELOG.md
Copilot AI review requested due to automatic review settings November 9, 2025 16:45
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

💡 Tip: Consider Using Draft PRs

Benefits of opening PRs as drafts initially:

  • 💰 Saves CI runtime and Copilot review credits
  • 🎯 Automatically sets linked issues to "🚧 In Progress" status
  • 🚀 Mark "Ready for review" when done to trigger full CI pipeline

How to convert:

  1. Click "Still in progress? Convert to draft" in the sidebar, OR
  2. Use gh pr ready when ready for review

This is just a friendly reminder - feel free to continue as is! 😊

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR adds automated detection of Git merge conflict markers to prevent accidental commits of broken code. A new shell script scans all tracked text files for conflict markers (<<<<<<<, =======, >>>>>>>, and diff3-style |||||||) and integrates with GitHub Actions to run on every PR and push to main.

Key Changes:

  • New shell script that scans tracked files and reports conflicts with file locations and line numbers
  • CI/CD integration via GitHub Actions workflow
  • Comprehensive documentation with usage examples and troubleshooting guide

Reviewed Changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 5 comments.

File Description
scripts/check-conflict-markers.sh Core detection script that scans tracked files for four types of conflict markers using grep patterns
.github/workflows/check-conflict-markers.yml CI workflow that runs the conflict marker check on PRs and pushes to main branch
docs/scripts/CHECK_CONFLICT_MARKERS.md Complete user guide covering usage, detected patterns, troubleshooting, and integration examples
CHANGELOG.md Documents the new conflict marker detection feature in the Unreleased section

- Fix diff3 marker pattern: Change '||||||' to '||||||| ' (6→7 pipes + space)
- Update CHANGELOG: Correct conflict marker pattern to '||||||| '
- Update docs table: Fix diff3 marker pattern with trailing space
- Fix docs link: Change '../scripts/preflight.sh' to 'PREFLIGHT.md'

Resolves 4 Copilot review comments. Nitpick #4 (copyright format) is correct as-is.
Prevents false positives in conflict marker detection script by
indenting the example markers in documentation.
@kevalyq kevalyq merged commit 9fc3ccb into main Nov 9, 2025
16 checks passed
@kevalyq kevalyq deleted the feat/git-conflict-marker-check branch November 9, 2025 17:58
@github-actions
Copy link

github-actions bot commented Nov 9, 2025

💡 Tip: Consider Using Draft PRs

Benefits of opening PRs as drafts initially:

  • 💰 Saves CI runtime and Copilot review credits
  • 🎯 Automatically sets linked issues to "🚧 In Progress" status
  • 🚀 Mark "Ready for review" when done to trigger full CI pipeline

How to convert:

  1. Click "Still in progress? Convert to draft" in the sidebar, OR
  2. Use gh pr ready when ready for review

This is just a friendly reminder - feel free to continue as is! 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants