File tree Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Expand file tree Collapse file tree 3 files changed +18
-1
lines changed Original file line number Diff line number Diff line change 1+ import os
12import subprocess
23from typing import NamedTuple
34
@@ -28,6 +29,8 @@ def _try_decode(bytes_: bytes) -> str:
2829
2930
3031def run (cmd : str , env = None ) -> Command :
32+ if env is not None :
33+ env = {** os .environ , ** env }
3134 process = subprocess .Popen (
3235 cmd ,
3336 shell = True ,
Original file line number Diff line number Diff line change @@ -175,7 +175,9 @@ def get_tags(
175175 f'%(object)"'
176176 )
177177 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 )
179181 if c .return_code != 0 :
180182 if reachable_only and c .err == "fatal: malformed object name HEAD\n " :
181183 # 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):
7171 assert tag_names == {"1.0.0" , "1.0.1" }
7272
7373
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+
7486def test_get_tag_names (mocker : MockFixture ):
7587 tag_str = "v1.0.0\n " "v0.5.0\n " "v0.0.1\n "
7688 mocker .patch ("commitizen.cmd.run" , return_value = FakeCommand (out = tag_str ))
You can’t perform that action at this time.
0 commit comments