From e28b1bfe3460508d2b41a4b39eedf7f374eb122d Mon Sep 17 00:00:00 2001 From: socar-humphrey Date: Tue, 29 Jun 2021 18:06:35 +0900 Subject: [PATCH 1/6] feat(gitopscli/*): add merge method parameter to deploy command --- gitopscli/cliparser.py | 2 ++ gitopscli/commands/deploy.py | 5 +++-- gitopscli/git_api/git_repo_api.py | 4 ++-- gitopscli/git_api/git_repo_api_logging_proxy.py | 6 +++--- gitopscli/git_api/github_git_repo_api_adapter.py | 9 +++++---- 5 files changed, 15 insertions(+), 11 deletions(-) diff --git a/gitopscli/cliparser.py b/gitopscli/cliparser.py index 5907ad9b..5fcb446a 100644 --- a/gitopscli/cliparser.py +++ b/gitopscli/cliparser.py @@ -99,6 +99,8 @@ def __create_deploy_parser() -> ArgumentParser: const=True, default=False, ) + parser.add_argument("--merge-method", help="Merge Method (squash, rebase, merge commit if None)", type=str, + default=None) __add_verbose_arg(parser) return parser diff --git a/gitopscli/commands/deploy.py b/gitopscli/commands/deploy.py index f14116da..f71cbda5 100644 --- a/gitopscli/commands/deploy.py +++ b/gitopscli/commands/deploy.py @@ -1,7 +1,7 @@ import logging import uuid from dataclasses import dataclass -from typing import Any, Dict, Optional, Tuple +from typing import Any, Dict, Optional, Tuple, Literal from gitopscli.git_api import GitApiConfig, GitRepo, GitRepoApi, GitRepoApiFactory from gitopscli.io_api.yaml_util import update_yaml_file, yaml_dump, YAMLException from gitopscli.gitops_exception import GitOpsException @@ -25,6 +25,7 @@ class Args(GitApiConfig): create_pr: bool auto_merge: bool + merge_method: Optional[Literal["squash", "rebase"]] = None def __init__(self, args: Args) -> None: self.__args = args @@ -50,7 +51,7 @@ def execute(self) -> None: pr_id = git_repo_api.create_pull_request_to_default_branch(pr_branch, title, description).pr_id if self.__args.auto_merge: - git_repo_api.merge_pull_request(pr_id) + git_repo_api.merge_pull_request(pr_id, self.__args.merge_method) git_repo_api.delete_branch(pr_branch) def __create_git_repo_api(self) -> GitRepoApi: diff --git a/gitopscli/git_api/git_repo_api.py b/gitopscli/git_api/git_repo_api.py index 87104aa1..0b286c69 100644 --- a/gitopscli/git_api/git_repo_api.py +++ b/gitopscli/git_api/git_repo_api.py @@ -1,5 +1,5 @@ from abc import ABCMeta, abstractmethod -from typing import NamedTuple, Optional +from typing import NamedTuple, Optional, Literal class GitRepoApi(metaclass=ABCMeta): @@ -32,7 +32,7 @@ def create_pull_request( ... @abstractmethod - def merge_pull_request(self, pr_id: int) -> None: + def merge_pull_request(self, pr_id: int, merge_method: Optional[Literal["squash", "rebase"]] = None) -> None: ... @abstractmethod diff --git a/gitopscli/git_api/git_repo_api_logging_proxy.py b/gitopscli/git_api/git_repo_api_logging_proxy.py index b9086f0f..1f544b54 100644 --- a/gitopscli/git_api/git_repo_api_logging_proxy.py +++ b/gitopscli/git_api/git_repo_api_logging_proxy.py @@ -1,5 +1,5 @@ import logging -from typing import Optional +from typing import Optional, Literal from .git_repo_api import GitRepoApi @@ -28,9 +28,9 @@ def create_pull_request( logging.info("Creating pull request from '%s' to '%s' with title: %s", from_branch, to_branch, title) return self.__api.create_pull_request(from_branch, to_branch, title, description) - def merge_pull_request(self, pr_id: int) -> None: + def merge_pull_request(self, pr_id: int, merge_method: Optional[Literal["squash", "rebase"]] = None) -> None: logging.info("Merging pull request %s", pr_id) - self.__api.merge_pull_request(pr_id) + self.__api.merge_pull_request(pr_id, merge_method=merge_method) def add_pull_request_comment(self, pr_id: int, text: str, parent_id: Optional[int] = None) -> None: if parent_id: diff --git a/gitopscli/git_api/github_git_repo_api_adapter.py b/gitopscli/git_api/github_git_repo_api_adapter.py index e3ad9cda..75752b6f 100644 --- a/gitopscli/git_api/github_git_repo_api_adapter.py +++ b/gitopscli/git_api/github_git_repo_api_adapter.py @@ -1,5 +1,6 @@ -from typing import Optional -from github import Github, UnknownObjectException, BadCredentialsException, GitRef, PullRequest, Repository +from typing import Optional, Literal +from github import Github, UnknownObjectException, BadCredentialsException, GitRef, PullRequest, Repository, \ + GithubException from gitopscli.gitops_exception import GitOpsException from .git_repo_api import GitRepoApi @@ -36,9 +37,9 @@ def create_pull_request( pull_request = repo.create_pull(title=title, body=description, head=from_branch, base=to_branch) return GitRepoApi.PullRequestIdAndUrl(pr_id=pull_request.number, url=pull_request.html_url) - def merge_pull_request(self, pr_id: int) -> None: + def merge_pull_request(self, pr_id: int, merge_method: Optional[Literal["squash", "rebase"]] = None) -> None: pull_request = self.__get_pull_request(pr_id) - pull_request.merge() + pull_request.merge(merge_method=merge_method) def add_pull_request_comment(self, pr_id: int, text: str, parent_id: Optional[int] = None) -> None: pull_request = self.__get_pull_request(pr_id) From a06cb431e33323964170f80e86b81144e674c125 Mon Sep 17 00:00:00 2001 From: socar-humphrey Date: Wed, 30 Jun 2021 17:12:29 +0900 Subject: [PATCH 2/6] refactor(gitopscli/*): set merge as default to merge method --- gitopscli/cliparser.py | 4 ++-- gitopscli/commands/deploy.py | 2 +- gitopscli/git_api/git_repo_api.py | 2 +- gitopscli/git_api/git_repo_api_logging_proxy.py | 2 +- gitopscli/git_api/github_git_repo_api_adapter.py | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gitopscli/cliparser.py b/gitopscli/cliparser.py index 5fcb446a..5e1be1ca 100644 --- a/gitopscli/cliparser.py +++ b/gitopscli/cliparser.py @@ -99,8 +99,8 @@ def __create_deploy_parser() -> ArgumentParser: const=True, default=False, ) - parser.add_argument("--merge-method", help="Merge Method (squash, rebase, merge commit if None)", type=str, - default=None) + parser.add_argument("--merge-method", help="Merge Method (e.g., 'squash', 'rebase', 'merge')", type=str, + default="merge") __add_verbose_arg(parser) return parser diff --git a/gitopscli/commands/deploy.py b/gitopscli/commands/deploy.py index f71cbda5..b69dd6c0 100644 --- a/gitopscli/commands/deploy.py +++ b/gitopscli/commands/deploy.py @@ -25,7 +25,7 @@ class Args(GitApiConfig): create_pr: bool auto_merge: bool - merge_method: Optional[Literal["squash", "rebase"]] = None + merge_method: Optional[Literal["squash", "rebase", "merge"]] = "merge" def __init__(self, args: Args) -> None: self.__args = args diff --git a/gitopscli/git_api/git_repo_api.py b/gitopscli/git_api/git_repo_api.py index 0b286c69..8abd4138 100644 --- a/gitopscli/git_api/git_repo_api.py +++ b/gitopscli/git_api/git_repo_api.py @@ -32,7 +32,7 @@ def create_pull_request( ... @abstractmethod - def merge_pull_request(self, pr_id: int, merge_method: Optional[Literal["squash", "rebase"]] = None) -> None: + def merge_pull_request(self, pr_id: int, merge_method: Optional[Literal["squash", "rebase", "merge"]] = "merge") -> None: ... @abstractmethod diff --git a/gitopscli/git_api/git_repo_api_logging_proxy.py b/gitopscli/git_api/git_repo_api_logging_proxy.py index 1f544b54..f23403a6 100644 --- a/gitopscli/git_api/git_repo_api_logging_proxy.py +++ b/gitopscli/git_api/git_repo_api_logging_proxy.py @@ -28,7 +28,7 @@ def create_pull_request( logging.info("Creating pull request from '%s' to '%s' with title: %s", from_branch, to_branch, title) return self.__api.create_pull_request(from_branch, to_branch, title, description) - def merge_pull_request(self, pr_id: int, merge_method: Optional[Literal["squash", "rebase"]] = None) -> None: + def merge_pull_request(self, pr_id: int, merge_method: Optional[Literal["squash", "rebase", "merge"]] = "merge") -> None: logging.info("Merging pull request %s", pr_id) self.__api.merge_pull_request(pr_id, merge_method=merge_method) diff --git a/gitopscli/git_api/github_git_repo_api_adapter.py b/gitopscli/git_api/github_git_repo_api_adapter.py index 75752b6f..145abe2b 100644 --- a/gitopscli/git_api/github_git_repo_api_adapter.py +++ b/gitopscli/git_api/github_git_repo_api_adapter.py @@ -37,7 +37,7 @@ def create_pull_request( pull_request = repo.create_pull(title=title, body=description, head=from_branch, base=to_branch) return GitRepoApi.PullRequestIdAndUrl(pr_id=pull_request.number, url=pull_request.html_url) - def merge_pull_request(self, pr_id: int, merge_method: Optional[Literal["squash", "rebase"]] = None) -> None: + def merge_pull_request(self, pr_id: int, merge_method: Optional[Literal["squash", "rebase", "merge"]] = "merge") -> None: pull_request = self.__get_pull_request(pr_id) pull_request.merge(merge_method=merge_method) From 3b72abc4ed71b947c8b32b64cb732015176d35d4 Mon Sep 17 00:00:00 2001 From: socar-humphrey Date: Wed, 30 Jun 2021 17:16:16 +0900 Subject: [PATCH 3/6] docs(gitopscli/*): add argument description and update deploy command docs --- docs/commands/deploy.md | 31 ++++++++++++------------------- gitopscli/cliparser.py | 2 +- 2 files changed, 13 insertions(+), 20 deletions(-) diff --git a/docs/commands/deploy.md b/docs/commands/deploy.md index 5242bda0..cf3b64c4 100644 --- a/docs/commands/deploy.md +++ b/docs/commands/deploy.md @@ -119,27 +119,20 @@ gitopscli deploy \ ## Usage ``` -usage: gitopscli deploy [-h] --file FILE --values VALUES - [--single-commit [SINGLE_COMMIT]] --username USERNAME - --password PASSWORD [--git-user GIT_USER] - [--git-email GIT_EMAIL] --organisation ORGANISATION - --repository-name REPOSITORY_NAME - [--git-provider GIT_PROVIDER] - [--git-provider-url GIT_PROVIDER_URL] - [--create-pr [CREATE_PR]] [--auto-merge [AUTO_MERGE]] - [-v [VERBOSE]] +usage: gitopscli deploy [-h] --file FILE --values VALUES [--single-commit [SINGLE_COMMIT]] [--commit-message COMMIT_MESSAGE] --username USERNAME --password PASSWORD [--git-user GIT_USER] + [--git-email GIT_EMAIL] --organisation ORGANISATION --repository-name REPOSITORY_NAME [--git-provider GIT_PROVIDER] [--git-provider-url GIT_PROVIDER_URL] [--create-pr [CREATE_PR]] + [--auto-merge [AUTO_MERGE]] [--merge-method MERGE_METHOD] [-v [VERBOSE]] optional arguments: -h, --help show this help message and exit --file FILE YAML file path - --values VALUES YAML/JSON object with the YAML path as key and the - desired value as value + --values VALUES YAML/JSON object with the YAML path as key and the desired value as value --single-commit [SINGLE_COMMIT] Create only single commit for all updates - --username USERNAME Git username (alternative: GITOPSCLI_USERNAME env - variable) - --password PASSWORD Git password or token (alternative: GITOPSCLI_PASSWORD - env variable) + --commit-message COMMIT_MESSAGE + Specify exact commit message of deployment commit + --username USERNAME Git username (alternative: GITOPSCLI_USERNAME env variable) + --password PASSWORD Git password or token (alternative: GITOPSCLI_PASSWORD env variable) --git-user GIT_USER Git Username --git-email GIT_EMAIL Git User Email @@ -150,13 +143,13 @@ optional arguments: --git-provider GIT_PROVIDER Git server provider --git-provider-url GIT_PROVIDER_URL - Git provider base API URL (e.g. - https://bitbucket.example.tld) + Git provider base API URL (e.g. https://bitbucket.example.tld) --create-pr [CREATE_PR] Creates a Pull Request --auto-merge [AUTO_MERGE] - Automatically merge the created PR (only valid with - --create-pr) + Automatically merge the created PR (only valid with --create-pr) + --merge-method MERGE_METHOD + Merge Method (e.g., 'squash', 'rebase', 'merge') (default: merge) -v [VERBOSE], --verbose [VERBOSE] Verbose exception logging ``` diff --git a/gitopscli/cliparser.py b/gitopscli/cliparser.py index 5e1be1ca..b6fa8b7b 100644 --- a/gitopscli/cliparser.py +++ b/gitopscli/cliparser.py @@ -99,7 +99,7 @@ def __create_deploy_parser() -> ArgumentParser: const=True, default=False, ) - parser.add_argument("--merge-method", help="Merge Method (e.g., 'squash', 'rebase', 'merge')", type=str, + parser.add_argument("--merge-method", help="Merge Method (e.g., 'squash', 'rebase', 'merge') (default: merge)", type=str, default="merge") __add_verbose_arg(parser) return parser From f8d56408d21c3ef6b582b047e12b8d138cc1874d Mon Sep 17 00:00:00 2001 From: socar-humphrey Date: Thu, 1 Jul 2021 09:48:18 +0900 Subject: [PATCH 4/6] refactor(gitopscli/*): remove optional typing and make tests pass apply review from https://github.com/baloise/gitopscli/pull/155#pullrequestreview-695990024 --- docs/commands/deploy.md | 31 +++++++++++----- gitopscli/cliparser.py | 36 +++++++++++++++---- gitopscli/commands/deploy.py | 2 +- .../git_api/bitbucket_git_repo_api_adapter.py | 6 ++-- gitopscli/git_api/git_repo_api.py | 4 ++- .../git_api/git_repo_api_logging_proxy.py | 13 +++++-- .../git_api/github_git_repo_api_adapter.py | 15 ++++++-- .../git_api/gitlab_git_repo_api_adapter.py | 9 +++-- .../common/test_gitops_config_loader.py | 5 ++- tests/commands/test_deploy.py | 2 +- .../test_git_repo_api_logging_proxy.py | 26 ++++++++++---- tests/git_api/test_repo_api_factory.py | 20 ++++++++--- tests/test_cliparser.py | 10 ++++-- 13 files changed, 135 insertions(+), 44 deletions(-) diff --git a/docs/commands/deploy.md b/docs/commands/deploy.md index cf3b64c4..0421440d 100644 --- a/docs/commands/deploy.md +++ b/docs/commands/deploy.md @@ -119,20 +119,30 @@ gitopscli deploy \ ## Usage ``` -usage: gitopscli deploy [-h] --file FILE --values VALUES [--single-commit [SINGLE_COMMIT]] [--commit-message COMMIT_MESSAGE] --username USERNAME --password PASSWORD [--git-user GIT_USER] - [--git-email GIT_EMAIL] --organisation ORGANISATION --repository-name REPOSITORY_NAME [--git-provider GIT_PROVIDER] [--git-provider-url GIT_PROVIDER_URL] [--create-pr [CREATE_PR]] - [--auto-merge [AUTO_MERGE]] [--merge-method MERGE_METHOD] [-v [VERBOSE]] +usage: gitopscli deploy [-h] --file FILE --values VALUES + [--single-commit [SINGLE_COMMIT]] + [--commit-message COMMIT_MESSAGE] --username USERNAME + --password PASSWORD [--git-user GIT_USER] + [--git-email GIT_EMAIL] --organisation ORGANISATION + --repository-name REPOSITORY_NAME + [--git-provider GIT_PROVIDER] + [--git-provider-url GIT_PROVIDER_URL] + [--create-pr [CREATE_PR]] [--auto-merge [AUTO_MERGE]] + [--merge-method MERGE_METHOD] [-v [VERBOSE]] optional arguments: -h, --help show this help message and exit --file FILE YAML file path - --values VALUES YAML/JSON object with the YAML path as key and the desired value as value + --values VALUES YAML/JSON object with the YAML path as key and the + desired value as value --single-commit [SINGLE_COMMIT] Create only single commit for all updates --commit-message COMMIT_MESSAGE Specify exact commit message of deployment commit - --username USERNAME Git username (alternative: GITOPSCLI_USERNAME env variable) - --password PASSWORD Git password or token (alternative: GITOPSCLI_PASSWORD env variable) + --username USERNAME Git username (alternative: GITOPSCLI_USERNAME env + variable) + --password PASSWORD Git password or token (alternative: GITOPSCLI_PASSWORD + env variable) --git-user GIT_USER Git Username --git-email GIT_EMAIL Git User Email @@ -143,13 +153,16 @@ optional arguments: --git-provider GIT_PROVIDER Git server provider --git-provider-url GIT_PROVIDER_URL - Git provider base API URL (e.g. https://bitbucket.example.tld) + Git provider base API URL (e.g. + https://bitbucket.example.tld) --create-pr [CREATE_PR] Creates a Pull Request --auto-merge [AUTO_MERGE] - Automatically merge the created PR (only valid with --create-pr) + Automatically merge the created PR (only valid with + --create-pr) --merge-method MERGE_METHOD - Merge Method (e.g., 'squash', 'rebase', 'merge') (default: merge) + Merge Method (e.g., 'squash', 'rebase', 'merge') + (default: merge) -v [VERBOSE], --verbose [VERBOSE] Verbose exception logging ``` diff --git a/gitopscli/cliparser.py b/gitopscli/cliparser.py index b6fa8b7b..9bd3d0ec 100644 --- a/gitopscli/cliparser.py +++ b/gitopscli/cliparser.py @@ -44,7 +44,9 @@ def __create_parser() -> ArgumentParser: parents=[__create_sync_apps_parser()], ) subparsers.add_parser( - "add-pr-comment", help="Create a comment on the pull request", parents=[__create_add_pr_comment_parser()], + "add-pr-comment", + help="Create a comment on the pull request", + parents=[__create_add_pr_comment_parser()], ) subparsers.add_parser( "create-preview", help="Create a preview environment", parents=[__create_create_preview_parser()] @@ -56,7 +58,9 @@ def __create_parser() -> ArgumentParser: "delete-preview", help="Delete a preview environment", parents=[__create_delete_preview_parser()] ) subparsers.add_parser( - "delete-pr-preview", help="Delete a pr preview environment", parents=[__create_delete_pr_preview_parser()], + "delete-pr-preview", + help="Delete a pr preview environment", + parents=[__create_delete_pr_preview_parser()], ) subparsers.add_parser( "version", help="Show the GitOps CLI version information", parents=[__create_version_parser()] @@ -82,14 +86,22 @@ def __create_deploy_parser() -> ArgumentParser: default=False, ) parser.add_argument( - "--commit-message", help="Specify exact commit message of deployment commit", type=str, default=None, + "--commit-message", + help="Specify exact commit message of deployment commit", + type=str, + default=None, ) __add_git_credentials_args(parser) __add_git_commit_user_args(parser) __add_git_org_and_repo_args(parser) __add_git_provider_args(parser) parser.add_argument( - "--create-pr", help="Creates a Pull Request", type=__parse_bool, nargs="?", const=True, default=False, + "--create-pr", + help="Creates a Pull Request", + type=__parse_bool, + nargs="?", + const=True, + default=False, ) parser.add_argument( "--auto-merge", @@ -99,8 +111,12 @@ def __create_deploy_parser() -> ArgumentParser: const=True, default=False, ) - parser.add_argument("--merge-method", help="Merge Method (e.g., 'squash', 'rebase', 'merge') (default: merge)", type=str, - default="merge") + parser.add_argument( + "--merge-method", + help="Merge Method (e.g., 'squash', 'rebase', 'merge') (default: merge)", + type=str, + default="merge", + ) __add_verbose_arg(parser) return parser @@ -236,7 +252,13 @@ def __add_expect_preview_exists_arg(parser: ArgumentParser) -> None: def __add_verbose_arg(parser: ArgumentParser) -> None: parser.add_argument( - "-v", "--verbose", help="Verbose exception logging", type=__parse_bool, nargs="?", const=True, default=False, + "-v", + "--verbose", + help="Verbose exception logging", + type=__parse_bool, + nargs="?", + const=True, + default=False, ) diff --git a/gitopscli/commands/deploy.py b/gitopscli/commands/deploy.py index b69dd6c0..691d243c 100644 --- a/gitopscli/commands/deploy.py +++ b/gitopscli/commands/deploy.py @@ -25,7 +25,7 @@ class Args(GitApiConfig): create_pr: bool auto_merge: bool - merge_method: Optional[Literal["squash", "rebase", "merge"]] = "merge" + merge_method: Literal["squash", "rebase", "merge"] = "merge" def __init__(self, args: Args) -> None: self.__args = args diff --git a/gitopscli/git_api/bitbucket_git_repo_api_adapter.py b/gitopscli/git_api/bitbucket_git_repo_api_adapter.py index 163bf6c3..0d4a01fb 100644 --- a/gitopscli/git_api/bitbucket_git_repo_api_adapter.py +++ b/gitopscli/git_api/bitbucket_git_repo_api_adapter.py @@ -1,4 +1,4 @@ -from typing import Optional +from typing import Optional, Literal import requests from atlassian import Bitbucket @@ -74,7 +74,9 @@ def create_pull_request( raise GitOpsException(pull_request["errors"][0]["message"]) return GitRepoApi.PullRequestIdAndUrl(pr_id=pull_request["id"], url=pull_request["links"]["self"][0]["href"]) - def merge_pull_request(self, pr_id: int) -> None: + def merge_pull_request( + self, pr_id: int, merge_method: Literal["squash", "rebase", "merge"] = "merge" + ) -> None: pull_request = self.__bitbucket.get_pullrequest(self.__organisation, self.__repository_name, pr_id) self.__bitbucket.merge_pull_request( self.__organisation, self.__repository_name, pull_request["id"], pull_request["version"] diff --git a/gitopscli/git_api/git_repo_api.py b/gitopscli/git_api/git_repo_api.py index 8abd4138..535c2d2b 100644 --- a/gitopscli/git_api/git_repo_api.py +++ b/gitopscli/git_api/git_repo_api.py @@ -32,7 +32,9 @@ def create_pull_request( ... @abstractmethod - def merge_pull_request(self, pr_id: int, merge_method: Optional[Literal["squash", "rebase", "merge"]] = "merge") -> None: + def merge_pull_request( + self, pr_id: int, merge_method: Literal["squash", "rebase", "merge"] = "merge" + ) -> None: ... @abstractmethod diff --git a/gitopscli/git_api/git_repo_api_logging_proxy.py b/gitopscli/git_api/git_repo_api_logging_proxy.py index f23403a6..da0dbda2 100644 --- a/gitopscli/git_api/git_repo_api_logging_proxy.py +++ b/gitopscli/git_api/git_repo_api_logging_proxy.py @@ -28,18 +28,25 @@ def create_pull_request( logging.info("Creating pull request from '%s' to '%s' with title: %s", from_branch, to_branch, title) return self.__api.create_pull_request(from_branch, to_branch, title, description) - def merge_pull_request(self, pr_id: int, merge_method: Optional[Literal["squash", "rebase", "merge"]] = "merge") -> None: + def merge_pull_request( + self, pr_id: int, merge_method: Literal["squash", "rebase", "merge"] = "merge" + ) -> None: logging.info("Merging pull request %s", pr_id) self.__api.merge_pull_request(pr_id, merge_method=merge_method) def add_pull_request_comment(self, pr_id: int, text: str, parent_id: Optional[int] = None) -> None: if parent_id: logging.info( - "Creating comment for pull request %s as reply to comment %s with content: %s", pr_id, parent_id, text, + "Creating comment for pull request %s as reply to comment %s with content: %s", + pr_id, + parent_id, + text, ) else: logging.info( - "Creating comment for pull request %s with content: %s", pr_id, text, + "Creating comment for pull request %s with content: %s", + pr_id, + text, ) self.__api.add_pull_request_comment(pr_id, text, parent_id) diff --git a/gitopscli/git_api/github_git_repo_api_adapter.py b/gitopscli/git_api/github_git_repo_api_adapter.py index 145abe2b..116a0729 100644 --- a/gitopscli/git_api/github_git_repo_api_adapter.py +++ b/gitopscli/git_api/github_git_repo_api_adapter.py @@ -1,6 +1,13 @@ from typing import Optional, Literal -from github import Github, UnknownObjectException, BadCredentialsException, GitRef, PullRequest, Repository, \ - GithubException +from github import ( + Github, + UnknownObjectException, + BadCredentialsException, + GitRef, + PullRequest, + Repository, + GithubException, +) from gitopscli.gitops_exception import GitOpsException from .git_repo_api import GitRepoApi @@ -37,7 +44,9 @@ def create_pull_request( pull_request = repo.create_pull(title=title, body=description, head=from_branch, base=to_branch) return GitRepoApi.PullRequestIdAndUrl(pr_id=pull_request.number, url=pull_request.html_url) - def merge_pull_request(self, pr_id: int, merge_method: Optional[Literal["squash", "rebase", "merge"]] = "merge") -> None: + def merge_pull_request( + self, pr_id: int, merge_method: Literal["squash", "rebase", "merge"] = "merge" + ) -> None: pull_request = self.__get_pull_request(pr_id) pull_request.merge(merge_method=merge_method) diff --git a/gitopscli/git_api/gitlab_git_repo_api_adapter.py b/gitopscli/git_api/gitlab_git_repo_api_adapter.py index 5d660449..565670e1 100644 --- a/gitopscli/git_api/gitlab_git_repo_api_adapter.py +++ b/gitopscli/git_api/gitlab_git_repo_api_adapter.py @@ -1,4 +1,4 @@ -from typing import Optional +from typing import Optional, Literal import logging import time import requests @@ -59,12 +59,17 @@ def create_pull_request( ) return GitRepoApi.PullRequestIdAndUrl(pr_id=merge_request.iid, url=merge_request.web_url) - def merge_pull_request(self, pr_id: int) -> None: + def merge_pull_request( + self, pr_id: int, merge_method: Literal["squash", "rebase", "merge"] = "merge" + ) -> None: merge_request = self.__project.mergerequests.get(pr_id) max_retries = MAX_MERGE_RETRIES while max_retries > 0: try: + if merge_method == "rebase": + merge_request.rebase() + return merge_request.merge() return except gitlab.exceptions.GitlabMRClosedError as ex: diff --git a/tests/commands/common/test_gitops_config_loader.py b/tests/commands/common/test_gitops_config_loader.py index c2e0810c..41e09c26 100644 --- a/tests/commands/common/test_gitops_config_loader.py +++ b/tests/commands/common/test_gitops_config_loader.py @@ -11,7 +11,10 @@ class GitOpsConfigLoaderTest(MockMixin, unittest.TestCase): git_api_config = GitApiConfig( - username="USERNAME", password="PASSWORD", git_provider=GitProvider.GITHUB, git_provider_url=None, + username="USERNAME", + password="PASSWORD", + git_provider=GitProvider.GITHUB, + git_provider_url=None, ) def setUp(self): diff --git a/tests/commands/test_deploy.py b/tests/commands/test_deploy.py index 5452b896..c0acfa3f 100644 --- a/tests/commands/test_deploy.py +++ b/tests/commands/test_deploy.py @@ -194,7 +194,7 @@ def test_create_pr_and_merge_happy_flow(self): "Updated values in test/file.yml", "Updated 2 values in `test/file.yml`:\n```yaml\na.b.c: foo\na.b.d: bar\n```\n", ), - call.GitRepoApi.merge_pull_request(42), + call.GitRepoApi.merge_pull_request(42, "merge"), call.GitRepoApi.delete_branch("gitopscli-deploy-b973b5bb"), ] diff --git a/tests/git_api/test_git_repo_api_logging_proxy.py b/tests/git_api/test_git_repo_api_logging_proxy.py index 0a900eb6..be82b5e8 100644 --- a/tests/git_api/test_git_repo_api_logging_proxy.py +++ b/tests/git_api/test_git_repo_api_logging_proxy.py @@ -51,7 +51,10 @@ def test_create_pull_request(self, logging_mock): "", "", "", "<description>" ) logging_mock.info.assert_called_once_with( - "Creating pull request from '%s' to '%s' with title: %s", "<from branch>", "<to branch>", "<title>", + "Creating pull request from '%s' to '%s' with title: %s", + "<from branch>", + "<to branch>", + "<title>", ) @patch("gitopscli.git_api.git_repo_api_logging_proxy.logging") @@ -68,15 +71,18 @@ def test_create_pull_request_to_default_branch(self, logging_mock): "<from branch>", "<title>", "<description>" ) logging_mock.info.assert_called_once_with( - "Creating pull request from '%s' to default branch with title: %s", "<from branch>", "<title>", + "Creating pull request from '%s' to default branch with title: %s", + "<from branch>", + "<title>", ) @patch("gitopscli.git_api.git_repo_api_logging_proxy.logging") def test_merge_pull_request(self, logging_mock): self.__testee.merge_pull_request(pr_id=42) - self.__mock_repo_api.merge_pull_request.assert_called_once_with(42) + self.__mock_repo_api.merge_pull_request.assert_called_once_with(42, merge_method="merge") logging_mock.info.assert_called_once_with( - "Merging pull request %s", 42, + "Merging pull request %s", + 42, ) @patch("gitopscli.git_api.git_repo_api_logging_proxy.logging") @@ -84,7 +90,10 @@ def test_add_pull_request_comment(self, logging_mock): self.__testee.add_pull_request_comment(pr_id=42, text="<text>", parent_id=4711) self.__mock_repo_api.add_pull_request_comment.assert_called_once_with(42, "<text>", 4711) logging_mock.info.assert_called_once_with( - "Creating comment for pull request %s as reply to comment %s with content: %s", 42, 4711, "<text>", + "Creating comment for pull request %s as reply to comment %s with content: %s", + 42, + 4711, + "<text>", ) @patch("gitopscli.git_api.git_repo_api_logging_proxy.logging") @@ -92,7 +101,9 @@ def test_add_pull_request_comment_without_parent_id(self, logging_mock): self.__testee.add_pull_request_comment(pr_id=42, text="<text>", parent_id=None) self.__mock_repo_api.add_pull_request_comment.assert_called_once_with(42, "<text>", None) logging_mock.info.assert_called_once_with( - "Creating comment for pull request %s with content: %s", 42, "<text>", + "Creating comment for pull request %s with content: %s", + 42, + "<text>", ) @patch("gitopscli.git_api.git_repo_api_logging_proxy.logging") @@ -100,7 +111,8 @@ def test_delete_branch(self, logging_mock): self.__testee.delete_branch("<branch>") self.__mock_repo_api.delete_branch.assert_called_once_with("<branch>") logging_mock.info.assert_called_once_with( - "Deleting branch '%s'", "<branch>", + "Deleting branch '%s'", + "<branch>", ) def test_get_branch_head_hash(self): diff --git a/tests/git_api/test_repo_api_factory.py b/tests/git_api/test_repo_api_factory.py index 3957c332..160c7c7b 100644 --- a/tests/git_api/test_repo_api_factory.py +++ b/tests/git_api/test_repo_api_factory.py @@ -17,7 +17,10 @@ def test_create_github(self, mock_github_adapter_constructor, mock_logging_proxy git_repo_api = GitRepoApiFactory.create( config=GitApiConfig( - username="USER", password="PASS", git_provider=GitProvider.GITHUB, git_provider_url=None, + username="USER", + password="PASS", + git_provider=GitProvider.GITHUB, + git_provider_url=None, ), organisation="ORG", repository_name="REPO", @@ -26,7 +29,10 @@ def test_create_github(self, mock_github_adapter_constructor, mock_logging_proxy self.assertEqual(git_repo_api, mock_logging_proxy) mock_github_adapter_constructor.assert_called_with( - username="USER", password="PASS", organisation="ORG", repository_name="REPO", + username="USER", + password="PASS", + organisation="ORG", + repository_name="REPO", ) mock_logging_proxy_constructor.assert_called_with(mock_github_adapter) @@ -41,7 +47,10 @@ def test_create_bitbucket(self, mock_bitbucket_adapter_constructor, mock_logging git_repo_api = GitRepoApiFactory.create( config=GitApiConfig( - username="USER", password="PASS", git_provider=GitProvider.BITBUCKET, git_provider_url="PROVIDER_URL", + username="USER", + password="PASS", + git_provider=GitProvider.BITBUCKET, + git_provider_url="PROVIDER_URL", ), organisation="ORG", repository_name="REPO", @@ -62,7 +71,10 @@ def test_create_bitbucket_missing_url(self): try: GitRepoApiFactory.create( config=GitApiConfig( - username="USER", password="PASS", git_provider=GitProvider.BITBUCKET, git_provider_url=None, + username="USER", + password="PASS", + git_provider=GitProvider.BITBUCKET, + git_provider_url=None, ), organisation="ORG", repository_name="REPO", diff --git a/tests/test_cliparser.py b/tests/test_cliparser.py index 5b254ee8..175feb4c 100644 --- a/tests/test_cliparser.py +++ b/tests/test_cliparser.py @@ -284,7 +284,7 @@ [--git-provider GIT_PROVIDER] [--git-provider-url GIT_PROVIDER_URL] [--create-pr [CREATE_PR]] [--auto-merge [AUTO_MERGE]] - [-v [VERBOSE]] + [--merge-method MERGE_METHOD] [-v [VERBOSE]] gitopscli deploy: error: the following arguments are required: --file, --values, --username, --password, --organisation, --repository-name """ @@ -298,7 +298,7 @@ [--git-provider GIT_PROVIDER] [--git-provider-url GIT_PROVIDER_URL] [--create-pr [CREATE_PR]] [--auto-merge [AUTO_MERGE]] - [-v [VERBOSE]] + [--merge-method MERGE_METHOD] [-v [VERBOSE]] optional arguments: -h, --help show this help message and exit @@ -330,6 +330,9 @@ --auto-merge [AUTO_MERGE] Automatically merge the created PR (only valid with --create-pr) + --merge-method MERGE_METHOD + Merge Method (e.g., 'squash', 'rebase', 'merge') + (default: merge) -v [VERBOSE], --verbose [VERBOSE] Verbose exception logging """ @@ -1265,7 +1268,8 @@ def test_invalid_yaml(self): self.assertEqual("", stdout) last_stderr_line = stderr.splitlines()[-1] self.assertEqual( - "gitopscli deploy: error: argument --values: invalid YAML value: '{ INVALID YAML'", last_stderr_line, + "gitopscli deploy: error: argument --values: invalid YAML value: '{ INVALID YAML'", + last_stderr_line, ) def test_invalid_git_provider(self): From 163d2d8168d8f3559dff6684ad475b866463dbc9 Mon Sep 17 00:00:00 2001 From: socar-humphrey <humphrey@socar.kr> Date: Thu, 1 Jul 2021 09:53:30 +0900 Subject: [PATCH 5/6] style(gitopscli/*): apply black formatting for build pass from https://travis-ci.com/github/baloise/gitopscli/jobs/520716793 --- gitopscli/cliparser.py | 28 ++++--------------- .../git_api/bitbucket_git_repo_api_adapter.py | 4 +-- gitopscli/git_api/git_repo_api.py | 4 +-- .../git_api/git_repo_api_logging_proxy.py | 13 ++------- .../git_api/github_git_repo_api_adapter.py | 4 +-- .../git_api/gitlab_git_repo_api_adapter.py | 4 +-- .../common/test_gitops_config_loader.py | 5 +--- .../test_git_repo_api_logging_proxy.py | 24 ++++------------ tests/git_api/test_repo_api_factory.py | 20 +++---------- tests/test_cliparser.py | 3 +- 10 files changed, 24 insertions(+), 85 deletions(-) diff --git a/gitopscli/cliparser.py b/gitopscli/cliparser.py index 9bd3d0ec..0cc8b30f 100644 --- a/gitopscli/cliparser.py +++ b/gitopscli/cliparser.py @@ -44,9 +44,7 @@ def __create_parser() -> ArgumentParser: parents=[__create_sync_apps_parser()], ) subparsers.add_parser( - "add-pr-comment", - help="Create a comment on the pull request", - parents=[__create_add_pr_comment_parser()], + "add-pr-comment", help="Create a comment on the pull request", parents=[__create_add_pr_comment_parser()], ) subparsers.add_parser( "create-preview", help="Create a preview environment", parents=[__create_create_preview_parser()] @@ -58,9 +56,7 @@ def __create_parser() -> ArgumentParser: "delete-preview", help="Delete a preview environment", parents=[__create_delete_preview_parser()] ) subparsers.add_parser( - "delete-pr-preview", - help="Delete a pr preview environment", - parents=[__create_delete_pr_preview_parser()], + "delete-pr-preview", help="Delete a pr preview environment", parents=[__create_delete_pr_preview_parser()], ) subparsers.add_parser( "version", help="Show the GitOps CLI version information", parents=[__create_version_parser()] @@ -86,22 +82,14 @@ def __create_deploy_parser() -> ArgumentParser: default=False, ) parser.add_argument( - "--commit-message", - help="Specify exact commit message of deployment commit", - type=str, - default=None, + "--commit-message", help="Specify exact commit message of deployment commit", type=str, default=None, ) __add_git_credentials_args(parser) __add_git_commit_user_args(parser) __add_git_org_and_repo_args(parser) __add_git_provider_args(parser) parser.add_argument( - "--create-pr", - help="Creates a Pull Request", - type=__parse_bool, - nargs="?", - const=True, - default=False, + "--create-pr", help="Creates a Pull Request", type=__parse_bool, nargs="?", const=True, default=False, ) parser.add_argument( "--auto-merge", @@ -252,13 +240,7 @@ def __add_expect_preview_exists_arg(parser: ArgumentParser) -> None: def __add_verbose_arg(parser: ArgumentParser) -> None: parser.add_argument( - "-v", - "--verbose", - help="Verbose exception logging", - type=__parse_bool, - nargs="?", - const=True, - default=False, + "-v", "--verbose", help="Verbose exception logging", type=__parse_bool, nargs="?", const=True, default=False, ) diff --git a/gitopscli/git_api/bitbucket_git_repo_api_adapter.py b/gitopscli/git_api/bitbucket_git_repo_api_adapter.py index 0d4a01fb..4c8cf7b9 100644 --- a/gitopscli/git_api/bitbucket_git_repo_api_adapter.py +++ b/gitopscli/git_api/bitbucket_git_repo_api_adapter.py @@ -74,9 +74,7 @@ def create_pull_request( raise GitOpsException(pull_request["errors"][0]["message"]) return GitRepoApi.PullRequestIdAndUrl(pr_id=pull_request["id"], url=pull_request["links"]["self"][0]["href"]) - def merge_pull_request( - self, pr_id: int, merge_method: Literal["squash", "rebase", "merge"] = "merge" - ) -> None: + def merge_pull_request(self, pr_id: int, merge_method: Literal["squash", "rebase", "merge"] = "merge") -> None: pull_request = self.__bitbucket.get_pullrequest(self.__organisation, self.__repository_name, pr_id) self.__bitbucket.merge_pull_request( self.__organisation, self.__repository_name, pull_request["id"], pull_request["version"] diff --git a/gitopscli/git_api/git_repo_api.py b/gitopscli/git_api/git_repo_api.py index 535c2d2b..bbc31015 100644 --- a/gitopscli/git_api/git_repo_api.py +++ b/gitopscli/git_api/git_repo_api.py @@ -32,9 +32,7 @@ def create_pull_request( ... @abstractmethod - def merge_pull_request( - self, pr_id: int, merge_method: Literal["squash", "rebase", "merge"] = "merge" - ) -> None: + def merge_pull_request(self, pr_id: int, merge_method: Literal["squash", "rebase", "merge"] = "merge") -> None: ... @abstractmethod diff --git a/gitopscli/git_api/git_repo_api_logging_proxy.py b/gitopscli/git_api/git_repo_api_logging_proxy.py index da0dbda2..d248e845 100644 --- a/gitopscli/git_api/git_repo_api_logging_proxy.py +++ b/gitopscli/git_api/git_repo_api_logging_proxy.py @@ -28,25 +28,18 @@ def create_pull_request( logging.info("Creating pull request from '%s' to '%s' with title: %s", from_branch, to_branch, title) return self.__api.create_pull_request(from_branch, to_branch, title, description) - def merge_pull_request( - self, pr_id: int, merge_method: Literal["squash", "rebase", "merge"] = "merge" - ) -> None: + def merge_pull_request(self, pr_id: int, merge_method: Literal["squash", "rebase", "merge"] = "merge") -> None: logging.info("Merging pull request %s", pr_id) self.__api.merge_pull_request(pr_id, merge_method=merge_method) def add_pull_request_comment(self, pr_id: int, text: str, parent_id: Optional[int] = None) -> None: if parent_id: logging.info( - "Creating comment for pull request %s as reply to comment %s with content: %s", - pr_id, - parent_id, - text, + "Creating comment for pull request %s as reply to comment %s with content: %s", pr_id, parent_id, text, ) else: logging.info( - "Creating comment for pull request %s with content: %s", - pr_id, - text, + "Creating comment for pull request %s with content: %s", pr_id, text, ) self.__api.add_pull_request_comment(pr_id, text, parent_id) diff --git a/gitopscli/git_api/github_git_repo_api_adapter.py b/gitopscli/git_api/github_git_repo_api_adapter.py index 116a0729..4dda5e56 100644 --- a/gitopscli/git_api/github_git_repo_api_adapter.py +++ b/gitopscli/git_api/github_git_repo_api_adapter.py @@ -44,9 +44,7 @@ def create_pull_request( pull_request = repo.create_pull(title=title, body=description, head=from_branch, base=to_branch) return GitRepoApi.PullRequestIdAndUrl(pr_id=pull_request.number, url=pull_request.html_url) - def merge_pull_request( - self, pr_id: int, merge_method: Literal["squash", "rebase", "merge"] = "merge" - ) -> None: + def merge_pull_request(self, pr_id: int, merge_method: Literal["squash", "rebase", "merge"] = "merge") -> None: pull_request = self.__get_pull_request(pr_id) pull_request.merge(merge_method=merge_method) diff --git a/gitopscli/git_api/gitlab_git_repo_api_adapter.py b/gitopscli/git_api/gitlab_git_repo_api_adapter.py index 565670e1..1916a235 100644 --- a/gitopscli/git_api/gitlab_git_repo_api_adapter.py +++ b/gitopscli/git_api/gitlab_git_repo_api_adapter.py @@ -59,9 +59,7 @@ def create_pull_request( ) return GitRepoApi.PullRequestIdAndUrl(pr_id=merge_request.iid, url=merge_request.web_url) - def merge_pull_request( - self, pr_id: int, merge_method: Literal["squash", "rebase", "merge"] = "merge" - ) -> None: + def merge_pull_request(self, pr_id: int, merge_method: Literal["squash", "rebase", "merge"] = "merge") -> None: merge_request = self.__project.mergerequests.get(pr_id) max_retries = MAX_MERGE_RETRIES diff --git a/tests/commands/common/test_gitops_config_loader.py b/tests/commands/common/test_gitops_config_loader.py index 41e09c26..c2e0810c 100644 --- a/tests/commands/common/test_gitops_config_loader.py +++ b/tests/commands/common/test_gitops_config_loader.py @@ -11,10 +11,7 @@ class GitOpsConfigLoaderTest(MockMixin, unittest.TestCase): git_api_config = GitApiConfig( - username="USERNAME", - password="PASSWORD", - git_provider=GitProvider.GITHUB, - git_provider_url=None, + username="USERNAME", password="PASSWORD", git_provider=GitProvider.GITHUB, git_provider_url=None, ) def setUp(self): diff --git a/tests/git_api/test_git_repo_api_logging_proxy.py b/tests/git_api/test_git_repo_api_logging_proxy.py index be82b5e8..f1180f1c 100644 --- a/tests/git_api/test_git_repo_api_logging_proxy.py +++ b/tests/git_api/test_git_repo_api_logging_proxy.py @@ -51,10 +51,7 @@ def test_create_pull_request(self, logging_mock): "<from branch>", "<to branch>", "<title>", "<description>" ) logging_mock.info.assert_called_once_with( - "Creating pull request from '%s' to '%s' with title: %s", - "<from branch>", - "<to branch>", - "<title>", + "Creating pull request from '%s' to '%s' with title: %s", "<from branch>", "<to branch>", "<title>", ) @patch("gitopscli.git_api.git_repo_api_logging_proxy.logging") @@ -71,9 +68,7 @@ def test_create_pull_request_to_default_branch(self, logging_mock): "<from branch>", "<title>", "<description>" ) logging_mock.info.assert_called_once_with( - "Creating pull request from '%s' to default branch with title: %s", - "<from branch>", - "<title>", + "Creating pull request from '%s' to default branch with title: %s", "<from branch>", "<title>", ) @patch("gitopscli.git_api.git_repo_api_logging_proxy.logging") @@ -81,8 +76,7 @@ def test_merge_pull_request(self, logging_mock): self.__testee.merge_pull_request(pr_id=42) self.__mock_repo_api.merge_pull_request.assert_called_once_with(42, merge_method="merge") logging_mock.info.assert_called_once_with( - "Merging pull request %s", - 42, + "Merging pull request %s", 42, ) @patch("gitopscli.git_api.git_repo_api_logging_proxy.logging") @@ -90,10 +84,7 @@ def test_add_pull_request_comment(self, logging_mock): self.__testee.add_pull_request_comment(pr_id=42, text="<text>", parent_id=4711) self.__mock_repo_api.add_pull_request_comment.assert_called_once_with(42, "<text>", 4711) logging_mock.info.assert_called_once_with( - "Creating comment for pull request %s as reply to comment %s with content: %s", - 42, - 4711, - "<text>", + "Creating comment for pull request %s as reply to comment %s with content: %s", 42, 4711, "<text>", ) @patch("gitopscli.git_api.git_repo_api_logging_proxy.logging") @@ -101,9 +92,7 @@ def test_add_pull_request_comment_without_parent_id(self, logging_mock): self.__testee.add_pull_request_comment(pr_id=42, text="<text>", parent_id=None) self.__mock_repo_api.add_pull_request_comment.assert_called_once_with(42, "<text>", None) logging_mock.info.assert_called_once_with( - "Creating comment for pull request %s with content: %s", - 42, - "<text>", + "Creating comment for pull request %s with content: %s", 42, "<text>", ) @patch("gitopscli.git_api.git_repo_api_logging_proxy.logging") @@ -111,8 +100,7 @@ def test_delete_branch(self, logging_mock): self.__testee.delete_branch("<branch>") self.__mock_repo_api.delete_branch.assert_called_once_with("<branch>") logging_mock.info.assert_called_once_with( - "Deleting branch '%s'", - "<branch>", + "Deleting branch '%s'", "<branch>", ) def test_get_branch_head_hash(self): diff --git a/tests/git_api/test_repo_api_factory.py b/tests/git_api/test_repo_api_factory.py index 160c7c7b..3957c332 100644 --- a/tests/git_api/test_repo_api_factory.py +++ b/tests/git_api/test_repo_api_factory.py @@ -17,10 +17,7 @@ def test_create_github(self, mock_github_adapter_constructor, mock_logging_proxy git_repo_api = GitRepoApiFactory.create( config=GitApiConfig( - username="USER", - password="PASS", - git_provider=GitProvider.GITHUB, - git_provider_url=None, + username="USER", password="PASS", git_provider=GitProvider.GITHUB, git_provider_url=None, ), organisation="ORG", repository_name="REPO", @@ -29,10 +26,7 @@ def test_create_github(self, mock_github_adapter_constructor, mock_logging_proxy self.assertEqual(git_repo_api, mock_logging_proxy) mock_github_adapter_constructor.assert_called_with( - username="USER", - password="PASS", - organisation="ORG", - repository_name="REPO", + username="USER", password="PASS", organisation="ORG", repository_name="REPO", ) mock_logging_proxy_constructor.assert_called_with(mock_github_adapter) @@ -47,10 +41,7 @@ def test_create_bitbucket(self, mock_bitbucket_adapter_constructor, mock_logging git_repo_api = GitRepoApiFactory.create( config=GitApiConfig( - username="USER", - password="PASS", - git_provider=GitProvider.BITBUCKET, - git_provider_url="PROVIDER_URL", + username="USER", password="PASS", git_provider=GitProvider.BITBUCKET, git_provider_url="PROVIDER_URL", ), organisation="ORG", repository_name="REPO", @@ -71,10 +62,7 @@ def test_create_bitbucket_missing_url(self): try: GitRepoApiFactory.create( config=GitApiConfig( - username="USER", - password="PASS", - git_provider=GitProvider.BITBUCKET, - git_provider_url=None, + username="USER", password="PASS", git_provider=GitProvider.BITBUCKET, git_provider_url=None, ), organisation="ORG", repository_name="REPO", diff --git a/tests/test_cliparser.py b/tests/test_cliparser.py index 175feb4c..f88b12ee 100644 --- a/tests/test_cliparser.py +++ b/tests/test_cliparser.py @@ -1268,8 +1268,7 @@ def test_invalid_yaml(self): self.assertEqual("", stdout) last_stderr_line = stderr.splitlines()[-1] self.assertEqual( - "gitopscli deploy: error: argument --values: invalid YAML value: '{ INVALID YAML'", - last_stderr_line, + "gitopscli deploy: error: argument --values: invalid YAML value: '{ INVALID YAML'", last_stderr_line, ) def test_invalid_git_provider(self): From 97f50939fd35a610be3bd659617faff4d65f8673 Mon Sep 17 00:00:00 2001 From: socar-humphrey <humphrey@socar.kr> Date: Thu, 1 Jul 2021 10:00:39 +0900 Subject: [PATCH 6/6] refactor(gitopscli/git_api): remove unused import --- gitopscli/git_api/github_git_repo_api_adapter.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gitopscli/git_api/github_git_repo_api_adapter.py b/gitopscli/git_api/github_git_repo_api_adapter.py index 4dda5e56..0269cccd 100644 --- a/gitopscli/git_api/github_git_repo_api_adapter.py +++ b/gitopscli/git_api/github_git_repo_api_adapter.py @@ -1,4 +1,5 @@ from typing import Optional, Literal + from github import ( Github, UnknownObjectException, @@ -6,8 +7,8 @@ GitRef, PullRequest, Repository, - GithubException, ) + from gitopscli.gitops_exception import GitOpsException from .git_repo_api import GitRepoApi