diff options
author | 2022-09-18 19:50:52 +0300 | |
---|---|---|
committer | 2022-09-18 19:50:52 +0300 | |
commit | 8dc2399540bc8b1300f3658eebadffd2e09fcd15 (patch) | |
tree | 1d4cfdcd6894dc5adbc1ae9ef3f13dd998026e88 | |
parent | docs: cleanup and fix warnings (diff) | |
download | snakeoil-8dc2399540bc8b1300f3658eebadffd2e09fcd15.tar.gz snakeoil-8dc2399540bc8b1300f3658eebadffd2e09fcd15.tar.bz2 snakeoil-8dc2399540bc8b1300f3658eebadffd2e09fcd15.zip |
version: better locale protection around running git
Bug: https://bugs.gentoo.org/869878
Signed-off-by: Arthur Zamarin <arthurzam@gentoo.org>
-rw-r--r-- | src/snakeoil/version.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/snakeoil/version.py b/src/snakeoil/version.py index c2aa3bb..6eea337 100644 --- a/src/snakeoil/version.py +++ b/src/snakeoil/version.py @@ -56,7 +56,11 @@ def get_version(project, repo_file, api_version=None): def _run_git(path, cmd): env = dict(os.environ) + for key in env: + if key.startswith("LC_"): + del env[key] env["LC_CTYPE"] = "C" + env["LC_ALL"] = "C" r = subprocess.Popen( ['git'] + list(cmd), stdout=subprocess.PIPE, env=env, @@ -84,7 +88,7 @@ def get_git_version(path): commits = None if ret == 0: prev_tag = stdout.decode().strip() - stdout, ret = _run_git( + stgbdout, ret = _run_git( path, ['log', '--oneline', f'{prev_tag}..HEAD']) if ret == 0: commits = len(stdout.decode().splitlines()) |