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