Skip to content

[check-merge-conflict] False positive on RST files that use '=======' for header notation. #100

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
hvdklauw opened this issue Feb 5, 2016 · 7 comments

Comments

@hvdklauw
Copy link

hvdklauw commented Feb 5, 2016

Either ignore that conflict pattern in .rst files or are a option to ignore certain file patterns (I don't want to list all the other file options).

@asottile
Copy link
Member

asottile commented Feb 5, 2016

From the docs on http://pre-commit.com you can exclude files with the exclude: pattern

Either that or you can use one more or one fewer =

@jaraco
Copy link

jaraco commented Sep 10, 2019

These workarounds aren't suitable for the needs of cheroot as reported in cherrypy/cheroot#223. We would like to be able to detect merge conflicts in this file just like with any other file. I think the problem is that the check is over-matching. It's detecting content that's not a merge conflict. Git doesn't have this problem when invoking mergetool. Perhaps the hook could be more precise.

@asottile
Copy link
Member

mergetool can probably detect when all three markers are there -- but this hook is intended to also prevent the cases where one or more of the markers have been deleted which makes this much trickier (and much more prone to false positives)

I'm not sure what the right answer is here

@hugovk
Copy link
Contributor

hugovk commented Nov 1, 2019

Just ran into this on two RST files with 7-character underlines:

Depends
=======
Porting
=======

Perhaps the simplest thing is to ignore ======= in RST files? 2/3 checks is better than 0/3.

  • Excluding all RST files with exclude: means they will never be checked for the other two conflict markers

  • Adding or removing an = makes the header look ugly in plaintext

  • More complicated things like looking for a 7-char string on the preceding line, and possibly an empty following line, is probably more effort than it's worth

@asottile
Copy link
Member

asottile commented Nov 1, 2019

Does exclude: not work for you? I don't want to make that choice for everyone in this repo and I don't really want to complicate and weaken the checks here

@hugovk
Copy link
Contributor

hugovk commented Nov 1, 2019

exclude: would stop it running all checks on all RST files, right?

It's better than nothing, but that would mean 145 RST files are never checked at all, which I think is worse than skipping one check in those files.

Perhaps it could be an option for those who happen to run into this?

@roskakori
Copy link

Another workaround would be to change the ReSTructured text files to use one of the other available characters to mark section headings, for example ###### or ******.

roskakori added a commit to roskakori/pygount that referenced this issue Jun 27, 2023
This works around the overly enthusiastic pre-commit check for merhe conflicts as described in <pre-commit/pre-commit-hooks#100>.
@pre-commit pre-commit locked as resolved and limited conversation to collaborators Jun 27, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Development

No branches or pull requests

5 participants