Implementing a repo-hook command to provide standardized repo hook script functionality for RBTools

Review Request #11492 — Created Feb. 26, 2021 and updated

TheArcticGiraffe
RBTools
master
students

High-Level Description

This feature is meant to give some hook script functionality for RBTools through a new command, repo-hook. Specifically, the repo-hook command allows users to call RBTools based pre-receive and post-receive hook script functionality from their own hook scripts.

The pre-receive functionality is focused on checking commits in the incoming push for review request IDs, and possibly cancelling the push if criteria are not met. This criteria depends on whether certain options are activated or left default (--dont-require-review-requests and --allow-unapproved-push). By default, the push will be cancelled if there are any commits without review requests, or if any review requests are not approved.

The post-receive functionality is based on closing any review requests referenced in commit messages in the current push. In this instance, a push cannot be cancelled, and warnings will be raised if there are commits with no review requests.

Initial Plans

Initial plans for this command were to have hook script functionality for multiple SCM systems, specifically starting with Git, Mercurial, and Subversion. At this point, only functionality for Git has been implemented, with skeleton code and empty classes being implemented for SVN and Mercurial.

How the Code Works Together

This functionality is performed by a RepoHook Command class. This class will perform all the SCM agnostic logic of the hook scripts. From this class, depending on the --repo-type option specified (again, currently only Git is an option), a SCMRepositoryHooks subclass representing the repository in --repo-type will be called to provide RepoHook with the information it needs in order to work, while performing all SCM specific code within it's own class.

Next Steps

Next steps would involve getting code reviews to confirm that the Git and RepoHook logic are bug-free, as well as implementing the SVN and Mercurial logic in their corresponding classes to allow more variety of SCMs.

Additionally, outside of initial scope, other hook types could be implemented. One that would prove useful is pre-commit functionality to ensure that a review request ID is included in the commit message. This would help avoid issues with using the pre-receive functionality, as the only issue that could arise would be that a review request is not approved.

Have done local testing with a local Git repository on my machine containing pre-receive and post-receive hook scripts that call the rbt repo-hook command to ensure that the code works.

Have created a suite of tests to test various options and how they would cause the RepoHook command to react. This includes testing all variations of --repo-type and --hook-type (allowed, un-implemented, no variant selected, and default value), default and specified server options, regex flag options, and both variations of all other toggle-able options.

Summary
Adding in-progress files.
Added new options to repo-hook command based on the functionality in contrib\tools\git-hook-set-submitted and contrib\tools\git-hook-check-approval. Followed same default values as found in these two hook scripts.
Fixed a few flake8 failure, and added in standard regex flag from contrib\tools\git-hook-set-submitted\n and contrib\tools\git-hook-check-approval as an option in the repo-hook command
Brought functionality from git.py over to the GitRepositoryHooks class. This may change, but this is a starting point
Changed the wording and working of a few commands, so that the default is standard and it lexically makes sense for the user to add the option as a way to enable the function (e.g. --require-review-requests changed to dont-require-review-requests, and changed the default from True to False). As well, a few minor tab and line length errors were corrected
This commit was an error fixing commit. Fixed some missed commas in the Options section, fixed a mispelling of store_true, fixed an error of using ! instead of not.
Added option for specifying the type of repository repository being used (--repo-type).
Minor change, adding self variable to a class method inside SECRepositoryHooks class
Added the common lines between /contrib/tools/git-hook-set-submitted and /contrib/tools/git-hook-check-approval to rbtools/commands/repo_hook.py in the RepoHook Command subclass as the default behaviour before hook-type specific behaviour is taken
Removed unnecessary debug code from RepoHook class and its helper classes, and cleaned up the code a little.
Brought logic for the pre-receive and post-receive functionality from /contrib/tools/git-hook-check-approval and /contrib/tools/git-hook-set-submitted into the pre_receive() and post_receive() methods of the RepoHook class.
Went through all flake8 errors that occured throughout the first 3 posts to ReviewBoard
More flake8 issue fixing.
Review Request #11492
Altered how repo_hook command accesses SCMRepositoryHooks subclasses. Now, repo_hook will call on the correcponsing SCM client, of which each now has a repository_hooks_class class attribute. The repo_hook command can access the corresponsing SCMRepositoryHooks subclass depending on the --repo-type supplied in the command. Skeleton code for the SVNRepositoryHooks and MercurialRepositoryHooks classes have been created to make sure all functionality is working. Also changed the GitRepositoryHooks class to no longer need to be supplied a copy of the RepoHook class (incorrect idea about code layout. Review Request #11492.
Fixed all current flake8 errors via local version of flake8
Minor changes, added sys.exit(1) for bad result in order for pre-receive hook to know what happened. Fixed some uncaught name spelling errors and other issues. Review Request #11492
Reorganized how rbtools/command/repo-hook.py and rbtools/clients/scmrepositoryhooks.py and all it's subclasses functioned. Previously, RepoHook called the functionality it needed from methods in the SCMRepositoryHooks directly. Now, depending on the hook-type passed in (pre-receive, post-receive, etc), RepoHook will call the corresponding method in the SCMRepositoryHooks subclass (e.g. SCMRepositoryHooks.pre_receive()) in order to get the stuff it needs. This is done so that the method calls will be the same, regardless of what SCM the hook is being used for.
Minor tweaks to some method calls for the post-receive hook side of repo-hook. Errors found with passing too many arguments or passing arguments the incorrect way.
Added tests for RepoHook command, including checking proper fetching of GitRepositoryHooks class, exit from system in case of calling 'svn', 'mercurial' or an invalid repo type for repo-type, saving of server options, properly setting regex flags, and testing for exiting when given invalid hook-type.
Added tests for valid --hook-types, the default hook_type, default repo_type, the default values for server options, and the default and activated states of calling --require-approval, --dont-require-review-requests, and --allow-unapproved-push.
Added documentation where needed, and fixed bad/non-compliant documentation
Fixed a minor flake8 error in rbtools/clients/scmrepositoryhooks.py. Review request #11492
Description From Last Updated

E303 too many blank lines (3)

reviewbotreviewbot

E999 IndentationError: expected an indented block

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

W292 no newline at end of file

reviewbotreviewbot

F401 'sys' imported but unused

reviewbotreviewbot

F401 'rbtools.clients.errors.InvalidRevisionSpecError' imported but unused

reviewbotreviewbot

F401 'rbtools.commands.CommandError' imported but unused

reviewbotreviewbot

F401 'six' imported but unused

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

E501 line too long (82 > 79 characters)

reviewbotreviewbot

F821 undefined name 'REVIEWBOARD_URL'

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

F821 undefined name 're'

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

W293 blank line contains whitespace

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

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

W293 blank line contains whitespace

reviewbotreviewbot

W293 blank line contains whitespace

reviewbotreviewbot

F401 'logging' imported but unused

reviewbotreviewbot

F401 'subprocess' imported but unused

reviewbotreviewbot

E302 expected 2 blank lines, found 1

reviewbotreviewbot

E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

E501 line too long (82 > 79 characters)

reviewbotreviewbot

E501 line too long (82 > 79 characters)

reviewbotreviewbot

E128 continuation line under-indented for visual indent

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

E501 line too long (82 > 79 characters)

reviewbotreviewbot

E128 continuation line under-indented for visual indent

reviewbotreviewbot

F821 undefined name 'get_excluded_branches'

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

E501 line too long (83 > 79 characters)

reviewbotreviewbot

E501 line too long (80 > 79 characters)

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

E501 line too long (80 > 79 characters)

reviewbotreviewbot

E128 continuation line under-indented for visual indent

reviewbotreviewbot

E501 line too long (81 > 79 characters)

reviewbotreviewbot

F821 undefined name 'get_branches_containing_commit'

reviewbotreviewbot

E501 line too long (82 > 79 characters)

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

F821 undefined name 'subprocess'

reviewbotreviewbot

F821 undefined name 'subprocess'

reviewbotreviewbot

F821 undefined name 'logging'

reviewbotreviewbot

E501 line too long (82 > 79 characters)

reviewbotreviewbot

W292 no newline at end of file

reviewbotreviewbot

F401 'logging' imported but unused

reviewbotreviewbot

F401 'subprocess' imported but unused

reviewbotreviewbot

E302 expected 2 blank lines, found 1

reviewbotreviewbot

E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

E251 unexpected spaces around keyword / parameter equals

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

E501 line too long (82 > 79 characters)

reviewbotreviewbot

E501 line too long (82 > 79 characters)

reviewbotreviewbot

E128 continuation line under-indented for visual indent

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

E501 line too long (82 > 79 characters)

reviewbotreviewbot

E128 continuation line under-indented for visual indent

reviewbotreviewbot

F821 undefined name 'get_excluded_branches'

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

E501 line too long (83 > 79 characters)

reviewbotreviewbot

E501 line too long (80 > 79 characters)

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

E501 line too long (80 > 79 characters)

reviewbotreviewbot

E128 continuation line under-indented for visual indent

reviewbotreviewbot

F821 undefined name 'get_branches_containing_commit'

reviewbotreviewbot

E501 line too long (81 > 79 characters)

reviewbotreviewbot

E501 line too long (82 > 79 characters)

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

F821 undefined name 'subprocess'

reviewbotreviewbot

F821 undefined name 'subprocess'

reviewbotreviewbot

F821 undefined name 'logging'

reviewbotreviewbot

E501 line too long (82 > 79 characters)

reviewbotreviewbot

W292 no newline at end of file

reviewbotreviewbot

E302 expected 2 blank lines, found 1

reviewbotreviewbot

E303 too many blank lines (2)

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E126 continuation line over-indented for hanging indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E302 expected 2 blank lines, found 1

reviewbotreviewbot

F401 'subprocess' imported but unused

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E502 the backslash is redundant between brackets

reviewbotreviewbot

E501 line too long (81 > 79 characters)

reviewbotreviewbot

E502 the backslash is redundant between brackets

reviewbotreviewbot

E502 the backslash is redundant between brackets

reviewbotreviewbot

E502 the backslash is redundant between brackets

reviewbotreviewbot

E502 the backslash is redundant between brackets

reviewbotreviewbot

E502 the backslash is redundant between brackets

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E502 the backslash is redundant between brackets

reviewbotreviewbot

E502 the backslash is redundant between brackets

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

W291 trailing whitespace

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

F401 'logging' imported but unused

reviewbotreviewbot

F401 'subprocess' imported but unused

reviewbotreviewbot

F401 'logging' imported but unused

reviewbotreviewbot

F401 'subprocess' imported but unused

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

E127 continuation line over-indented for visual indent

reviewbotreviewbot

F401 'rbtools.clients.mercurial.MercurialClient' imported but unused

reviewbotreviewbot

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

reviewbotreviewbot

E128 continuation line under-indented for visual indent

reviewbotreviewbot

E128 continuation line under-indented for visual indent

reviewbotreviewbot

W503 line break before binary operator

reviewbotreviewbot

W503 line break before binary operator

reviewbotreviewbot

W391 blank line at end of file

reviewbotreviewbot

W503 line break before binary operator

reviewbotreviewbot

W503 line break before binary operator

reviewbotreviewbot

W503 line break before binary operator

reviewbotreviewbot

W503 line break before binary operator

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

flake8

TheArcticGiraffe
Review request changed

Change Summary:

Brought basic functionality from git.py and common.py into RepoHook class, SCMRepositoryHooks class, and GitRespositoryHooks class. Will continue working on the functionality to improve it.

Commits:

Summary
-
Adding in-progress files.
+
Adding in-progress files.
+
Added new options to repo-hook command based on the functionality in contrib\tools\git-hook-set-submitted and contrib\tools\git-hook-check-approval. Followed same default values as found in these two hook scripts.
+
Fixed a few flake8 failure, and added in standard regex flag from contrib\tools\git-hook-set-submitted\n and contrib\tools\git-hook-check-approval as an option in the repo-hook command
+
Brought functionality from git.py over to the GitRepositoryHooks class. This may change, but this is a starting point
+
Changed the wording and working of a few commands, so that the default is standard and it lexically makes sense for the user to add the option as a way to enable the function (e.g. --require-review-requests changed to dont-require-review-requests, and changed the default from True to False). As well, a few minor tab and line length errors were corrected
+
This commit was an error fixing commit. Fixed some missed commas in the Options section, fixed a mispelling of store_true, fixed an error of using ! instead of not.
+
Added option for specifying the type of repository repository being used (--repo-type).

Groups:

-rbtools
+students

Diff:

Revision 2 (+1158 -294)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

TheArcticGiraffe
Review request changed

Change Summary:

Brought remaining logic from existing Git hook scripts into repo-hook command

Commits:

Summary
-
Adding in-progress files.
-
Added new options to repo-hook command based on the functionality in contrib\tools\git-hook-set-submitted and contrib\tools\git-hook-check-approval. Followed same default values as found in these two hook scripts.
-
Fixed a few flake8 failure, and added in standard regex flag from contrib\tools\git-hook-set-submitted\n and contrib\tools\git-hook-check-approval as an option in the repo-hook command
-
Brought functionality from git.py over to the GitRepositoryHooks class. This may change, but this is a starting point
-
Changed the wording and working of a few commands, so that the default is standard and it lexically makes sense for the user to add the option as a way to enable the function (e.g. --require-review-requests changed to dont-require-review-requests, and changed the default from True to False). As well, a few minor tab and line length errors were corrected
-
This commit was an error fixing commit. Fixed some missed commas in the Options section, fixed a mispelling of store_true, fixed an error of using ! instead of not.
-
Added option for specifying the type of repository repository being used (--repo-type).
+
Adding in-progress files.
+
Added new options to repo-hook command based on the functionality in contrib\tools\git-hook-set-submitted and contrib\tools\git-hook-check-approval. Followed same default values as found in these two hook scripts.
+
Fixed a few flake8 failure, and added in standard regex flag from contrib\tools\git-hook-set-submitted\n and contrib\tools\git-hook-check-approval as an option in the repo-hook command
+
Brought functionality from git.py over to the GitRepositoryHooks class. This may change, but this is a starting point
+
Changed the wording and working of a few commands, so that the default is standard and it lexically makes sense for the user to add the option as a way to enable the function (e.g. --require-review-requests changed to dont-require-review-requests, and changed the default from True to False). As well, a few minor tab and line length errors were corrected
+
This commit was an error fixing commit. Fixed some missed commas in the Options section, fixed a mispelling of store_true, fixed an error of using ! instead of not.
+
Added option for specifying the type of repository repository being used (--repo-type).
+
Minor change, adding self variable to a class method inside SECRepositoryHooks class
+
Added the common lines between /contrib/tools/git-hook-set-submitted and /contrib/tools/git-hook-check-approval to rbtools/commands/repo_hook.py in the RepoHook Command subclass as the default behaviour before hook-type specific behaviour is taken
+
Removed unnecessary debug code from RepoHook class and its helper classes, and cleaned up the code a little.
+
Brought logic for the pre-receive and post-receive functionality from /contrib/tools/git-hook-check-approval and /contrib/tools/git-hook-set-submitted into the pre_receive() and post_receive() methods of the RepoHook class.

Diff:

Revision 3 (+1357 -433)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

TheArcticGiraffe
TheArcticGiraffe
Review request changed

Change Summary:

Went through all flake8 errors from revision 1-3 and fixed them.

Commits:

Summary
-
Adding in-progress files.
-
Added new options to repo-hook command based on the functionality in contrib\tools\git-hook-set-submitted and contrib\tools\git-hook-check-approval. Followed same default values as found in these two hook scripts.
-
Fixed a few flake8 failure, and added in standard regex flag from contrib\tools\git-hook-set-submitted\n and contrib\tools\git-hook-check-approval as an option in the repo-hook command
-
Brought functionality from git.py over to the GitRepositoryHooks class. This may change, but this is a starting point
-
Changed the wording and working of a few commands, so that the default is standard and it lexically makes sense for the user to add the option as a way to enable the function (e.g. --require-review-requests changed to dont-require-review-requests, and changed the default from True to False). As well, a few minor tab and line length errors were corrected
-
This commit was an error fixing commit. Fixed some missed commas in the Options section, fixed a mispelling of store_true, fixed an error of using ! instead of not.
-
Added option for specifying the type of repository repository being used (--repo-type).
-
Minor change, adding self variable to a class method inside SECRepositoryHooks class
-
Added the common lines between /contrib/tools/git-hook-set-submitted and /contrib/tools/git-hook-check-approval to rbtools/commands/repo_hook.py in the RepoHook Command subclass as the default behaviour before hook-type specific behaviour is taken
-
Removed unnecessary debug code from RepoHook class and its helper classes, and cleaned up the code a little.
-
Brought logic for the pre-receive and post-receive functionality from /contrib/tools/git-hook-check-approval and /contrib/tools/git-hook-set-submitted into the pre_receive() and post_receive() methods of the RepoHook class.
+
Adding in-progress files.
+
Added new options to repo-hook command based on the functionality in contrib\tools\git-hook-set-submitted and contrib\tools\git-hook-check-approval. Followed same default values as found in these two hook scripts.
+
Fixed a few flake8 failure, and added in standard regex flag from contrib\tools\git-hook-set-submitted\n and contrib\tools\git-hook-check-approval as an option in the repo-hook command
+
Brought functionality from git.py over to the GitRepositoryHooks class. This may change, but this is a starting point
+
Changed the wording and working of a few commands, so that the default is standard and it lexically makes sense for the user to add the option as a way to enable the function (e.g. --require-review-requests changed to dont-require-review-requests, and changed the default from True to False). As well, a few minor tab and line length errors were corrected
+
This commit was an error fixing commit. Fixed some missed commas in the Options section, fixed a mispelling of store_true, fixed an error of using ! instead of not.
+
Added option for specifying the type of repository repository being used (--repo-type).
+
Minor change, adding self variable to a class method inside SECRepositoryHooks class
+
Added the common lines between /contrib/tools/git-hook-set-submitted and /contrib/tools/git-hook-check-approval to rbtools/commands/repo_hook.py in the RepoHook Command subclass as the default behaviour before hook-type specific behaviour is taken
+
Removed unnecessary debug code from RepoHook class and its helper classes, and cleaned up the code a little.
+
Brought logic for the pre-receive and post-receive functionality from /contrib/tools/git-hook-check-approval and /contrib/tools/git-hook-set-submitted into the pre_receive() and post_receive() methods of the RepoHook class.
+
Went through all flake8 errors that occured throughout the first 3 posts to ReviewBoard

Diff:

Revision 4 (+1397 -473)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

TheArcticGiraffe
Review request changed

Change Summary:

Fixed various flake8 issues. Altered code taken from pre-existing hook scrpits to match the new self.options.xxxxx locations for various variables.

Commits:

Summary
-
Adding in-progress files.
-
Added new options to repo-hook command based on the functionality in contrib\tools\git-hook-set-submitted and contrib\tools\git-hook-check-approval. Followed same default values as found in these two hook scripts.
-
Fixed a few flake8 failure, and added in standard regex flag from contrib\tools\git-hook-set-submitted\n and contrib\tools\git-hook-check-approval as an option in the repo-hook command
-
Brought functionality from git.py over to the GitRepositoryHooks class. This may change, but this is a starting point
-
Changed the wording and working of a few commands, so that the default is standard and it lexically makes sense for the user to add the option as a way to enable the function (e.g. --require-review-requests changed to dont-require-review-requests, and changed the default from True to False). As well, a few minor tab and line length errors were corrected
-
This commit was an error fixing commit. Fixed some missed commas in the Options section, fixed a mispelling of store_true, fixed an error of using ! instead of not.
-
Added option for specifying the type of repository repository being used (--repo-type).
-
Minor change, adding self variable to a class method inside SECRepositoryHooks class
-
Added the common lines between /contrib/tools/git-hook-set-submitted and /contrib/tools/git-hook-check-approval to rbtools/commands/repo_hook.py in the RepoHook Command subclass as the default behaviour before hook-type specific behaviour is taken
-
Removed unnecessary debug code from RepoHook class and its helper classes, and cleaned up the code a little.
-
Brought logic for the pre-receive and post-receive functionality from /contrib/tools/git-hook-check-approval and /contrib/tools/git-hook-set-submitted into the pre_receive() and post_receive() methods of the RepoHook class.
-
Went through all flake8 errors that occured throughout the first 3 posts to ReviewBoard
+
Adding in-progress files.
+
Added new options to repo-hook command based on the functionality in contrib\tools\git-hook-set-submitted and contrib\tools\git-hook-check-approval. Followed same default values as found in these two hook scripts.
+
Fixed a few flake8 failure, and added in standard regex flag from contrib\tools\git-hook-set-submitted\n and contrib\tools\git-hook-check-approval as an option in the repo-hook command
+
Brought functionality from git.py over to the GitRepositoryHooks class. This may change, but this is a starting point
+
Changed the wording and working of a few commands, so that the default is standard and it lexically makes sense for the user to add the option as a way to enable the function (e.g. --require-review-requests changed to dont-require-review-requests, and changed the default from True to False). As well, a few minor tab and line length errors were corrected
+
This commit was an error fixing commit. Fixed some missed commas in the Options section, fixed a mispelling of store_true, fixed an error of using ! instead of not.
+
Added option for specifying the type of repository repository being used (--repo-type).
+
Minor change, adding self variable to a class method inside SECRepositoryHooks class
+
Added the common lines between /contrib/tools/git-hook-set-submitted and /contrib/tools/git-hook-check-approval to rbtools/commands/repo_hook.py in the RepoHook Command subclass as the default behaviour before hook-type specific behaviour is taken
+
Removed unnecessary debug code from RepoHook class and its helper classes, and cleaned up the code a little.
+
Brought logic for the pre-receive and post-receive functionality from /contrib/tools/git-hook-check-approval and /contrib/tools/git-hook-set-submitted into the pre_receive() and post_receive() methods of the RepoHook class.
+
Went through all flake8 errors that occured throughout the first 3 posts to ReviewBoard
+
More flake8 issue fixing.
+
Review Request #11492

Diff:

Revision 5 (+1487 -549)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

TheArcticGiraffe
Review request changed

Commits:

Summary
-
Adding in-progress files.
-
Added new options to repo-hook command based on the functionality in contrib\tools\git-hook-set-submitted and contrib\tools\git-hook-check-approval. Followed same default values as found in these two hook scripts.
-
Fixed a few flake8 failure, and added in standard regex flag from contrib\tools\git-hook-set-submitted\n and contrib\tools\git-hook-check-approval as an option in the repo-hook command
-
Brought functionality from git.py over to the GitRepositoryHooks class. This may change, but this is a starting point
-
Changed the wording and working of a few commands, so that the default is standard and it lexically makes sense for the user to add the option as a way to enable the function (e.g. --require-review-requests changed to dont-require-review-requests, and changed the default from True to False). As well, a few minor tab and line length errors were corrected
-
This commit was an error fixing commit. Fixed some missed commas in the Options section, fixed a mispelling of store_true, fixed an error of using ! instead of not.
-
Added option for specifying the type of repository repository being used (--repo-type).
-
Minor change, adding self variable to a class method inside SECRepositoryHooks class
-
Added the common lines between /contrib/tools/git-hook-set-submitted and /contrib/tools/git-hook-check-approval to rbtools/commands/repo_hook.py in the RepoHook Command subclass as the default behaviour before hook-type specific behaviour is taken
-
Removed unnecessary debug code from RepoHook class and its helper classes, and cleaned up the code a little.
-
Brought logic for the pre-receive and post-receive functionality from /contrib/tools/git-hook-check-approval and /contrib/tools/git-hook-set-submitted into the pre_receive() and post_receive() methods of the RepoHook class.
-
Went through all flake8 errors that occured throughout the first 3 posts to ReviewBoard
-
More flake8 issue fixing.
-
Review Request #11492
+
Adding in-progress files.
+
Added new options to repo-hook command based on the functionality in contrib\tools\git-hook-set-submitted and contrib\tools\git-hook-check-approval. Followed same default values as found in these two hook scripts.
+
Fixed a few flake8 failure, and added in standard regex flag from contrib\tools\git-hook-set-submitted\n and contrib\tools\git-hook-check-approval as an option in the repo-hook command
+
Brought functionality from git.py over to the GitRepositoryHooks class. This may change, but this is a starting point
+
Changed the wording and working of a few commands, so that the default is standard and it lexically makes sense for the user to add the option as a way to enable the function (e.g. --require-review-requests changed to dont-require-review-requests, and changed the default from True to False). As well, a few minor tab and line length errors were corrected
+
This commit was an error fixing commit. Fixed some missed commas in the Options section, fixed a mispelling of store_true, fixed an error of using ! instead of not.
+
Added option for specifying the type of repository repository being used (--repo-type).
+
Minor change, adding self variable to a class method inside SECRepositoryHooks class
+
Added the common lines between /contrib/tools/git-hook-set-submitted and /contrib/tools/git-hook-check-approval to rbtools/commands/repo_hook.py in the RepoHook Command subclass as the default behaviour before hook-type specific behaviour is taken
+
Removed unnecessary debug code from RepoHook class and its helper classes, and cleaned up the code a little.
+
Brought logic for the pre-receive and post-receive functionality from /contrib/tools/git-hook-check-approval and /contrib/tools/git-hook-set-submitted into the pre_receive() and post_receive() methods of the RepoHook class.
+
Went through all flake8 errors that occured throughout the first 3 posts to ReviewBoard
+
More flake8 issue fixing.
+
Review Request #11492
+
Altered how repo_hook command accesses SCMRepositoryHooks subclasses. Now, repo_hook will call on the correcponsing SCM client, of which each now has a repository_hooks_class class attribute. The repo_hook command can access the corresponsing SCMRepositoryHooks subclass depending on the --repo-type supplied in the command. Skeleton code for the SVNRepositoryHooks and MercurialRepositoryHooks classes have been created to make sure all functionality is working. Also changed the GitRepositoryHooks class to no longer need to be supplied a copy of the RepoHook class (incorrect idea about code layout. Review Request #11492.

Diff:

Revision 6 (+1625 -555)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

TheArcticGiraffe
Review request changed

Change Summary:

Minor changes and final tweaks to refactoring to RepoHook class and SCMRepositoryHooks and its subclasses.
Posted this RR two weeks ago before lots of local testing happened, but forgot to publish it.

Commits:

Summary
-
Adding in-progress files.
-
Added new options to repo-hook command based on the functionality in contrib\tools\git-hook-set-submitted and contrib\tools\git-hook-check-approval. Followed same default values as found in these two hook scripts.
-
Fixed a few flake8 failure, and added in standard regex flag from contrib\tools\git-hook-set-submitted\n and contrib\tools\git-hook-check-approval as an option in the repo-hook command
-
Brought functionality from git.py over to the GitRepositoryHooks class. This may change, but this is a starting point
-
Changed the wording and working of a few commands, so that the default is standard and it lexically makes sense for the user to add the option as a way to enable the function (e.g. --require-review-requests changed to dont-require-review-requests, and changed the default from True to False). As well, a few minor tab and line length errors were corrected
-
This commit was an error fixing commit. Fixed some missed commas in the Options section, fixed a mispelling of store_true, fixed an error of using ! instead of not.
-
Added option for specifying the type of repository repository being used (--repo-type).
-
Minor change, adding self variable to a class method inside SECRepositoryHooks class
-
Added the common lines between /contrib/tools/git-hook-set-submitted and /contrib/tools/git-hook-check-approval to rbtools/commands/repo_hook.py in the RepoHook Command subclass as the default behaviour before hook-type specific behaviour is taken
-
Removed unnecessary debug code from RepoHook class and its helper classes, and cleaned up the code a little.
-
Brought logic for the pre-receive and post-receive functionality from /contrib/tools/git-hook-check-approval and /contrib/tools/git-hook-set-submitted into the pre_receive() and post_receive() methods of the RepoHook class.
-
Went through all flake8 errors that occured throughout the first 3 posts to ReviewBoard
-
More flake8 issue fixing.
-
Review Request #11492
-
Altered how repo_hook command accesses SCMRepositoryHooks subclasses. Now, repo_hook will call on the correcponsing SCM client, of which each now has a repository_hooks_class class attribute. The repo_hook command can access the corresponsing SCMRepositoryHooks subclass depending on the --repo-type supplied in the command. Skeleton code for the SVNRepositoryHooks and MercurialRepositoryHooks classes have been created to make sure all functionality is working. Also changed the GitRepositoryHooks class to no longer need to be supplied a copy of the RepoHook class (incorrect idea about code layout. Review Request #11492.
+
Adding in-progress files.
+
Added new options to repo-hook command based on the functionality in contrib\tools\git-hook-set-submitted and contrib\tools\git-hook-check-approval. Followed same default values as found in these two hook scripts.
+
Fixed a few flake8 failure, and added in standard regex flag from contrib\tools\git-hook-set-submitted\n and contrib\tools\git-hook-check-approval as an option in the repo-hook command
+
Brought functionality from git.py over to the GitRepositoryHooks class. This may change, but this is a starting point
+
Changed the wording and working of a few commands, so that the default is standard and it lexically makes sense for the user to add the option as a way to enable the function (e.g. --require-review-requests changed to dont-require-review-requests, and changed the default from True to False). As well, a few minor tab and line length errors were corrected
+
This commit was an error fixing commit. Fixed some missed commas in the Options section, fixed a mispelling of store_true, fixed an error of using ! instead of not.
+
Added option for specifying the type of repository repository being used (--repo-type).
+
Minor change, adding self variable to a class method inside SECRepositoryHooks class
+
Added the common lines between /contrib/tools/git-hook-set-submitted and /contrib/tools/git-hook-check-approval to rbtools/commands/repo_hook.py in the RepoHook Command subclass as the default behaviour before hook-type specific behaviour is taken
+
Removed unnecessary debug code from RepoHook class and its helper classes, and cleaned up the code a little.
+
Brought logic for the pre-receive and post-receive functionality from /contrib/tools/git-hook-check-approval and /contrib/tools/git-hook-set-submitted into the pre_receive() and post_receive() methods of the RepoHook class.
+
Went through all flake8 errors that occured throughout the first 3 posts to ReviewBoard
+
More flake8 issue fixing.
+
Review Request #11492
+
Altered how repo_hook command accesses SCMRepositoryHooks subclasses. Now, repo_hook will call on the correcponsing SCM client, of which each now has a repository_hooks_class class attribute. The repo_hook command can access the corresponsing SCMRepositoryHooks subclass depending on the --repo-type supplied in the command. Skeleton code for the SVNRepositoryHooks and MercurialRepositoryHooks classes have been created to make sure all functionality is working. Also changed the GitRepositoryHooks class to no longer need to be supplied a copy of the RepoHook class (incorrect idea about code layout. Review Request #11492.
+
Fixed all current flake8 errors via local version of flake8
+
Minor changes, added sys.exit(1) for bad result in order for pre-receive hook to know what happened. Fixed some uncaught name spelling errors and other issues. Review Request #11492
+
Reorganized how rbtools/command/repo-hook.py and rbtools/clients/scmrepositoryhooks.py and all it's subclasses functioned. Previously, RepoHook called the functionality it needed from methods in the SCMRepositoryHooks directly. Now, depending on the hook-type passed in (pre-receive, post-receive, etc), RepoHook will call the corresponding method in the SCMRepositoryHooks subclass (e.g. SCMRepositoryHooks.pre_receive()) in order to get the stuff it needs. This is done so that the method calls will be the same, regardless of what SCM the hook is being used for.
+
Minor tweaks to some method calls for the post-receive hook side of repo-hook. Errors found with passing too many arguments or passing arguments the incorrect way.

Diff:

Revision 7 (+1808 -678)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

TheArcticGiraffe
Review request changed

Change Summary:

Added more tests, and have removed all references to pre_commit hook type from all files relating to the RepoHook command class.

Summary:

-[WIP] Implementing a repo-hook command to standardize how hooks for RBTools are used
+Implementing a repo-hook command to standardize how hooks for RBTools are used

Description:

~  

Adding in-progress files.

~   Created repo-hook.py, which implements the most basic of functionality of a command, on which to build.
  ~

Have created all functionality for RepoHook class.

  ~ Have created support class SCMRepositoryHooks and subclasses for Git, SVN, and Mercurial.

-   This command also has had the code from rbtools/hook/common.py inserted in, though not much functionality is implemented.
-   Created scmrepositoryhooks.py as a base class for all the remaining repository classes. Include basic methods which are just passed over for implementation in the subclasses.
-   Created the gitrepositoryhooks.py sub-class, which inherits from scmrepositoryhooks.py. No implementation inside yet.
-   Altered setup.py to include repo-hook as a command to be part of the rbtools commands.

Testing Done:

~  

No testing done, as code is not in a working state as of yet.

  ~

Have done testing with a local Git repository on my machine and pre-receive and post-receive hook scripts to ensure that the code works.

  + Have created a suite of tests to test various options and how they would cause the RepoHook command to react.

Commits:

Summary
-
Adding in-progress files.
-
Added new options to repo-hook command based on the functionality in contrib\tools\git-hook-set-submitted and contrib\tools\git-hook-check-approval. Followed same default values as found in these two hook scripts.
-
Fixed a few flake8 failure, and added in standard regex flag from contrib\tools\git-hook-set-submitted\n and contrib\tools\git-hook-check-approval as an option in the repo-hook command
-
Brought functionality from git.py over to the GitRepositoryHooks class. This may change, but this is a starting point
-
Changed the wording and working of a few commands, so that the default is standard and it lexically makes sense for the user to add the option as a way to enable the function (e.g. --require-review-requests changed to dont-require-review-requests, and changed the default from True to False). As well, a few minor tab and line length errors were corrected
-
This commit was an error fixing commit. Fixed some missed commas in the Options section, fixed a mispelling of store_true, fixed an error of using ! instead of not.
-
Added option for specifying the type of repository repository being used (--repo-type).
-
Minor change, adding self variable to a class method inside SECRepositoryHooks class
-
Added the common lines between /contrib/tools/git-hook-set-submitted and /contrib/tools/git-hook-check-approval to rbtools/commands/repo_hook.py in the RepoHook Command subclass as the default behaviour before hook-type specific behaviour is taken
-
Removed unnecessary debug code from RepoHook class and its helper classes, and cleaned up the code a little.
-
Brought logic for the pre-receive and post-receive functionality from /contrib/tools/git-hook-check-approval and /contrib/tools/git-hook-set-submitted into the pre_receive() and post_receive() methods of the RepoHook class.
-
Went through all flake8 errors that occured throughout the first 3 posts to ReviewBoard
-
More flake8 issue fixing.
-
Review Request #11492
-
Altered how repo_hook command accesses SCMRepositoryHooks subclasses. Now, repo_hook will call on the correcponsing SCM client, of which each now has a repository_hooks_class class attribute. The repo_hook command can access the corresponsing SCMRepositoryHooks subclass depending on the --repo-type supplied in the command. Skeleton code for the SVNRepositoryHooks and MercurialRepositoryHooks classes have been created to make sure all functionality is working. Also changed the GitRepositoryHooks class to no longer need to be supplied a copy of the RepoHook class (incorrect idea about code layout. Review Request #11492.
-
Fixed all current flake8 errors via local version of flake8
-
Minor changes, added sys.exit(1) for bad result in order for pre-receive hook to know what happened. Fixed some uncaught name spelling errors and other issues. Review Request #11492
-
Reorganized how rbtools/command/repo-hook.py and rbtools/clients/scmrepositoryhooks.py and all it's subclasses functioned. Previously, RepoHook called the functionality it needed from methods in the SCMRepositoryHooks directly. Now, depending on the hook-type passed in (pre-receive, post-receive, etc), RepoHook will call the corresponding method in the SCMRepositoryHooks subclass (e.g. SCMRepositoryHooks.pre_receive()) in order to get the stuff it needs. This is done so that the method calls will be the same, regardless of what SCM the hook is being used for.
-
Minor tweaks to some method calls for the post-receive hook side of repo-hook. Errors found with passing too many arguments or passing arguments the incorrect way.
+
Adding in-progress files.
+
Added new options to repo-hook command based on the functionality in contrib\tools\git-hook-set-submitted and contrib\tools\git-hook-check-approval. Followed same default values as found in these two hook scripts.
+
Fixed a few flake8 failure, and added in standard regex flag from contrib\tools\git-hook-set-submitted\n and contrib\tools\git-hook-check-approval as an option in the repo-hook command
+
Brought functionality from git.py over to the GitRepositoryHooks class. This may change, but this is a starting point
+
Changed the wording and working of a few commands, so that the default is standard and it lexically makes sense for the user to add the option as a way to enable the function (e.g. --require-review-requests changed to dont-require-review-requests, and changed the default from True to False). As well, a few minor tab and line length errors were corrected
+
This commit was an error fixing commit. Fixed some missed commas in the Options section, fixed a mispelling of store_true, fixed an error of using ! instead of not.
+
Added option for specifying the type of repository repository being used (--repo-type).
+
Minor change, adding self variable to a class method inside SECRepositoryHooks class
+
Added the common lines between /contrib/tools/git-hook-set-submitted and /contrib/tools/git-hook-check-approval to rbtools/commands/repo_hook.py in the RepoHook Command subclass as the default behaviour before hook-type specific behaviour is taken
+
Removed unnecessary debug code from RepoHook class and its helper classes, and cleaned up the code a little.
+
Brought logic for the pre-receive and post-receive functionality from /contrib/tools/git-hook-check-approval and /contrib/tools/git-hook-set-submitted into the pre_receive() and post_receive() methods of the RepoHook class.
+
Went through all flake8 errors that occured throughout the first 3 posts to ReviewBoard
+
More flake8 issue fixing.
+
Review Request #11492
+
Altered how repo_hook command accesses SCMRepositoryHooks subclasses. Now, repo_hook will call on the correcponsing SCM client, of which each now has a repository_hooks_class class attribute. The repo_hook command can access the corresponsing SCMRepositoryHooks subclass depending on the --repo-type supplied in the command. Skeleton code for the SVNRepositoryHooks and MercurialRepositoryHooks classes have been created to make sure all functionality is working. Also changed the GitRepositoryHooks class to no longer need to be supplied a copy of the RepoHook class (incorrect idea about code layout. Review Request #11492.
+
Fixed all current flake8 errors via local version of flake8
+
Minor changes, added sys.exit(1) for bad result in order for pre-receive hook to know what happened. Fixed some uncaught name spelling errors and other issues. Review Request #11492
+
Reorganized how rbtools/command/repo-hook.py and rbtools/clients/scmrepositoryhooks.py and all it's subclasses functioned. Previously, RepoHook called the functionality it needed from methods in the SCMRepositoryHooks directly. Now, depending on the hook-type passed in (pre-receive, post-receive, etc), RepoHook will call the corresponding method in the SCMRepositoryHooks subclass (e.g. SCMRepositoryHooks.pre_receive()) in order to get the stuff it needs. This is done so that the method calls will be the same, regardless of what SCM the hook is being used for.
+
Minor tweaks to some method calls for the post-receive hook side of repo-hook. Errors found with passing too many arguments or passing arguments the incorrect way.
+
Added tests for RepoHook command, including checking proper fetching of GitRepositoryHooks class, exit from system in case of calling 'svn', 'mercurial' or an invalid repo type for repo-type, saving of server options, properly setting regex flags, and testing for exiting when given invalid hook-type.
+
Added tests for valid --hook-types, the default hook_type, default repo_type, the default values for server options, and the default and activated states of calling --require-approval, --dont-require-review-requests, and --allow-unapproved-push.

Diff:

Revision 8 (+2397 -753)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

TheArcticGiraffe
Review request changed

Summary:

-Implementing a repo-hook command to standardize how hooks for RBTools are used
+Implementing a repo-hook command to provide standardized repo hook script functionality for RBTools

Description:

~  

Have created all functionality for RepoHook class.

~   Have created support class SCMRepositoryHooks and subclasses for Git, SVN, and Mercurial.

  ~

High-Level Description

  ~
  +

This feature is meant to give some hook script functionality for RBTools through a new command, repo-hook. Specifically, the repo-hook command allows users to call RBTools based pre-receive and post-receive hook script functionality from their own hook scripts.

  +
  +

The pre-receive functionality is focused on checking commits in the incoming push for review request IDs, and possibly cancelling the push if criteria are not met. This criteria depends on whether certain options are activated or left default (--dont-require-review-requests and --allow-unapproved-push). By default, the push will be cancelled if there are any commits without review requests, or if any review requests are not approved.

  +
  +

The post-receive functionality is based on closing any review requests referenced in commit messages in the current push. In this instance, a push cannot be cancelled, and warnings will be raised if there are commits with no review requests.

  +
  +

Initial Plans

  +
  +

Initial plans for this command were to have hook script functionality for multiple SCM systems, specifically starting with Git, Mercurial, and Subversion. At this point, only functionality for Git has been implemented, with skeleton code and empty classes being implemented for SVN and Mercurial.

  +
  +

How the Code Works Together

  +
  +

This functionality is performed by a RepoHook Command class. This class will perform all the SCM agnostic logic of the hook scripts. From this class, depending on the --repo-type option specified (again, currently only Git is an option), a SCMRepositoryHooks subclass representing the repository in --repo-type will be called to provide RepoHook with the information it needs in order to work, while performing all SCM specific code within it's own class.

  +
  +

Next Steps

  +
  +

Next steps would involve getting code reviews to confirm that the Git and RepoHook logic are bug-free, as well as implementing the SVN and Mercurial logic in their corresponding classes to allow more variety of SCMs.

  +
  +

Additionally, outside of initial scope, other hook types could be implemented. One that would prove useful is pre-commit functionality to ensure that a review request ID is included in the commit message. This would help avoid issues with using the pre-receive functionality, as the only issue that could arise would be that a review request is not approved.

Testing Done:

~  

Have done testing with a local Git repository on my machine and pre-receive and post-receive hook scripts to ensure that the code works.

~   Have created a suite of tests to test various options and how they would cause the RepoHook command to react.

  ~

Have done local testing with a local Git repository on my machine containing pre-receive and post-receive hook scripts that call the rbt repo-hook command to ensure that the code works.

  ~
  +

Have created a suite of tests to test various options and how they would cause the RepoHook command to react. This includes testing all variations of --repo-type and --hook-type (allowed, un-implemented, no variant selected, and default value), default and specified server options, regex flag options, and both variations of all other toggle-able options.

Commits:

Summary
-
Adding in-progress files.
-
Added new options to repo-hook command based on the functionality in contrib\tools\git-hook-set-submitted and contrib\tools\git-hook-check-approval. Followed same default values as found in these two hook scripts.
-
Fixed a few flake8 failure, and added in standard regex flag from contrib\tools\git-hook-set-submitted\n and contrib\tools\git-hook-check-approval as an option in the repo-hook command
-
Brought functionality from git.py over to the GitRepositoryHooks class. This may change, but this is a starting point
-
Changed the wording and working of a few commands, so that the default is standard and it lexically makes sense for the user to add the option as a way to enable the function (e.g. --require-review-requests changed to dont-require-review-requests, and changed the default from True to False). As well, a few minor tab and line length errors were corrected
-
This commit was an error fixing commit. Fixed some missed commas in the Options section, fixed a mispelling of store_true, fixed an error of using ! instead of not.
-
Added option for specifying the type of repository repository being used (--repo-type).
-
Minor change, adding self variable to a class method inside SECRepositoryHooks class
-
Added the common lines between /contrib/tools/git-hook-set-submitted and /contrib/tools/git-hook-check-approval to rbtools/commands/repo_hook.py in the RepoHook Command subclass as the default behaviour before hook-type specific behaviour is taken
-
Removed unnecessary debug code from RepoHook class and its helper classes, and cleaned up the code a little.
-
Brought logic for the pre-receive and post-receive functionality from /contrib/tools/git-hook-check-approval and /contrib/tools/git-hook-set-submitted into the pre_receive() and post_receive() methods of the RepoHook class.
-
Went through all flake8 errors that occured throughout the first 3 posts to ReviewBoard
-
More flake8 issue fixing.
-
Review Request #11492
-
Altered how repo_hook command accesses SCMRepositoryHooks subclasses. Now, repo_hook will call on the correcponsing SCM client, of which each now has a repository_hooks_class class attribute. The repo_hook command can access the corresponsing SCMRepositoryHooks subclass depending on the --repo-type supplied in the command. Skeleton code for the SVNRepositoryHooks and MercurialRepositoryHooks classes have been created to make sure all functionality is working. Also changed the GitRepositoryHooks class to no longer need to be supplied a copy of the RepoHook class (incorrect idea about code layout. Review Request #11492.
-
Fixed all current flake8 errors via local version of flake8
-
Minor changes, added sys.exit(1) for bad result in order for pre-receive hook to know what happened. Fixed some uncaught name spelling errors and other issues. Review Request #11492
-
Reorganized how rbtools/command/repo-hook.py and rbtools/clients/scmrepositoryhooks.py and all it's subclasses functioned. Previously, RepoHook called the functionality it needed from methods in the SCMRepositoryHooks directly. Now, depending on the hook-type passed in (pre-receive, post-receive, etc), RepoHook will call the corresponding method in the SCMRepositoryHooks subclass (e.g. SCMRepositoryHooks.pre_receive()) in order to get the stuff it needs. This is done so that the method calls will be the same, regardless of what SCM the hook is being used for.
-
Minor tweaks to some method calls for the post-receive hook side of repo-hook. Errors found with passing too many arguments or passing arguments the incorrect way.
-
Added tests for RepoHook command, including checking proper fetching of GitRepositoryHooks class, exit from system in case of calling 'svn', 'mercurial' or an invalid repo type for repo-type, saving of server options, properly setting regex flags, and testing for exiting when given invalid hook-type.
-
Added tests for valid --hook-types, the default hook_type, default repo_type, the default values for server options, and the default and activated states of calling --require-approval, --dont-require-review-requests, and --allow-unapproved-push.
+
Adding in-progress files.
+
Added new options to repo-hook command based on the functionality in contrib\tools\git-hook-set-submitted and contrib\tools\git-hook-check-approval. Followed same default values as found in these two hook scripts.
+
Fixed a few flake8 failure, and added in standard regex flag from contrib\tools\git-hook-set-submitted\n and contrib\tools\git-hook-check-approval as an option in the repo-hook command
+
Brought functionality from git.py over to the GitRepositoryHooks class. This may change, but this is a starting point
+
Changed the wording and working of a few commands, so that the default is standard and it lexically makes sense for the user to add the option as a way to enable the function (e.g. --require-review-requests changed to dont-require-review-requests, and changed the default from True to False). As well, a few minor tab and line length errors were corrected
+
This commit was an error fixing commit. Fixed some missed commas in the Options section, fixed a mispelling of store_true, fixed an error of using ! instead of not.
+
Added option for specifying the type of repository repository being used (--repo-type).
+
Minor change, adding self variable to a class method inside SECRepositoryHooks class
+
Added the common lines between /contrib/tools/git-hook-set-submitted and /contrib/tools/git-hook-check-approval to rbtools/commands/repo_hook.py in the RepoHook Command subclass as the default behaviour before hook-type specific behaviour is taken
+
Removed unnecessary debug code from RepoHook class and its helper classes, and cleaned up the code a little.
+
Brought logic for the pre-receive and post-receive functionality from /contrib/tools/git-hook-check-approval and /contrib/tools/git-hook-set-submitted into the pre_receive() and post_receive() methods of the RepoHook class.
+
Went through all flake8 errors that occured throughout the first 3 posts to ReviewBoard
+
More flake8 issue fixing.
+
Review Request #11492
+
Altered how repo_hook command accesses SCMRepositoryHooks subclasses. Now, repo_hook will call on the correcponsing SCM client, of which each now has a repository_hooks_class class attribute. The repo_hook command can access the corresponsing SCMRepositoryHooks subclass depending on the --repo-type supplied in the command. Skeleton code for the SVNRepositoryHooks and MercurialRepositoryHooks classes have been created to make sure all functionality is working. Also changed the GitRepositoryHooks class to no longer need to be supplied a copy of the RepoHook class (incorrect idea about code layout. Review Request #11492.
+
Fixed all current flake8 errors via local version of flake8
+
Minor changes, added sys.exit(1) for bad result in order for pre-receive hook to know what happened. Fixed some uncaught name spelling errors and other issues. Review Request #11492
+
Reorganized how rbtools/command/repo-hook.py and rbtools/clients/scmrepositoryhooks.py and all it's subclasses functioned. Previously, RepoHook called the functionality it needed from methods in the SCMRepositoryHooks directly. Now, depending on the hook-type passed in (pre-receive, post-receive, etc), RepoHook will call the corresponding method in the SCMRepositoryHooks subclass (e.g. SCMRepositoryHooks.pre_receive()) in order to get the stuff it needs. This is done so that the method calls will be the same, regardless of what SCM the hook is being used for.
+
Minor tweaks to some method calls for the post-receive hook side of repo-hook. Errors found with passing too many arguments or passing arguments the incorrect way.
+
Added tests for RepoHook command, including checking proper fetching of GitRepositoryHooks class, exit from system in case of calling 'svn', 'mercurial' or an invalid repo type for repo-type, saving of server options, properly setting regex flags, and testing for exiting when given invalid hook-type.
+
Added tests for valid --hook-types, the default hook_type, default repo_type, the default values for server options, and the default and activated states of calling --require-approval, --dont-require-review-requests, and --allow-unapproved-push.
+
Added documentation where needed, and fixed bad/non-compliant documentation
+
Fixed a minor flake8 error in rbtools/clients/scmrepositoryhooks.py. Review request #11492

Diff:

Revision 9 (+2660 -866)

Show changes

Checks run (1 failed, 1 succeeded)

flake8 failed.
JSHint passed.

flake8

Loading...