Skip to content

Commit

Permalink
Merge pull request #281 from kxepal/gitlab-api-v4
Browse files Browse the repository at this point in the history
Switch to Gitlab API v4
  • Loading branch information
jayfk committed Mar 14, 2018
2 parents b4c255c + 9bd083d commit fb220c1
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pyup/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ def commit_and_pull(self, initial, new_branch, title, body, updates):
"content": content}
else:
logger.error("Empty commit at {repo}, unable to update {title}.".format(
repo=self.user_repo.full_name, title=title)
repo=self.user_repo.path_with_namespace, title=title)
)

if updated_files:
Expand Down
8 changes: 4 additions & 4 deletions pyup/providers/gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def get_pull_request_permissions(self, user, repo):
return True

def iter_git_tree(self, repo, branch):
for item in repo.repository_tree(ref=branch, recursive=True):
for item in repo.repository_tree(ref=branch, recursive=True, all=True):
yield item['type'], item['path']

def get_file(self, repo, path, branch):
Expand All @@ -80,7 +80,7 @@ def create_and_commit_file(self, repo, path, branch, content, commit_message, co
# TODO: committer
return repo.files.create({
'file_path': path,
'branch_name': branch,
'branch': branch,
'content': content,
'commit_message': commit_message
})
Expand All @@ -96,7 +96,7 @@ def get_requirement_file(self, repo, path, branch):

def create_branch(self, repo, base_branch, new_branch):
try:
repo.branches.create({"branch_name": new_branch,
repo.branches.create({"branch": new_branch,
"ref": base_branch})
except GitlabCreateError as e:
if e.error_message == 'Branch already exists':
Expand Down Expand Up @@ -142,7 +142,7 @@ def create_commit(self, path, branch, commit_message, content, sha, repo, commit
f.content = b64encode(content.encode()).decode()
f.encoding = 'base64'
# TODO: committer
f.save(branch_name=branch, commit_message=commit_message)
f.save(branch=branch, commit_message=commit_message)

def close_pull_request(self, bot_repo, user_repo, mr, comment, prefix):
mr.state_event = 'close'
Expand Down
7 changes: 4 additions & 3 deletions tests/test_gitlab.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ def test_iter_git_tree(self):
self.repo.repository_tree.return_value = mocked_items
items = list(self.provider.iter_git_tree(self.repo, "some branch"))
self.repo.repository_tree.assert_called_with(ref="some branch",
all=True,
recursive=True)
self.assertEqual(items, [("type", "path")])

Expand All @@ -97,7 +98,7 @@ def test_get_requirement_file(self):
def test_create_branch(self):
self.provider.create_branch(self.repo, "base branch", "new branch")
self.repo.branches.create.assert_called_with(
{"branch_name": "new branch", "ref": "base branch"})
{"branch": "new branch", "ref": "base branch"})

def test_is_empty_branch(self):
with self.assertRaises(AssertionError):
Expand Down Expand Up @@ -138,7 +139,7 @@ def test_create_commit(self, time):
self.assertEquals(self.repo.files.get.call_count, 1)
self.assertEquals(file.content, b64encode(b"content").decode())
self.assertEquals(file.encoding, "base64")
file.save.assert_called_with(branch_name="branch", commit_message="commit")
file.save.assert_called_with(branch="branch", commit_message="commit")

def test_create_and_commit_file(self):
repo = Mock()
Expand All @@ -159,7 +160,7 @@ def test_create_and_commit_file(self):
)
repo.files.create.assert_called_once_with({
'file_path': path,
'branch_name': branch,
'branch': branch,
'content': content,
'commit_message': commit_message
})
Expand Down

0 comments on commit fb220c1

Please sign in to comment.