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

Overcommit taking long time to exit #720

Closed
thecouchcoder opened this issue Jun 20, 2020 · 5 comments
Closed

Overcommit taking long time to exit #720

thecouchcoder opened this issue Jun 20, 2020 · 5 comments
Labels

Comments

@thecouchcoder
Copy link

I am new to overcommit, so it's likely I'm doing something wrong.

In a post commit hook I am trying to generate new files then add them to the previous commit. The functionality works perfect (files are generated, staged, and then amended to the commit). However, overcommit takes ~10 minutes to exit. If I use ctrl+c to exit then everything is fine because the commit hook did work correctly. I am stuck at this stage:
image

Here is my overcommit.yml

PostCommit:
    GeneratePages:
        enabled: true
        command: ['python', 'generator.py']
    AddTags:
        enabled: true
        command: ['git', 'add', './_tag-entries']
    AmendCommit:
        enabled: true
        command: ['git', 'commit', '--amend', '--no-edit']
@sds sds added the question label Jun 25, 2020
@sds
Copy link
Owner

sds commented Jun 25, 2020

Hey @aes421, I don't have an immediate answer to why your hook runs take 10 minutes. That is certainly odd.

With that said, post-commit hooks are run after commit, so the fact that you are not seeing their output until 10 minutes later suggests it is one of your hooks. You can set the OVERCOMMIT_DEBUG=1 environment variable to get timing information so you can understand which hook is the slow one.

Also note: as discussed in #238 Overcommit does not support pre-commit hooks with file-changing side-effects. In this case, I'm not aware of anything preventing this working with post-commit hooks, but I personally haven't tried. Just want you to be aware that there may be some other issue with what you are trying to do.

Hope this helps! I'm going to close in the meantime as I'm pretty sure this is something to do with the python generator.py command, as that seems like something that could suspiciously take a long time. Feel free to reopen if you discover something suggesting this is Overcommit. Thanks!

@sds sds closed this as completed Jun 25, 2020
@pillarsdotnet
Copy link

pillarsdotnet commented Jul 7, 2020

@sds

I ran into the same problem as @aes421 -- I think it happens because the post-commit hook has a git commit command, which calls overcommit, which calls the post-commit hook... (recursion!)

I did the following, which seems to be working:

PostCommit:
  GenerateDocs:
    enabled: true
    command: ['bash', '-c', 'overcommit -u ; puppet strings generate --format markdown ; git add REFERENCE.md ; git commit REFERENCE.md --amend --no-edit ; overcommit -i']

@sds
Copy link
Owner

sds commented Jul 8, 2020

You could also set OVERCOMMIT_DISABLE=1 instead of overcommit -u / overcommit -i to avoid uninstalling/reinstalling the hooks. But I'll emphasize this isn't a supported workflow today.

@thecouchcoder
Copy link
Author

Changing my post commit hook to the following as @pillarsdotnet mentioned works.

PostCommit:
    GenerateTagPages:
        enabled: true
        command: ['python', 'tag-generator.py']
    AmendCommit:
        enabled: true
        command: ['bash', '-c', 'overcommit -u; git add ./_tag-entries; git commit --amend --no-edit; overcommit -i;']

I tried using
command: ['bash', '-c', 'OVERCOMMIT_DISABLE=1 git add ./_tag-entries; git commit --amend --no-edit;']
since it looks cleaner, but it still caused an infinite loop.

I also tried
command: ['OVERCOMMIT_DISABLE=1 git add ./_tag-entries; git commit --amend --no-edit;']
but I get the error FAILED
'"OVERCOMMIT_DISABLE' is not recognized as an internal or external command,
operable program or batch file.

@pillarsdotnet
Copy link

pillarsdotnet commented Jul 13, 2020

@aes421 -- You need to export the environment variable in order for git to see it:

command: ['bash', '-c', 'export OVERCOMMIT_DISABLE=1 ; git add ./_tag-entries; git commit --amend --no-edit;']

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

No branches or pull requests

3 participants