summaryrefslogtreecommitdiffhomepage
path: root/gbp
diff options
context:
space:
mode:
authorGuido Günther <agx@sigxcpu.org>2015-06-12 08:43:25 +0200
committerGuido Günther <agx@sigxcpu.org>2015-06-12 08:43:25 +0200
commit6a5675cba7ca41aa0e56df245a1d56f66115bd27 (patch)
tree8210b063b18efdb93cf307074531fbed67a40eb8 /gbp
parent21eaad96e9445a015e579f3f4b280b7f7fd95987 (diff)
GitRepository: Use C locale when building error messages
If we use stderr to build the error message we need to use the C locale when invoking git commands since otherwise we might end up with non ascii characters. Leading to errors like: gbp:debug: ['git', 'describe', '--match', 'upstream/*', '--abbrev=0', u'99b4406e2c43ed1e011239e07f2f809dad4803c0'] Traceback (most recent call last): File "/usr/bin/gbp", line 9, in <module> load_entry_point('gbp==0.6.31', 'console_scripts', 'gbp')() File "/usr/lib/python2.7/dist-packages/gbp/scripts/supercommand.py", line 136, in supercommand return module.main(args) File "/usr/lib/python2.7/dist-packages/gbp/scripts/dch.py", line 480, in main options.upstream_branch, cp) File "/usr/lib/python2.7/dist-packages/gbp/scripts/dch.py", line 48, in guess_version_from_upstream epoch=cp.epoch) File "/usr/lib/python2.7/dist-packages/gbp/deb/git.py", line 83, in debian_version_from_upstream tag = self.find_branch_tag(commit, upstream_branch, pattern=pattern) File "/usr/lib/python2.7/dist-packages/gbp/git/repository.py", line 729, in find_branch_tag return self.describe(base_commit, pattern, abbrev=0) File "/usr/lib/python2.7/dist-packages/gbp/git/repository.py", line 700, in describe (commitish, err.strip())) UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 19: ordinal not in range(128)
Diffstat (limited to 'gbp')
-rw-r--r--gbp/git/repository.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/gbp/git/repository.py b/gbp/git/repository.py
index 8adaa612..a9613af7 100644
--- a/gbp/git/repository.py
+++ b/gbp/git/repository.py
@@ -420,7 +420,10 @@ class GitRepository(object):
args = GitArgs()
args.add(commit1)
args.add(commit2)
- sha1, stderr, ret = self._git_inout('merge-base', args.args, capture_stderr=True)
+ sha1, stderr, ret = self._git_inout('merge-base',
+ args.args,
+ extra_env={'LC_ALL': 'C'},
+ capture_stderr=True)
if not ret:
return self.strip_sha1(sha1).decode('utf-8')
else:
@@ -577,6 +580,7 @@ class GitRepository(object):
dummy, err, ret = self._git_inout('branch',
args,
+ extra_env={'LC_ALL': 'C'},
capture_stderr=True)
if ret:
raise GitRepositoryError(
@@ -694,10 +698,11 @@ class GitRepository(object):
args.add(commitish)
tag, err, ret = self._git_inout('describe', args.args,
+ extra_env={'LC_ALL': 'C'},
capture_stderr=True)
if ret:
- raise GitRepositoryError("Can't describe %s. Git error: %s" % \
- (commitish, err.strip()))
+ raise GitRepositoryError("Can't describe %s. Git error: %s" %
+ (commitish, err.strip()))
return tag.strip()
def find_tag(self, commit, pattern=None):