allura-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From brond...@apache.org
Subject [allura] 08/16: [#8375] git py3 fixes
Date Thu, 27 Aug 2020 20:35:33 GMT
This is an automated email from the ASF dual-hosted git repository.

brondsem pushed a commit to branch db/8375
in repository https://gitbox.apache.org/repos/asf/allura.git

commit e5226472b1e0200df3b2e5ac4a9f1b502ebe64f1
Author: Dave Brondsema <dave@brondsema.net>
AuthorDate: Tue Aug 25 17:00:17 2020 -0400

    [#8375] git py3 fixes
---
 Allura/allura/controllers/repository.py                | 13 +++++++------
 ForgeGit/forgegit/model/git_repo.py                    |  4 ++--
 ForgeGit/forgegit/tests/functional/test_controllers.py |  4 ++--
 ForgeGit/forgegit/tests/model/test_repository.py       |  2 +-
 4 files changed, 12 insertions(+), 11 deletions(-)

diff --git a/Allura/allura/controllers/repository.py b/Allura/allura/controllers/repository.py
index 4959af7..3104e07 100644
--- a/Allura/allura/controllers/repository.py
+++ b/Allura/allura/controllers/repository.py
@@ -797,7 +797,7 @@ class TreeBrowser(BaseController, DispatchIndex):
         next = h.really_unicode(unquote(next))
         if not rest:
             # Might be a file rather than a dir
-            filename = h.really_unicode(request.environ['PATH_INFO'].rsplit(str('/'))[-1])
+            filename = h.really_unicode(request.path_info.rsplit(str('/'))[-1])
             if filename:
                 try:
                     obj = self._tree[filename]
@@ -809,7 +809,7 @@ class TreeBrowser(BaseController, DispatchIndex):
                         self._tree,
                         filename), rest
         elif rest == ('index', ):
-            rest = (request.environ['PATH_INFO'].rsplit(str('/'))[-1],)
+            rest = (request.path_info.rsplit(str('/'))[-1],)
         try:
             tree = self._tree[next]
         except KeyError:
@@ -899,10 +899,11 @@ class FileBrowser(BaseController):
             diff = "Cannot display: file marked as a binary type."
             return dict(a=a, b=b, diff=diff)
 
-        la = list(a)
-        lb = list(b)
-        adesc = ('a' + h.really_unicode(apath)).encode('utf-8')
-        bdesc = ('b' + h.really_unicode(b.path())).encode('utf-8')
+        # could consider making Blob.__iter__ do unicode conversion?
+        la = [h.really_unicode(line) for line in a]
+        lb = [h.really_unicode(line) for line in b]
+        adesc = 'a' + h.really_unicode(apath)
+        bdesc = 'b' + h.really_unicode(b.path())
 
         if not fmt:
             fmt = web_session.get('diformat', '')
diff --git a/ForgeGit/forgegit/model/git_repo.py b/ForgeGit/forgegit/model/git_repo.py
index 11638f3..7c5827b 100644
--- a/ForgeGit/forgegit/model/git_repo.py
+++ b/ForgeGit/forgegit/model/git_repo.py
@@ -353,7 +353,7 @@ class GitImplementation(M.RepositoryImplementation):
         If id_only is True, returns only the commit ID, otherwise it returns
         detailed information about each commit.
         """
-        path = path.strip('/').encode("utf-8") if path else None
+        path = path.strip('/') if path else None
         if exclude is not None:
             revs.extend(['^%s' % e for e in exclude])
         args = ['--follow', '--name-status', revs, '--', path or '.']
@@ -634,7 +634,7 @@ class GitImplementation(M.RepositoryImplementation):
         skip = 0
         while commit_id and not files:
             output = self._git.git.log(
-                commit_id, '--', *[p.encode('utf-8') for p in paths],
+                commit_id, '--', *[p for p in paths],
                 pretty='format:%H',
                 name_only=True,
                 max_count=1,
diff --git a/ForgeGit/forgegit/tests/functional/test_controllers.py b/ForgeGit/forgegit/tests/functional/test_controllers.py
index c5050c7..f65a823 100644
--- a/ForgeGit/forgegit/tests/functional/test_controllers.py
+++ b/ForgeGit/forgegit/tests/functional/test_controllers.py
@@ -302,13 +302,13 @@ class TestRootController(_TestCase):
         url = ci + 'tree/' + h.urlquote('with%2Furlquote-literal.txt') + '?format=raw'
         resp = self.app.get(url)
         assert_in('%2F means /', resp.body.decode('utf-8'))
-        assert_equal(resp.headers.get('Content-Disposition').decode('utf-8'),
+        assert_equal(resp.headers.get('Content-Disposition'),
                      'attachment;filename="with%252Furlquote-literal.txt"')
 
         url = ci + 'tree/' + h.urlquote('with"&:specials.txt') + '?format=raw'
         resp = self.app.get(url)
         assert_in('"&: encodes as %22%26%3A', resp.body.decode('utf-8'))
-        assert_equal(resp.headers.get('Content-Disposition').decode('utf-8'),
+        assert_equal(resp.headers.get('Content-Disposition'),
                      'attachment;filename="with%22%26%3Aspecials.txt"')
 
     def test_invalid_file(self):
diff --git a/ForgeGit/forgegit/tests/model/test_repository.py b/ForgeGit/forgegit/tests/model/test_repository.py
index 30672f3..39b055c 100644
--- a/ForgeGit/forgegit/tests/model/test_repository.py
+++ b/ForgeGit/forgegit/tests/model/test_repository.py
@@ -748,7 +748,7 @@ By Dave Brondsema''', text_body)
         tmp_repo.git.checkout.assert_called_once_with('target-branch')
         assert_equal(
             tmp_repo.git.config.call_args_list,
-            [mock.call('user.name', 'Test Admin'),
+            [mock.call('user.name', b'Test Admin'),
              mock.call('user.email', 'allura@localhost')])
         msg = 'Merge downstream-repo-url branch source-branch into target-branch'
         msg += '\n\nhttp://localhost/merge-request/1/'


Mime
View raw message