This commit is contained in:
Laurent Mazuel 2018-02-13 15:00:25 -08:00 коммит произвёл Laurent Mazuel
Родитель ee3ab09941
Коммит b7215b1b9d
6 изменённых файлов: 16 добавлений и 62 удалений

3
.vscode/settings.json поставляемый
Просмотреть файл

@ -2,5 +2,6 @@
"python.unitTest.pyTestArgs": [
"."
],
"python.unitTest.pyTestEnabled": true
"python.unitTest.pyTestEnabled": true,
"python.linting.pylintUseMinimalCheckers": false
}

6
pylintrc Normal file
Просмотреть файл

@ -0,0 +1,6 @@
[MESSAGES CONTROL]
# For all codes, run 'pylint --list-msgs' or go to 'https://pylint.readthedocs.io/en/latest/reference_guide/features.html'
disable=missing-docstring
[FORMAT]
max-line-length=120

Просмотреть файл

@ -1,39 +1,13 @@
from collections import namedtuple
from contextlib import contextmanager
from functools import lru_cache
import logging
import os
import re
from pathlib import Path
import tempfile
import traceback
from github import Github
from git import Repo, GitCommandError
from swaggertosdk.build_sdk import generate as build_sdk
from swaggertosdk.SwaggerToSdkCore import (
CONFIG_FILE,
read_config,
DEFAULT_COMMIT_MESSAGE,
get_input_paths,
extract_conf_from_readmes,
build_swaggertosdk_conf_from_json_readme,
get_readme_files_from_git_objects
)
from swaggertosdk.SwaggerToSdkNewCLI import build_libraries
from swaggertosdk.git_tools import (
checkout_and_create_branch,
checkout_create_push_branch,
do_commit,
)
from swaggertosdk.github_tools import (
configure_user,
exception_to_github,
manage_git_folder,
do_pr,
create_comment,
GithubLink
)
_LOGGER = logging.getLogger(__name__)
@ -89,7 +63,7 @@ class BotHandler:
return {'message': 'I don\'t talk to myself, I\'m not schizo'}
webhook_data = build_from_issue_comment(self.gh_token, body)
return self.manage_comment(webhook_data)
def issues(self, body):
if self._is_myself(body):
return {'message': 'I don\'t talk to myself, I\'m not schizo'}
@ -112,7 +86,7 @@ class BotHandler:
split_text = command.lower().split()
order = split_text.pop(0)
if order == "help":
response = self.help_order(webhook_data.issue)
response = self.help_order()
elif order in self.orders():
with exception_to_github(webhook_data.issue): # Should do nothing, if handler is managing error correctly
response = getattr(self.handler, order)(webhook_data.issue, *split_text)
@ -123,9 +97,9 @@ class BotHandler:
return {'message': response}
return {'message': 'Nothing for me or exception'}
def help_order(self, issue):
def help_order(self):
orders = ["This is what I can do:"]
for order in self.orders():
orders.append("- `{}`".format(order))
for orderstr in self.orders():
orders.append("- `{}`".format(orderstr))
orders.append("- `help` : this help message")
return "\n".join(orders)

Просмотреть файл

@ -1,11 +1,9 @@
import os
from enum import Enum
from functools import lru_cache
import hmac
import hashlib
import logging
from queue import Queue
import re
import traceback
from threading import Thread

Просмотреть файл

@ -1,46 +1,34 @@
from collections import namedtuple
import logging
import os
import re
from pathlib import Path
import tempfile
import traceback
from github import Github
from git import Repo, GitCommandError
from swaggertosdk.build_sdk import generate as build_sdk
from swaggertosdk.SwaggerToSdkCore import (
CONFIG_FILE,
read_config,
DEFAULT_COMMIT_MESSAGE,
get_input_paths,
extract_conf_from_readmes,
build_swaggertosdk_conf_from_json_readme,
get_readme_files_from_git_objects
)
from swaggertosdk.SwaggerToSdkNewCLI import build_libraries
from swaggertosdk.git_tools import (
checkout_and_create_branch,
checkout_create_push_branch,
do_commit,
)
from swaggertosdk.github_tools import (
configure_user,
exception_to_github,
manage_git_folder,
do_pr,
create_comment,
GithubLink
)
_LOGGER = logging.getLogger(__name__)
def generate_sdk_from_git_object(git_object, branch_name, restapi_git_id, sdk_git_id, base_branch_names, *, fallback_base_branch_name="master", sdk_tag=None):
"""Generate SDK from a commit or a PR object.
git_object is the initial commit/PR from the RestAPI repo. restapi_git_id explains where to clone the repo.
sdk_git_id explains where to push the commit.
sdk_tag explains what is the tag used in the Readme for the swagger-to-sdk section. If not provided, use sdk_git_id.

Просмотреть файл

@ -1,36 +1,23 @@
from collections import namedtuple
from contextlib import contextmanager
import logging
import os
import re
from pathlib import Path
import tempfile
import traceback
from github import Github
from git import Repo, GitCommandError
from git import Repo
from swaggertosdk.build_sdk import generate as build_sdk
from swaggertosdk.SwaggerToSdkCore import (
CONFIG_FILE,
read_config,
DEFAULT_COMMIT_MESSAGE,
get_input_paths,
extract_conf_from_readmes,
build_swaggertosdk_conf_from_json_readme,
)
from swaggertosdk.SwaggerToSdkNewCLI import build_libraries
from swaggertosdk.git_tools import (
checkout_and_create_branch,
checkout_create_push_branch,
do_commit,
)
from swaggertosdk.github_tools import (
configure_user,
exception_to_github,
manage_git_folder,
do_pr,
create_comment,
GithubLink
)
from .bot_framework import (
@ -49,7 +36,7 @@ class GithubHandler:
def rebase(self, issue, branch=None):
if not issue.pull_request:
return "Rebase is just supported in PR for now"
pr = issue.repository.get_pull(issue.number)
branch_name = pr.head.ref