Skip to content

Commit

Permalink
Merge pull request #375 from ckleemann/master
Browse files Browse the repository at this point in the history
Remove leading slash from .pyup.yml to fix bug on gitlab api
  • Loading branch information
rafaelpivato authored Mar 28, 2020
2 parents 587ce37 + 6e6b0b7 commit 6d4b08a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
8 changes: 4 additions & 4 deletions pyup/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def pull_requests(self):

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)
content, _ = self.provider.get_file(repo, ".pyup.yml", branch)
if content is not None:
try:
return yaml.safe_load(content)
Expand Down Expand Up @@ -361,14 +361,14 @@ def pull_config(self, new_config): # pragma: no cover
branch = 'pyup-config'
if self.create_branch(branch, delete_empty=True):
content = self.config.generate_config_file(new_config)
_, content_file = self.provider.get_file(self.user_repo, '/.pyup.yml', branch)
_, content_file = self.provider.get_file(self.user_repo, '.pyup.yml', branch)
if content_file:
# a config file exists, update and commit it
logger.info(
"Config file exists, updating config for sha {}".format(content_file.sha))
self.provider.create_commit(
repo=self.user_repo,
path="/.pyup.yml",
path=".pyup.yml",
branch=branch,
content=content,
commit_message="update pyup.io config file",
Expand All @@ -379,7 +379,7 @@ def pull_config(self, new_config): # pragma: no cover
# there's no config file present, write a new config file and commit it
self.provider.create_and_commit_file(
repo=self.user_repo,
path="/.pyup.yml",
path=".pyup.yml",
branch=branch,
content=content,
commit_message="create pyup.io config file",
Expand Down
2 changes: 2 additions & 0 deletions pyup/providers/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def iter_git_tree(self, repo, branch):

def get_file(self, repo, path, branch):
logger.info("Getting file at {} for branch {}".format(path, branch))
# remove unnecessary leading slash to avoid gitlab errors. See #375
path = path.lstrip('/')
try:
contentfile = repo.files.get(file_path=path, ref=branch)
except GitlabGetError as e:
Expand Down

0 comments on commit 6d4b08a

Please sign in to comment.