Chromium Code Reviews| Index: recipe_modules/gclient/api.py |
| diff --git a/recipe_modules/gclient/api.py b/recipe_modules/gclient/api.py |
| index 6b44dab1d2bce72726b22b6552ef11de1abea020..f858b0231c33a28660779d5a9d621890ec1c3798 100644 |
| --- a/recipe_modules/gclient/api.py |
| +++ b/recipe_modules/gclient/api.py |
| @@ -376,3 +376,23 @@ class GclientApi(recipe_api.RecipeApi): |
| path, revision = cfg.patch_projects.get(patch_project, (None, None)) |
| if path and revision and path not in cfg.revisions: |
| cfg.revisions[path] = revision |
| + |
| + def get_files_affected_by_patch(self, patch_project, gclient_config=None): |
| + """Returns list of paths to files affected by the patch.""" |
| + patch_root = self.calculate_patch_root(patch_project, gclient_config) |
|
Michael Achenbach
2016/04/29 14:11:53
Maybe patch_root should be a parameter to this met
tandrii(chromium)
2016/04/29 15:09:41
Good idea. Will do that.
|
| + step_result = self.m.git('diff', '--cached', '--name-only', |
| + cwd=self.m.path['root'].join(patch_root), |
| + name='git diff to analyze patch', |
| + stdout=self.m.raw_io.output(), |
| + step_test_data=lambda: |
| + self.m.raw_io.test_api.stream_output('foo.cc')) |
| + paths = step_result.stdout.split() |
| + if patch_root: |
| + paths = [self.m.path.join(patch_root, path) for path in paths] |
| + if self.m.platform.is_win: |
| + # Looks like "analyze" wants POSIX slashes even on Windows (since git |
| + # uses that format even on Windows). |
| + paths = [path.replace('\\', '/') for path in paths] |
| + |
| + step_result.presentation.logs['files'] = paths |
| + return paths |