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

conflict with git precommit hook #149

Open
sunew opened this issue Nov 17, 2015 · 12 comments
Open

conflict with git precommit hook #149

sunew opened this issue Nov 17, 2015 · 12 comments

Comments

@sunew
Copy link

sunew commented Nov 17, 2015

plone.recipe.codeanalysis installs a precommit hook running flake8 etc. But the output from the hook causes zest.releaser to hang:

OK to commit this (Y/n)? y
DEBUG: Running command: u'git commit -a -m "Preparing release 0.3.4"'

and nothing happens (waited several minutes)

Running the git command manually afterwards works fine - but with a lot of output from the hook.

Removing the hook makes the prerelease proces work. (After reverting and restarting)

The hook output in my case is very long (above 600 lines of text). I'm not sure if smaller amounts of hook output causes any trouble.

Traceback from ctrl-c, if it can help:

Traceback (most recent call last):
  File "../bin/prerelease", line 11, in <module>
    sys.exit(main())
  File "/work/tools/pythontools/local/lib/python2.7/site-packages/zest/releaser/prerelease.py", line 241, in main
    prereleaser.run()
  File "/work/tools/pythontools/local/lib/python2.7/site-packages/zest/releaser/baserelease.py", line 42, in run
    self.execute()
  File "/work/tools/pythontools/local/lib/python2.7/site-packages/zest/releaser/prerelease.py", line 84, in execute
    self._diff_and_commit()
  File "/work/tools/pythontools/local/lib/python2.7/site-packages/zest/releaser/prerelease.py", line 228, in _diff_and_commit
    commit = execute_command(commit_cmd)
  File "/work/tools/pythontools/local/lib/python2.7/site-packages/zest/releaser/utils.py", line 651, in execute_command
    result = _execute_command(command)
  File "/work/tools/pythontools/local/lib/python2.7/site-packages/zest/releaser/utils.py", line 577, in _execute_command
    stdout_output = o.read()
KeyboardInterrupt
@reinout
Copy link
Collaborator

reinout commented Nov 17, 2015

Is the hook asking for some input? Or is it "just" a matter of the output not being what zest.releaser expects?

@sunew
Copy link
Author

sunew commented Nov 17, 2015

It does not ask for input - so probably "just" a matter of the output not being what zest.releaser expects

@reinout
Copy link
Collaborator

reinout commented Nov 17, 2015

I have that codeanalysis thingy in one of my own projects, too, but I haven't seen a problem with fullrelease.

You're saying that you see a lot of output from the hook. I fixed the few errors that codeanalysis reported (and quieted down the rest) for that project of mine before releasing it, so I didn't have the problem.

Can you paste the first and last 20 lines of output? Perhaps than we can spot something that throws zest.releaser off guard.

@mauritsvanrees: do you have any clue? You're probably using the codeanalysis recipe more often than I do :-)

@sunew
Copy link
Author

sunew commented Nov 17, 2015

My guess is that it could be the amount of output that causes the problem. I had my hook on a bobtemplate project, so a lot of what I consider false negatives (generated bootstrap files etc.).

These I can of course ignore. But for now it is good for debugging the problem...

sune@sune-T440:/work/tools/pythontools/bobtemplates.zitelab (master)$ git commit -a
Flake8..........................[ FAILURE ] in 0.727s
/work/tools/pythontools/bobtemplates.zitelab/tests.py:0:1: C101 Coding magic comment not found
/work/tools/pythontools/bobtemplates.zitelab/tests.py:31:80: E501 line too long (80 > 79 characters)
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/__init__.py:0:1: C101 Coding magic comment not found
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/zitelab/__init__.py:0:1: C101 Coding magic comment not found
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/zitelab/hooks.py:104:1: E302 expected 2 blank lines, found 1
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/zitelab/hooks.py:110:1: E302 expected 2 blank lines, found 1
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/zitelab/hooks.py:250:1: E303 too many blank lines (3)
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/zitelab/zitelab_plone5_buildout/create_virtualenv_bootstrap.py:0:1: C101 Coding magic comment not found
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/zitelab/zitelab_plone5_buildout/create_virtualenv_bootstrap.py:1:18: E401 multiple imports on one line
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/zitelab/zitelab_plone5_buildout/create_virtualenv_bootstrap.py:9:80: E501 line too long (87 > 79 characters)
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/zitelab/zitelab_plone5_buildout/create_virtualenv_bootstrap.py:27:80: E501 line too long (109 > 79 characters)
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/zitelab/zitelab_plone5_buildout/create_virtualenv_bootstrap.py:29:80: E501 line too long (87 > 79 characters)
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/zitelab/zitelab_plone5_buildout/create_virtualenv_bootstrap.py:31:80: E501 line too long (123 > 79 characters)
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/zitelab/zitelab_plone_buildout/create_virtualenv_bootstrap.py:0:1: C101 Coding magic comment not found
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/zitelab/zitelab_plone_buildout/create_virtualenv_bootstrap.py:1:18: E401 multiple imports on one line
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/zitelab/zitelab_plone_buildout/create_virtualenv_bootstrap.py:9:80: E501 line too long (87 > 79 characters)
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/zitelab/zitelab_plone_buildout/create_virtualenv_bootstrap.py:27:80: E501 line too long (109 > 79 characters)
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/zitelab/zitelab_plone_buildout/create_virtualenv_bootstrap.py:29:80: E501 line too long (87 > 79 characters)
/work/tools/pythontools/bobtemplates.zitelab/build/lib.linux-x86_64-2.7/bobtemplates/zitelab/zitelab_plone_buildout/create_virtualenv_bootstrap.py:31:80: E501 line too long (123 > 79 characters)
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/__init__.py:0:1: C101 Coding magic comment not found

...

/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:1888:5: E265 block comment should start with '# '
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:1891:5: E265 block comment should start with '# '
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:1903:25: E128 continuation line under-indented for visual indent
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:1904:25: E128 continuation line under-indented for visual indent
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:1905:25: E124 closing bracket does not match visual indentation
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:1916:1: E302 expected 2 blank lines, found 1
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:1924:1: E265 block comment should start with '# '
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:2069:1: E265 block comment should start with '# '
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:2088:1: E265 block comment should start with '# '
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:2108:1: E265 block comment should start with '# '
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:2123:1: E265 block comment should start with '# '
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:2131:1: E265 block comment should start with '# '
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:2138:1: E265 block comment should start with '# '
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:2229:1: E265 block comment should start with '# '
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:2256:1: E265 block comment should start with '# '
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:2263:1: E265 block comment should start with '# '
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:2367:80: E501 line too long (92 > 79 characters)
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:2401:80: E501 line too long (89 > 79 characters)
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:2419:1: E265 block comment should start with '# '
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:2420:1: E265 block comment should start with '# '
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/bootstrap-virtualenv.py:2421:1: E265 block comment should start with '# '
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/create_virtualenv_bootstrap.py:0:1: C101 Coding magic comment not found
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/create_virtualenv_bootstrap.py:1:18: E401 multiple imports on one line
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/create_virtualenv_bootstrap.py:12:80: E501 line too long (87 > 79 characters)
/work/tools/pythontools/bobtemplates.zitelab/bobtemplates/zitelab/zitelab_plone_buildout/create_virtualenv_bootstrap.py:17:80: E501 line too long (86 > 79 characters)
[master 1d6f2d6] test
 1 file changed, 2 insertions(+)

@mauritsvanrees
Copy link
Member

I was going to say: "I cannot reproduce this." But I can. :-)
I have created a new project with mrbob -O test.template bobtemplates:plone_addon.

That has this recipe:

[code-analysis]
recipe = plone.recipe.codeanalysis
directory = ${buildout:directory}/src/test
flake8-exclude = bootstrap.py,bootstrap-buildout.py,docs,*.egg.,omelette
flake8-max-complexity = 15
flake8-extensions =
    flake8-blind-except
    flake8-debugger
    flake8-coding

All goes fine then. But then I make a few changes so the script checks the current directory and does not exclude parts/omelette:

[code-analysis]
recipe = plone.recipe.codeanalysis
# directory = ${buildout:directory}/src/test
directory = ${buildout:directory}
# Does not really matter: return-status-codes = True
# flake8-exclude = bootstrap.py,bootstrap-buildout.py,docs,*.egg.,omelette
flake8-max-complexity = 15
flake8-extensions =
    flake8-blind-except
    flake8-debugger
    flake8-coding

Running bin/code-analysis creates 194 KB of output. Takes about two seconds. Should not really be a problem. A manual git commit works. But when you do the prerelease, zest.releaser hangs reading the stdout of subprocess.Popen. With a pdb in there I see no difference between the stdout of this and other commands: the class is the same and the file is not closed. And reading line by line through the output does not help either: it waits on the first line.

I wonder if code-analysis has somehow eaten up the output.
@gforcada: Have you seen this before?

@gforcada
Copy link
Contributor

@mauritsvanrees no, first time seeing it... looks weird, I will try to look at it

@reinout
Copy link
Collaborator

reinout commented Apr 3, 2019

Is this still a problem? (I'm looking through old issues)

@odelaere
Copy link

odelaere commented Jan 9, 2020

UP !
I'm having the same issue

@reinout
Copy link
Collaborator

reinout commented Jan 9, 2020

Brainstorming: does one of the pre-commit hooks "mess" with the stdin/stdout?

@odelaere : do you have more details? Which pre-commit hooks you're using, for instance?

@odelaere
Copy link

odelaere commented Jan 9, 2020

@reinout Nothing mess in the terminal. it just hangs waiting (I suppose) for something to respond.
It seems to be the same error as sunew. plone.recipe.codeanalysis screws it and the commit is never performed.
But the changes are staged for commit though.
I have just one pre-commit hook which is Flake8.
Removing the pre-commit is working.
Right now i am trying to twist the flake8 config for zest to work.

@odelaere
Copy link

odelaere commented Jan 9, 2020

@reinout It appears zest keep hanging while trying to commit if the pre-commit hook returns a failure.
it worked when it returns an OK status

@regebro
Copy link

regebro commented Mar 28, 2022

It doesn't hang for me, it just continues without committing, which is very confusing.

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

No branches or pull requests

6 participants