Skip to content
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

Option to force run check-merge-conflict #300

Closed
vinayinvicible opened this issue Jun 24, 2018 · 5 comments
Closed

Option to force run check-merge-conflict #300

vinayinvicible opened this issue Jun 24, 2018 · 5 comments

Comments

@vinayinvicible
Copy link
Contributor

check-merge-conflict only runs when it detects merge/rebase in progress.
This means it will always pass on CI setups.

Am not sure if this should be fixed specifically for check-merge-conflict or make a generic CI functionality available via pre-commit

@asottile
Copy link
Member

This is a bit intentional, the hook is especially susceptible to false positives when run outside of a merge conflict due to matching things like this

That said, you could easily write a local pygrep hook which works almost the same, something like this:

-   repo: local
    hooks:
    -   id: naive-check-merge-conflict
        name: naive check-merge-conflict
        entry: '^(<<<<<<< |======= |>>>>>>> |=======$)'
        language: pygrep

for example against pre-commit-hooks:

$ pre-commit run naive-check-merge-conflict --all-files
naive check-merge-conflict...............................................Failed
hookid: naive-check-merge-conflict

CHANGELOG.md:39:=======

Might be able to get away with exclude_types: [markdown] to make it work better?

$ pre-commit run naive-check-merge-conflict --all-files
naive check-merge-conflict...............................................Passed

@vinayinvicible
Copy link
Contributor Author

Setting up a local hook will run it on developer's machine too.

Our codebase is huge and we were not using pre-commits from the start. So, CI is setup to run using source and origin options instead of all files.

So, I am just looking for a way to trigger this hook on our CI setup.

@asottile
Copy link
Member

Here's some previous ideas I've sketched out for running a different set of hooks in CI vs locally: pre-commit/pre-commit#765 (comment)

basically two ideas: either using stages: [manual] or separate config files with -c

@vinayinvicible
Copy link
Contributor Author

I wasn't aware of manual stage being added.
Even to use this, I don't want to duplicate the merge conflict logic into pygrep. Is it possible to support --force as an optional argument for check-merge-conflict.

@asottile
Copy link
Member

Sure, would need a PR but I'd accept that :)

Maybe --assume-in-conflict?

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

No branches or pull requests

2 participants