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

Implemented Per-Call Environment Variables#645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 6 commits intogitpython-developers:masterfromAJMansfield:master
Sep 28, 2017
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionsAUTHORS
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -19,6 +19,7 @@ Contributors are:
-Timothy B. Hartman <tbhartman _at_ gmail.com>
-Konstantin Popov <konstantin.popov.89 _at_ yandex.ru>
-Peter Jones <pjones _at_ redhat.com>
-Anson Mansfield <anson.mansfield _at_ gmail.com>
-Ken Odegard <ken.odegard _at_ gmail.com>
-Alexis Horgix Chotard

Expand Down
9 changes: 8 additions & 1 deletiongit/cmd.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -47,7 +47,7 @@
execute_kwargs = set(('istream', 'with_extended_output',
'with_exceptions', 'as_process', 'stdout_as_string',
'output_stream', 'with_stdout', 'kill_after_timeout',
'universal_newlines', 'shell'))
'universal_newlines', 'shell', 'env'))

log = logging.getLogger(__name__)
log.addHandler(logging.NullHandler())
Expand DownExpand Up@@ -597,6 +597,7 @@ def execute(self, command,
with_stdout=True,
universal_newlines=False,
shell=None,
env=None,
**subprocess_kwargs
):
"""Handles executing the command on the shell and consumes and returns
Expand DownExpand Up@@ -640,6 +641,9 @@ def execute(self, command,
decoded into a string using the default encoding (usually utf-8).
The latter can fail, if the output contains binary data.

:param env:
A dictionary of environment variables to be passed to `subprocess.Popen`.

:param subprocess_kwargs:
Keyword arguments to be passed to subprocess.Popen. Please note that
some of the valid kwargs are already set by this method, the ones you
Expand DownExpand Up@@ -685,6 +689,7 @@ def execute(self, command,
cwd = self._working_dir or os.getcwd()

# Start the process
inline_env = env
env = os.environ.copy()
# Attempt to force all output to plain ascii english, which is what some parsing code
# may expect.
Expand All@@ -693,6 +698,8 @@ def execute(self, command,
env["LANGUAGE"] = "C"
env["LC_ALL"] = "C"
env.update(self._environment)
if inline_env is not None:
env.update(inline_env)

if is_win:
cmd_not_found_exception = OSError
Expand Down
View file
Open in desktop
Empty file.
15 changes: 15 additions & 0 deletionsgit/test/test_git.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -106,6 +106,21 @@ def test_it_ignores_false_kwargs(self, git):
self.git.version(pass_this_kwarg=False)
assert_true("pass_this_kwarg" not in git.call_args[1])

def test_it_accepts_environment_variables(self):
filename = fixture_path("ls_tree_empty")
with open(filename, 'r') as fh:
tree = self.git.mktree(istream=fh)
env = {
'GIT_AUTHOR_NAME': 'Author Name',
'GIT_AUTHOR_EMAIL': 'author@example.com',
'GIT_AUTHOR_DATE': '1400000000+0000',
'GIT_COMMITTER_NAME': 'Committer Name',
'GIT_COMMITTER_EMAIL': 'committer@example.com',
'GIT_COMMITTER_DATE': '1500000000+0000',
}
commit = self.git.commit_tree(tree, m='message', env=env)
assert_equal(commit, '4cfd6b0314682d5a58f80be39850bad1640e9241')

def test_persistent_cat_file_command(self):
# read header only
import subprocess as sp
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp