From d345d4b64a7090219910908432994493e7cd1d99 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 19 Mar 2019 12:09:31 +0000 Subject: [PATCH 1/2] Don't quote URLs in Github provider --- pyup/providers/github.py | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/pyup/providers/github.py b/pyup/providers/github.py index 9520b46..8d61147 100644 --- a/pyup/providers/github.py +++ b/pyup/providers/github.py @@ -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__) @@ -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( @@ -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, From f75b5d0f47bf37f9bc787d9c15e76cc92542bda0 Mon Sep 17 00:00:00 2001 From: Bruno Alla Date: Tue, 19 Mar 2019 12:28:11 +0000 Subject: [PATCH 2/2] Add a test case for checking quoted characters --- tests/test_github.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tests/test_github.py b/tests/test_github.py index c2ef596..e575424 100644 --- a/tests/test_github.py +++ b/tests/test_github.py @@ -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), @@ -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) @@ -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()