Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't quote URLs in Github provider #344

Merged
merged 2 commits into from
May 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions pyup/providers/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,6 @@
import time
import logging
from github import Github, GithubException, UnknownObjectException, InputGitAuthor
try:
from urllib import quote # Python 2.X
except ImportError:
from urllib.parse import quote # Python 3+
from ..errors import BranchExistsError, NoPermissionError, RepoDoesNotExistError

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -76,7 +72,7 @@ def iter_git_tree(self, repo, branch):
def get_file(self, repo, path, branch):
logger.info("Getting file at {} for branch {}".format(path, branch))
try:
contentfile = repo.get_contents(quote(path), ref=branch)
contentfile = repo.get_contents(path, ref=branch)
return contentfile.decoded_content.decode("utf-8"), contentfile
except GithubException:
logger.warning("Unable to get {path} on {repo}".format(
Expand Down Expand Up @@ -163,7 +159,7 @@ def create_commit(self, path, branch, commit_message, content, sha, repo, commit
for i in range(1, 7):
try:
data = repo.update_file(
path=quote(path),
path=path,
message=commit_message,
content=content,
branch=branch,
Expand Down
10 changes: 7 additions & 3 deletions tests/test_github.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@ def test_get_repo(self):
self.provider._api().get_repo.assert_called_once_with("name")

def test_get_default_branch(self):

self.repo.default_branch = "foo"
self.assertEqual(
self.provider.get_default_branch(self.repo),
Expand Down Expand Up @@ -87,7 +86,6 @@ def test_iter_git_tree(self):
list(self.provider.iter_git_tree(self.repo, "some branch"))

def test_get_file(self):

content, obj = self.provider.get_file(self.repo, "path", "branch")
self.assertIsNotNone(content)
self.assertIsNotNone(obj)
Expand All @@ -98,8 +96,14 @@ def test_get_file(self):
self.assertIsNone(content)
self.assertIsNone(obj)

def test_get_requirement_file(self):
def test_get_file_placeholder(self):
# template path (e.g. cookiecutter template): '{' and '}' should not be escaped
content, obj = self.provider.get_file(self.repo, "{{path}}", "branch")
self.assertIsNotNone(content)
self.assertIsNotNone(obj)
self.repo.get_contents.assert_called_with("{{path}}", ref="branch")

def test_get_requirement_file(self):
req = self.provider.get_requirement_file(self.repo, "path", "branch")
self.assertIsNotNone(req)
self.provider.bundle.get_requirement_file_class.assert_called_once_with()
Expand Down