#108 Allow certain configured groups to by-pass the PR-only setting
Merged by pingou. Opened by pingou.
by_pass_pr_only  into  master

Download 108.patch

Pagure has a setting that can be set for each project to disallow
direct commit and instead have all contribution be made via
pull-requests.
On dist-git (src.fp.o), if enabled, this feature has the unforseen
consequences of blocking provenpackager or releng from fixing
packages directly and forcing them into this PR-only model.
This is not ideal as we want provenpackager or releng to be able to
fix quickly packages that need to be.

This issue was raised in https://pagure.io/fedora-infrastructure/issue/8895

Fixes https://pagure.io/fedora-infrastructure/issue/8895

Signed-off-by: Pierre-Yves Chibon pingou@pingoured.fr

It's obvious what you do here (and the code likely works), but the "by_pass_pr_only = ..." construct is still somewhat hard to read.

How about making self.bypass_pr_only_groups a set right away and using the intersection operator (the last one is syntactical sugar, feel free to ignore)? Also, consistently use bypass without underscore and just utilize that lists/tuple/sets/string are understood as False(-ish) if empty and True(-ish) if not. E.g.:

    self.bypass_pr_only_groups = set(pagure_config.get("BYPASS_PR_ONLY_GROUPS", []))
    ...
    # Determine if the user is part of a group which allows them to by-pass the PR-only setting
    bypass_pr_only = self.bypass_pr_only_groups & usergroups
    ...
    self.debug("Bypass PR-only: %s" % bool(bypass_pr_only))
    ...
    if repotype == "main" and not is_rcm and not bypass_pr_only:

I've had to tweak:

    self.bypass_pr_only_groups = set(pagure_config.get("BYPASS_PR_ONLY_GROUPS", []))

to

    self.bypass_pr_only_groups = set(pagure_config.get("BYPASS_PR_ONLY_GROUPS") or [])

as if the configuration file has: BYPASS_PR_ONLY_GROUPS = None the .get() will give you what is in the config, ie: None and poof :)

I did keep the .intersection() which I find clearer (though longer) in what it does.

The rest is adjusted, thanks for the advices!

rebased onto 8a5941f485eb849fc85b8a6e09c948f689e990c7

This needs to be bypass_pr_only (without underscore) and should be wrapped in bool(bypass_pr_only) so that the debug output contains a simple True or False rather than the intersection of the group sets.

This also has to be bypass_pr_only.

rebased onto 1117155ef352693dc744b6a14578b961ce291aff

Looks good to me!

Thanks! :)

Pull-Request has been merged by pingou

Metadata