File tree 3 files changed +18
-1
lines changed
3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change
1
+ import os
1
2
import subprocess
2
3
from typing import NamedTuple
3
4
@@ -28,6 +29,8 @@ def _try_decode(bytes_: bytes) -> str:
28
29
29
30
30
31
def run (cmd : str , env = None ) -> Command :
32
+ if env is not None :
33
+ env = {** os .environ , ** env }
31
34
process = subprocess .Popen (
32
35
cmd ,
33
36
shell = True ,
Original file line number Diff line number Diff line change @@ -175,7 +175,9 @@ def get_tags(
175
175
f'%(object)"'
176
176
)
177
177
extra = "--merged" if reachable_only else ""
178
- c = cmd .run (f"git tag --format={ formatter } --sort=-creatordate { extra } " )
178
+ # Force the default language for parsing
179
+ env = {"LC_ALL" : "C" , "LANG" : "C" , "LANGUAGE" : "C" }
180
+ c = cmd .run (f"git tag --format={ formatter } --sort=-creatordate { extra } " , env = env )
179
181
if c .return_code != 0 :
180
182
if reachable_only and c .err == "fatal: malformed object name HEAD\n " :
181
183
# this can happen if there are no commits in the repo yet
Original file line number Diff line number Diff line change @@ -71,6 +71,18 @@ def test_get_reachable_tags(tmp_commitizen_project):
71
71
assert tag_names == {"1.0.0" , "1.0.1" }
72
72
73
73
74
+ @pytest .mark .parametrize ("locale" , ["en_US" , "fr_FR" ])
75
+ def test_get_reachable_tags_with_commits (
76
+ tmp_commitizen_project , locale : str , monkeypatch : pytest .MonkeyPatch
77
+ ):
78
+ monkeypatch .setenv ("LANG" , f"{ locale } .UTF-8" )
79
+ monkeypatch .setenv ("LANGUAGE" , f"{ locale } .UTF-8" )
80
+ monkeypatch .setenv ("LC_ALL" , f"{ locale } .UTF-8" )
81
+ with tmp_commitizen_project .as_cwd ():
82
+ tags = git .get_tags (reachable_only = True )
83
+ assert tags == []
84
+
85
+
74
86
def test_get_tag_names (mocker : MockFixture ):
75
87
tag_str = "v1.0.0\n " "v0.5.0\n " "v0.0.1\n "
76
88
mocker .patch ("commitizen.cmd.run" , return_value = FakeCommand (out = tag_str ))
You can’t perform that action at this time.
0 commit comments