From 67964c5de15b16bfca48876fc954212a6b9677b4 Mon Sep 17 00:00:00 2001 From: Ales Raszka Date: Feb 02 2016 09:17:06 +0000 Subject: Lookaside: encoding repo name to UTF-8 Pycurl can't handle unicode string as argument on RHEL7. String must be encoded to UTF-8. Resolves: bz#1241059 Signed-off-by: Ales Raszka --- diff --git a/src/pyrpkg/__init__.py b/src/pyrpkg/__init__.py index b9f16be..b95ecb2 100644 --- a/src/pyrpkg/__init__.py +++ b/src/pyrpkg/__init__.py @@ -387,7 +387,6 @@ class Commands(object): def load_push_url(self): """Find the pushurl or url of remote of branch we're on.""" - try: url = self.repo.git.config('--get', 'remote.%s.pushurl' % self.branch_remote) @@ -397,7 +396,11 @@ class Commands(object): % self.branch_remote) except git.GitCommandError as e: raise rpkgError('Unable to find remote push url: %s' % e) - self._push_url = url + if isinstance(url, unicode): + # GitPython >= 1.0 return unicode. It must be encoded to string. + self._push_url = url.encode('utf-8') + else: + self._push_url = url @property def commithash(self): diff --git a/test/commands/test_package_name.py b/test/commands/test_package_name.py new file mode 100644 index 0000000..c17653f --- /dev/null +++ b/test/commands/test_package_name.py @@ -0,0 +1,24 @@ +import os + +from . import CommandTestCase + + +class CommandPackageNameTestCase(CommandTestCase): + def test_name_is_not_unicode(self): + self.make_new_git(self.module) + + import pyrpkg + cmd = pyrpkg.Commands(self.path, self.lookaside, self.lookasidehash, + self.lookaside_cgi, self.gitbaseurl, + self.anongiturl, self.branchre, self.kojiconfig, + self.build_client, self.user, self.dist, + self.target, self.quiet) + cmd.clone(self.module, anon=True) + + moduledir = os.path.join(self.path, self.module) + cmd.path = moduledir + + # pycurl can't handle unicode variable + # module_name needs to be string + self.assertNotEquals(type(cmd.module_name), unicode) + self.assertEquals(type(cmd.module_name), str)