deepbrook / gerrit-hooks Goto Github PK
View Code? Open in Web Editor NEWCLI ArgumentParsers for Gerrit Hooks
License: MIT License
CLI ArgumentParsers for Gerrit Hooks
License: MIT License
The current implementation of the hashtag-created hook would only allow one of each:
--removed
--added
--hashtag
Support for multiple of these needs to be implemented, since bulk-changes to hashtags are currently not supported due to this limitation.
document uses gerrit_hooks.add_custom_approval_rating
when it should be gerrit_hooks.add_custom_approval_category
https://github.com/nlsdfnbch/gerrit-hooks/blob/master/gerrit_hooks/containers.py#L20
https://github.com/nlsdfnbch/gerrit-hooks/blob/master/gerrit_hooks/containers.py#L181
This comes from the official documentation:
https://gerrit.googlesource.com/plugins/hooks/+/refs/heads/master/src/main/resources/Documentation/hooks.md#hashtags_changed
This may not be a bug in the library, but it may be possible to set nargs="+"
and then have some logic to do a ' '.join(gerrit_args.author)
(and so on for similar fields)
So far I have had to do a workaround after parsing (using sys.argv) for the following fields:
--uploader
--change-owner
--author
Another similar issue occurs when Gerrit passes --topic
without any argument, and the parser expects one to be there. (i.e. some of the configurations could be tweaked for certain options)
Maybe instead of _generate_parser()
there could be an extra step before that like _generate_options()
so that the options could be modified before the call to _generate_parser()
Currently, the developers have to define the type of hook they're writing, by passing a str to the build_parser_for()
function (or using the HookType container class to do so).
Since the hook names are identical to the file names in the common case, add an auto-detection mechanism, to automatically select the appropriate parser to build.
It could then look like this:
import gerrit_hooks
options = gerrit_hooks.parse_options()
Where parse_options()
would throw an error if we can't make anything of the current file-type.
Traceback (most recent call last):
File "...", line ..., in <module>
gerrit_parser = gerrit_hooks.build_parser_for(args.gerrit_event)
File "/usr/local/lib/python3.5/dist-packages/gerrit_hooks/hook.py", line 37, in build_parser_for
cli_flags = HookFlagDefinitions()[hook_type]
File "/usr/local/lib/python3.5/dist-packages/gerrit_hooks/containers.py", line 172, in __getitem__
flag_string = self.__mapping__[item]
KeyError: 'change-deleted'
These are currently not supported by the parser we build.
Implement them.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.