-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from sclorg/split_to_two_commands
Split auto-merge to two commands
- Loading branch information
Showing
12 changed files
with
534 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
# MIT License | ||
# | ||
# Copyright (c) 2018-2019 Red Hat, Inc. | ||
|
||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
import logging | ||
import sys | ||
|
||
from pathlib import Path | ||
from typing import Dict | ||
|
||
from auto_merger.pr_checker import PRStatusChecker | ||
from auto_merger.merger import AutoMerger | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
def pr_checker(print_results, github_labels, blocking_labels, approvals, send_email) -> int: | ||
""" | ||
Checks NVR from brew build against pulp | ||
""" | ||
pr_status_checker = PRStatusChecker(github_labels, blocking_labels, approvals) | ||
ret_value = pr_status_checker.check_all_containers() | ||
if ret_value != 0: | ||
return ret_value | ||
if print_results: | ||
pr_status_checker.print_blocked_pull_request() | ||
pr_status_checker.print_approval_pull_request() | ||
if not pr_status_checker.send_results(send_email): | ||
return 1 | ||
return ret_value | ||
|
||
|
||
def merger(print_results, merger_labels, approvals, pr_lifetime, send_email) -> int: | ||
auto_merger = AutoMerger(merger_labels, approvals, pr_lifetime) | ||
ret_value = auto_merger.check_all_containers() | ||
if ret_value != 0: | ||
return ret_value | ||
if print_results: | ||
auto_merger.print_pull_request_to_merge() | ||
if not auto_merger.send_results(send_email): | ||
return 1 | ||
return ret_value |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# MIT License | ||
# | ||
# Copyright (c) 2018-2019 Red Hat, Inc. | ||
|
||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
|
||
import logging | ||
import click | ||
import sys | ||
|
||
from auto_merger.config import pass_global_config | ||
from auto_merger import api | ||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@click.command("merger") | ||
@click.option("--print-results", is_flag=True, help="Prints readable summary") | ||
@click.option("--merger-labels", required=True, multiple=True, | ||
help="Specify Git Hub labels to meet criteria") | ||
@click.option("--send-email", multiple=True, help="Specify email addresses to which the mail will be sent.") | ||
@click.option("--approvals", | ||
default=2, type=int, | ||
help="Specify number of approvals to automatically merge PR. Default 2") | ||
@click.option("--pr-lifetime", default=1, type=int, help="Specify a smallest time for which PR should opened") | ||
@pass_global_config | ||
def merger(ctx, print_results, merger_labels, approvals, pr_lifetime, send_email): | ||
logger.debug(ctx.debug) | ||
ret_value = api.merger(print_results, merger_labels, approvals, pr_lifetime, send_email) | ||
sys.exit(ret_value) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# MIT License | ||
# | ||
# Copyright (c) 2018-2019 Red Hat, Inc. | ||
|
||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
|
||
import logging | ||
import click | ||
import sys | ||
|
||
from auto_merger.config import pass_global_config | ||
from auto_merger import api | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
|
||
@click.command("pr-checker") | ||
@click.option("--print-results", is_flag=True, help="Prints readable summary") | ||
@click.option("--github-labels", required=True, multiple=True, | ||
help="Specify Git Hub labels to meet criteria") | ||
@click.option("--blocking-labels", multiple=True, | ||
help="Specify Git Hub labels that blocks PR to merge") | ||
@click.option("--send-email", multiple=True, help="Specify email addresses to which the mail will be sent.") | ||
@click.option("--approvals", | ||
default=2, type=int, | ||
help="Specify number of approvals to automatically merge PR. Default 2") | ||
@pass_global_config | ||
def pr_checker(ctx, print_results, github_labels, blocking_labels, approvals, send_email): | ||
logger.debug(ctx.debug) | ||
ret_value = api.pr_checker(print_results, github_labels, blocking_labels, approvals, send_email) | ||
sys.exit(ret_value) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# MIT License | ||
# | ||
# Copyright (c) 2018-2019 Red Hat, Inc. | ||
|
||
# Permission is hereby granted, free of charge, to any person obtaining a copy | ||
# of this software and associated documentation files (the "Software"), to deal | ||
# in the Software without restriction, including without limitation the rights | ||
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
# copies of the Software, and to permit persons to whom the Software is | ||
# furnished to do so, subject to the following conditions: | ||
# | ||
# The above copyright notice and this permission notice shall be included in all | ||
# copies or substantial portions of the Software. | ||
# | ||
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
# SOFTWARE. | ||
|
||
|
||
import click | ||
|
||
|
||
class GlobalConfig(object): | ||
def __init__(self, debug: bool = False): | ||
self.debug = debug | ||
|
||
|
||
pass_global_config = click.make_pass_decorator(GlobalConfig) |
Oops, something went wrong.