Skip to content

Commit

Permalink
make the issue creation configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
jayfk committed Mar 16, 2018
1 parent be55153 commit f58cd0f
Showing 1 changed file with 20 additions and 16 deletions.
36 changes: 20 additions & 16 deletions pyup/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,39 +69,43 @@ def pull_requests(self):
self._fetched_prs = True
return self.req_bundle.pull_requests

def get_repo_config(self, repo, branch=None):
def get_repo_config(self, repo, branch=None, create_error_issue=True):
branch = self.config.branch if branch is None else branch
content, _ = self.provider.get_file(repo, "/.pyup.yml", branch)
if content is not None:
try:
return yaml.safe_load(content)
except yaml.YAMLError as e:
err = ConfigError(content=content, error=e.__str__())
issue_title = "Invalid .pyup.yml detected"
# check that there's not an open issue already
if issue_title not in [pr.title for pr in self.pull_requests if pr.is_open]:
self.create_issue(
title=issue_title,
body="The bot encountered an error in your `.pyup.yml` config file:\n\n"
"```{error}\n```\n\n"
"You can validate it with this "
"[online YAML parser](http://yaml-online-parser.appspot.com/) or "
"by taking a look at the "
"[Documentation](https://pyup.io/docs/bot/config/).".format(
error=err.error)
)
if create_error_issue:
issue_title = "Invalid .pyup.yml detected"
# check that there's not an open issue already
if issue_title not in [pr.title for pr in self.pull_requests if pr.is_open]:
self.create_issue(
title=issue_title,
body="The bot encountered an error in your `.pyup.yml` config file:\n\n"
"```{error}\n```\n\n"
"You can validate it with this "
"[online YAML parser](http://yaml-online-parser.appspot.com/) or "
"by taking a look at the "
"[Documentation](https://pyup.io/docs/bot/config/).".format(
error=err.error)
)
raise err
return None

def configure(self, **kwargs):
def configure(self, create_error_issue=True, **kwargs):
if kwargs.get("write_config", False):
self.write_config = kwargs.get("write_config")
# if the branch is not set, get the default branch
if kwargs.get("branch", False) in [None, False]:
self.config.branch = self.provider.get_default_branch(repo=self.user_repo)
# set the config for this update run
self.config.update_config(kwargs)
repo_config = self.get_repo_config(repo=self.user_repo)
repo_config = self.get_repo_config(
repo=self.user_repo,
create_error_issue=create_error_issue
)
if repo_config:
self.config.update_config(repo_config)
if self.write_config:
Expand Down

0 comments on commit f58cd0f

Please sign in to comment.