Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8df6b87

Browse files
author
Darragh Bailey
committed
Copy environment for subprocess execution
Git utilizes multiple environment variables to control variousbehaviours. Make sure to set LC_MESSAGES on a copy of the environmentinstead of discarding any variables that may be set by the user ordefault shell environment such as EDITOR.Add test to assert that when overriding GIT_EDITOR via os.environ thatthe modified value will be picked up by and git commands called.
1 parent2af9892 commit8df6b87

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

‎git/cmd.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,10 @@ def execute(self, command,
341341
cwd=self._working_dir
342342

343343
# Start the process
344+
env=os.environ.copy()
345+
env["LC_MESSAGES"]="C"
344346
proc=Popen(command,
345-
env={"LC_MESSAGES":"C"},
347+
env=env,
346348
cwd=cwd,
347349
stdin=istream,
348350
stderr=PIPE,

‎git/test/test_git.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# the BSD License: http://www.opensource.org/licenses/bsd-license.php
66

77
importos
8+
importmock
89
fromgit.test.libimport (TestBase,
910
patch,
1011
raises,
@@ -128,3 +129,8 @@ def test_single_char_git_options_are_passed_to_git(self):
128129

129130
deftest_change_to_transform_kwargs_does_not_break_command_options(self):
130131
self.git.log(n=1)
132+
133+
deftest_env_vars_passed_to_git(self):
134+
editor='non_existant_editor'
135+
withmock.patch.dict('os.environ', {'GIT_EDITOR':editor}):
136+
assertself.git.var("GIT_EDITOR")==editor

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp