Making it easy to write pre/post-commit hooks

Review Request #9236 — Created Sept. 29, 2017 and discarded

Information

RBTools
master

Reviewers

Applies the 0001-WIP-Repository-hooks-support.patch that Christian Hammond
created.

Adds the repo-hook command to make it easy to use pre and post commit hooks. The
supported repositories are Git, Mercurial and SVN.

Ran nosetests -v; all tests pass with patch applied.

Created unit tests for all functions.

Ran nosetests -v; all tests passed.

Description From Last Updated

F401 'json' imported but unused

reviewbotreviewbot

F401 'six.moves.urllib.request.urlopen' imported but unused

reviewbotreviewbot

F401 'rbtools.api.tests.MockResponse' imported but unused

reviewbotreviewbot

F401 'rbtools.clients.svn.SVNClient' imported but unused

reviewbotreviewbot

E265 block comment should start with '# '

reviewbotreviewbot

E265 block comment should start with '# '

reviewbotreviewbot

E265 block comment should start with '# '

reviewbotreviewbot

E265 block comment should start with '# '

reviewbotreviewbot

F811 redefinition of unused 'RepositoryInfo' from line 10

reviewbotreviewbot

F811 redefinition of unused 'SCMClient' from line 10

reviewbotreviewbot

F811 redefinition of unused 'PatchResult' from line 10

reviewbotreviewbot

E302 expected 2 blank lines, found 1

reviewbotreviewbot

F811 redefinition of unused 'PatchResult' from line 10

reviewbotreviewbot

F811 redefinition of unused 'RepositoryInfo' from line 10

reviewbotreviewbot

F811 redefinition of unused 'SCMClient' from line 10

reviewbotreviewbot

F401 'rbtools.hooks.common.get_review_request_id' imported but unused

reviewbotreviewbot

E302 expected 2 blank lines, found 1

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E128 continuation line under-indented for visual indent

reviewbotreviewbot

W391 blank line at end of file

reviewbotreviewbot

E226 missing whitespace around arithmetic operator

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

Have you checked what happens when the commit message contains a colon+space separator (:)? The regex looks like it would …

bleblan2bleblan2

E226 missing whitespace around arithmetic operator

reviewbotreviewbot

E226 missing whitespace around arithmetic operator

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

run_from_argv now returns the exit code, as opposed to calling sys.exit(exit_code). I'd consider adding what it returns to the function's …

NI nicho
Checks run (1 failed, 1 succeeded)
flake8 failed.
JSHint passed.

flake8

GR
Review request changed

Description:

~  

Applies the 0001-WIP-Repository-hooks-support.patch that Christian Hammond gave me as a skeleton to start with. No other changes have been made yet, as I'm still going through the code.

  ~

Applies the 0001-WIP-Repository-hooks-support.patch that Christian Hammond gave

  + me as a skeleton to start with. No other changes have been made yet, as I'm
  + still going through the code.

  +
  +

Oct 1 - 8

  + Fixed common.py to make the old hook method work so I could test it and learn
  + how it works. Found the common.py fix in https://reviews.reviewboard.org/r/9198/
  + Started working through repo_hook.py and learned that the code Christian Hammond
  + gave me comes with working git functionality.

Testing Done:

   

Ran nosetests -v; all tests pass with patch applied.

  +
  +

Oct 1 - 8

  + Manually tested the repo-hook command by making hooks for pre-receive and
  + post-receive in a local remote repository. I made changes and pushed the changes
  + to test the pre-receive hook, it denied the push as expected because the review
  + request was not marked "Ship It". Allowing the push to succeed caused the
  + post-receive code close the review-request.

Commit:

-39f4e50ab9c9271572eab66b55b0cd2f2add6415
+1ea1b5644830abc5a0f1a7caf72d5bf2e7c9333f

Diff:

Revision 2 (+409 -16)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

GR
GR
GR
Review request changed

Change Summary:

Started svn repository hooks unit tests and added basics to Mercurial.

Commit:

-d76a380ab6e7560b4b7e6bb042cbe6aebc307c01
+c97ca4a0b39aff638a2ad0ab3f56befd41c5d37d

Diff:

Revision 5 (+466 -17)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

GR
Review request changed

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

GR
Review request changed

Change Summary:

Working Mercurial pre-commit hooks. Fixed Flake8 errors.

Commit:

-ba97b9f4c0ba14ed0b9559eefdf10072c8a3c9ed
+1a4d2395433934d6f0ac781bc96a4e406c8c71a3

Diff:

Revision 7 (+519 -18)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

GR
Review request changed

Change Summary:

Added Mercurial tests, Changed SVN to make Post-commit work, still not working atm. Changed Repo_hook to use command arguments for input

Commit:

-1a4d2395433934d6f0ac781bc96a4e406c8c71a3
+769cf363965c7c286c9da5893d9b53bf807fa23b

Diff:

Revision 8 (+559 -19)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

bleblan2
  1. Just a note about the regex being used for parsing the mercurial logs.

  2. rbtools/clients/mercurial.py (Diff revision 8)
     
     
    Show all issues

    Have you checked what happens when the commit message contains a colon+space separator (:)? The regex looks like it would end up splitting a commit message if it is there.

    I'm also guessing the regex would split multiline commit messages at the newline.

    1. Good call. It will mess up. Thanks, I'll change the way I do it.

  3. 
      
GR
GR
GR
NI
  1. 
      
  2. rbtools/commands/__init__.py (Diff revision 11)
     
     
    Show all issues

    run_from_argv now returns the exit code, as opposed to calling sys.exit(exit_code). I'd consider adding what it returns to the function's docstring.

  3. 
      
GR
GR
david
Review request changed

Status: Discarded

Loading...