aboutsummaryrefslogtreecommitdiffstats
path: root/git_deps
diff options
context:
space:
mode:
authorAdam Spiers <git@adamspiers.org>2018-05-16 16:12:34 +0100
committerAdam Spiers <git@adamspiers.org>2018-05-16 16:25:24 +0100
commit2446d4a6061b65c498b4ad78b507e640553f08f8 (patch)
tree798d4341f2361fa3eeef47f8187ff812d9e5bba7 /git_deps
parent09bd07f2b86fd14008791cbf0543d533cc7aa57d (diff)
downloadgit-deps-2446d4a6061b65c498b4ad78b507e640553f08f8.tar.gz
fix Python 3 uses of subprocess.check_output
https://stackoverflow.com/questions/15817420/subprocess-and-type-str-doesnt-support-the-buffer-api/15817457#15817457
Diffstat (limited to 'git_deps')
-rw-r--r--git_deps/detector.py4
-rw-r--r--git_deps/gitutils.py8
-rw-r--r--git_deps/listener/cli.py2
3 files changed, 8 insertions, 6 deletions
diff --git a/git_deps/detector.py b/git_deps/detector.py
index 3111a38..df5b001 100644
--- a/git_deps/detector.py
+++ b/git_deps/detector.py
@@ -169,7 +169,7 @@ class DependencyDetector(object):
'-L', "%d,+%d" % (hunk.old_start, hunk.old_lines),
parent.hex, '--', path
]
- blame = subprocess.check_output(cmd)
+ blame = subprocess.check_output(cmd, universal_newlines=True)
dependent_sha1 = dependent.hex
if dependent_sha1 not in self.dependencies:
@@ -288,7 +288,7 @@ class DependencyDetector(object):
cmd = ['git', 'merge-base', sha1, branch_sha1]
# self.logger.debug(" ".join(cmd))
- out = subprocess.check_output(cmd).strip()
+ out = subprocess.check_output(cmd, universal_newlines=True).strip()
self.logger.debug(" merge-base returned: %s" % out[:8])
result = out == sha1
self.logger.debug(" %s" % result)
diff --git a/git_deps/gitutils.py b/git_deps/gitutils.py
index f7b5470..f699551 100644
--- a/git_deps/gitutils.py
+++ b/git_deps/gitutils.py
@@ -15,7 +15,7 @@ class GitUtils(object):
# we will be able to do this via pygit2.
cmd = ['git', 'rev-parse', '--short', sha1]
# cls.logger.debug(" ".join(cmd))
- out = subprocess.check_output(cmd).strip()
+ out = subprocess.check_output(cmd, universal_newlines=True).strip()
# cls.logger.debug(out)
return out
@@ -39,7 +39,8 @@ class GitUtils(object):
# cls.logger.debug(" ".join(cmd))
out = None
try:
- out = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
+ out = subprocess.check_output(
+ cmd, stderr=subprocess.STDOUT, universal_newlines=True)
except subprocess.CalledProcessError as e:
if e.output.find('No tags can describe') != -1:
return ''
@@ -77,7 +78,8 @@ class GitUtils(object):
@classmethod
def rev_list(cls, rev_range):
cmd = ['git', 'rev-list', rev_range]
- return subprocess.check_output(cmd).strip().split('\n')
+ return subprocess.check_output(cmd, universal_newlines=True) \
+ .strip().split('\n')
@classmethod
def ref_commit(cls, repo, rev):
diff --git a/git_deps/listener/cli.py b/git_deps/listener/cli.py
index 285c622..01bf4df 100644
--- a/git_deps/listener/cli.py
+++ b/git_deps/listener/cli.py
@@ -46,7 +46,7 @@ class CLIDependencyListener(DependencyListener):
'log', '-n1',
dependency_sha1
]
- print(subprocess.check_output(cmd))
+ print(subprocess.check_output(cmd, universal_newlines=True))
# dependency = detector.get_commit(dependency_sha1)
# print(dependency.message + "\n")