Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(20)

Side by Side Diff: testing_support/git/repo.py

Issue 1306033009: Don't clobber the PATH environment variable when running git commit. (Closed) Base URL: https://chromium.googlesource.com/infra/testing/testing_support.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright 2014 The Chromium Authors. All rights reserved. 1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import atexit 5 import atexit
6 import collections 6 import collections
7 import datetime 7 import datetime
8 import os 8 import os
9 import shutil 9 import shutil
10 import subprocess 10 import subprocess
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 if commit.parents: 100 if commit.parents:
101 parents = list(commit.parents) 101 parents = list(commit.parents)
102 self.git('checkout', '--detach', '-q', self[parents[0]]) 102 self.git('checkout', '--detach', '-q', self[parents[0]])
103 if len(parents) > 1: 103 if len(parents) > 1:
104 self.git('merge', '--no-commit', '-q', *[self[x] for x in parents[1:]]) 104 self.git('merge', '--no-commit', '-q', *[self[x] for x in parents[1:]])
105 else: 105 else:
106 self.git('checkout', '--orphan', 'root_%s' % commit.name) 106 self.git('checkout', '--orphan', 'root_%s' % commit.name)
107 self.git('rm', '-rf', '.') 107 self.git('rm', '-rf', '.')
108 108
109 env = self.get_git_commit_env(commit_data) 109 env = os.environ.copy()
110 env.update(self.get_git_commit_env(commit_data))
110 111
111 for fname, file_data in commit_data.iteritems(): 112 for fname, file_data in commit_data.iteritems():
112 deleted = False 113 deleted = False
113 if 'data' in file_data: 114 if 'data' in file_data:
114 data = file_data.get('data') 115 data = file_data.get('data')
115 if data is None: 116 if data is None:
116 deleted = True 117 deleted = True
117 self.git('rm', fname) 118 self.git('rm', fname)
118 else: 119 else:
119 path = os.path.join(self.repo_path, fname) 120 path = os.path.join(self.repo_path, fname)
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
160 assert self.repo_path is not None 161 assert self.repo_path is not None
161 try: 162 try:
162 with open(os.devnull, 'wb') as devnull: 163 with open(os.devnull, 'wb') as devnull:
163 output = subprocess.check_output( 164 output = subprocess.check_output(
164 ('git',) + args, cwd=self.repo_path, stderr=devnull, **kwargs) 165 ('git',) + args, cwd=self.repo_path, stderr=devnull, **kwargs)
165 return self.COMMAND_OUTPUT(0, output) 166 return self.COMMAND_OUTPUT(0, output)
166 except subprocess.CalledProcessError as e: 167 except subprocess.CalledProcessError as e:
167 return self.COMMAND_OUTPUT(e.returncode, e.output) 168 return self.COMMAND_OUTPUT(e.returncode, e.output)
168 169
169 def git_commit(self, message): 170 def git_commit(self, message):
170 return self.git('commit', '-am', message, env=self.get_git_commit_env()) 171 env = os.environ.copy()
172 env.update(self.get_git_commit_env())
173 return self.git('commit', '-am', message, env=env)
171 174
172 def nuke(self): 175 def nuke(self):
173 """Obliterates the git repo on disk. 176 """Obliterates the git repo on disk.
174 177
175 Causes this GitRepo to be unusable. 178 Causes this GitRepo to be unusable.
176 """ 179 """
177 shutil.rmtree(self.repo_path) 180 shutil.rmtree(self.repo_path)
178 self.repo_path = None 181 self.repo_path = None
179 182
180 def run(self, fn, *args, **kwargs): 183 def run(self, fn, *args, **kwargs):
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
232 else: 235 else:
233 assert current is not None 236 assert current is not None
234 hash_to_msg[current] = line 237 hash_to_msg[current] = line
235 ret.add_partial(line) 238 ret.add_partial(line)
236 for parent in parents: 239 for parent in parents:
237 ret.add_partial(line, hash_to_msg[parent]) 240 ret.add_partial(line, hash_to_msg[parent])
238 current = None 241 current = None
239 parents = [] 242 parents = []
240 assert current is None 243 assert current is None
241 return ret 244 return ret
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698