OLD | NEW |
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 contextlib | 5 import contextlib |
6 import hashlib | 6 import hashlib |
7 | 7 |
8 from recipe_engine import recipe_api | 8 from recipe_engine import recipe_api |
9 | 9 |
10 | 10 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 patch_content = self.m.raw_io.input(result.raw_io.output) | 93 patch_content = self.m.raw_io.input(result.raw_io.output) |
94 self._apply_patch_step(patch_content=patch_content, root=root) | 94 self._apply_patch_step(patch_content=patch_content, root=root) |
95 | 95 |
96 def apply_from_git(self, cwd): | 96 def apply_from_git(self, cwd): |
97 """Downloads patch from given git repo and ref and applies it""" | 97 """Downloads patch from given git repo and ref and applies it""" |
98 # TODO(nodir): accept these properties as parameters | 98 # TODO(nodir): accept these properties as parameters |
99 patch_repo_url = self.m.properties['patch_repo_url'] | 99 patch_repo_url = self.m.properties['patch_repo_url'] |
100 patch_ref = self.m.properties['patch_ref'] | 100 patch_ref = self.m.properties['patch_ref'] |
101 | 101 |
102 patch_dir = self.m.path.mkdtemp('patch') | 102 patch_dir = self.m.path.mkdtemp('patch') |
103 git_setup_py = self.m.infra_paths['build'].join( | 103 git_setup_py = self.m.path['build'].join('scripts', 'slave', 'git_setup.py') |
104 'scripts', 'slave', 'git_setup.py') | |
105 git_setup_args = ['--path', patch_dir, '--url', patch_repo_url] | 104 git_setup_args = ['--path', patch_dir, '--url', patch_repo_url] |
106 patch_path = patch_dir.join('patch.diff') | 105 patch_path = patch_dir.join('patch.diff') |
107 | 106 |
108 self.m.python('patch git setup', git_setup_py, git_setup_args) | 107 self.m.python('patch git setup', git_setup_py, git_setup_args) |
109 self.m.git('fetch', 'origin', patch_ref, | 108 self.m.git('fetch', 'origin', patch_ref, |
110 name='patch fetch', cwd=patch_dir) | 109 name='patch fetch', cwd=patch_dir) |
111 self.m.git('clean', '-f', '-d', '-x', | 110 self.m.git('clean', '-f', '-d', '-x', |
112 name='patch clean', cwd=patch_dir) | 111 name='patch clean', cwd=patch_dir) |
113 self.m.git('checkout', '-f', 'FETCH_HEAD', | 112 self.m.git('checkout', '-f', 'FETCH_HEAD', |
114 name='patch git checkout', cwd=patch_dir) | 113 name='patch git checkout', cwd=patch_dir) |
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 self.add_failure_reason(e.reason) | 238 self.add_failure_reason(e.reason) |
240 | 239 |
241 failure_hash = hashlib.sha1() | 240 failure_hash = hashlib.sha1() |
242 failure_hash.update(self.m.json.dumps(self._failure_reasons)) | 241 failure_hash.update(self.m.json.dumps(self._failure_reasons)) |
243 | 242 |
244 step_result = self.m.step.active_result | 243 step_result = self.m.step.active_result |
245 step_result.presentation.properties['failure_hash'] = \ | 244 step_result.presentation.properties['failure_hash'] = \ |
246 failure_hash.hexdigest() | 245 failure_hash.hexdigest() |
247 | 246 |
248 raise | 247 raise |
OLD | NEW |