pre-commit / pre-commit-hooks

Some out-of-the-box hooks for pre-commit
MIT License
5.2k stars 694 forks source link

check-merge-conflict: False positive for RST header #1050

Closed JelleZijlstra closed 4 months ago

JelleZijlstra commented 4 months ago

I got this on the CPython repo:

% git commit
[INFO] Checking merge-conflict files only.
Run Ruff on Lib/test/....................................................Passed
Run Ruff on Argument Clinic..........................(no files to check)Skipped
check for case conflicts.................................................Passed
check for merge conflicts................................................Failed
- hook id: check-merge-conflict
- exit code: 1

Doc/whatsnew/3.13.rst:1385: Merge conflict string '=======' found

check toml...........................................(no files to check)Skipped

But it's an RST header, not a merge conflict (https://github.com/python/cpython/blob/2326d6c868e300a814179d77fc308fec8365cb8c/Doc/whatsnew/3.13.rst?plain=1#L1383).

The only solution I can think of is to remove the ===== case from the pre-commit hook and check only for <<<< and >>>>, but that might cause false negatives instead. Of course, in projects where this triggers it could also be fixed by using different RST headers.

JelleZijlstra commented 4 months ago

Ah, duplicate of #100, sorry for not looking at closed issues.