From 983aceeb9c03a02dd22d7ab5cb14246a1d4813dc Mon Sep 17 00:00:00 2001
From: Chenxiong Qi <cqi@redhat.com>
Date: Thu, 17 Aug 2017 12:35:44 +0800
Subject: [PATCH] Fix encoding in new command
In previous commit, new_diff returned from GitPython API is unicode
string and has to be encoded in encoding UTF-8. That works well with
GitPython>=1.0, but not with version GitPython<1.0 which returns string
in basestring type. This failure case happens in EL6 with
0.3.2-0.6.RC1.el6.
Signed-off-by: Chenxiong Qi <cqi@redhat.com>
---
pyrpkg/cli.py | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/pyrpkg/cli.py b/pyrpkg/cli.py
index ac6c841..69cc931 100644
--- a/pyrpkg/cli.py
+++ b/pyrpkg/cli.py
@@ -23,6 +23,7 @@ import time
import koji
import pyrpkg.utils as utils
+import six
from pyrpkg import rpkgError, log as rpkgLogger
from six.moves import xmlrpc_client, configparser
@@ -1315,7 +1316,12 @@ see API KEY section of copr-cli(1) man page.
def new(self):
new_diff = self.cmd.new()
- print(new_diff.encode('utf-8'))
+ # When running rpkg with old version GitPython<1.0 which returns string
+ # in type basestring, no need to encode.
+ if isinstance(new_diff, six.string_types):
+ print(new_diff)
+ else:
+ print(new_diff.encode('utf-8'))
def new_sources(self):
# Check to see if the files passed exist
--
2.9.4