| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 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 itertools |
| 5 import re | 6 import re |
| 6 | 7 |
| 7 from recipe_engine import recipe_api | 8 from recipe_engine import recipe_api |
| 8 | 9 |
| 9 class GitApi(recipe_api.RecipeApi): | 10 class GitApi(recipe_api.RecipeApi): |
| 10 _GIT_HASH_RE = re.compile('[0-9a-f]{40}', re.IGNORECASE) | 11 _GIT_HASH_RE = re.compile('[0-9a-f]{40}', re.IGNORECASE) |
| 11 | 12 |
| 12 def __call__(self, *args, **kwargs): | 13 def __call__(self, *args, **kwargs): |
| 13 """Return a git command step.""" | 14 """Return a git command step.""" |
| 14 name = kwargs.pop('name', 'git '+args[0]) | 15 name = kwargs.pop('name', 'git '+args[0]) |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 249 rev_parse_step = self('rev-parse', 'HEAD', | 250 rev_parse_step = self('rev-parse', 'HEAD', |
| 250 cwd=dir_path, | 251 cwd=dir_path, |
| 251 name='set got_revision', | 252 name='set got_revision', |
| 252 stdout=self.m.raw_io.output(), | 253 stdout=self.m.raw_io.output(), |
| 253 can_fail_build=False) | 254 can_fail_build=False) |
| 254 | 255 |
| 255 if rev_parse_step.presentation.status == 'SUCCESS': | 256 if rev_parse_step.presentation.status == 'SUCCESS': |
| 256 sha = rev_parse_step.stdout.strip() | 257 sha = rev_parse_step.stdout.strip() |
| 257 rev_parse_step.presentation.properties['got_revision'] = sha | 258 rev_parse_step.presentation.properties['got_revision'] = sha |
| 258 | 259 |
| 259 clean_args = list(self.m.itertools.chain( | 260 clean_args = list(itertools.chain( |
| 260 *[('-e', path) for path in keep_paths or []])) | 261 *[('-e', path) for path in keep_paths or []])) |
| 261 | 262 |
| 262 self('clean', '-f', '-d', '-x', *clean_args, | 263 self('clean', '-f', '-d', '-x', *clean_args, |
| 263 name='git clean%s' % step_suffix, | 264 name='git clean%s' % step_suffix, |
| 264 cwd=dir_path, | 265 cwd=dir_path, |
| 265 can_fail_build=can_fail_build) | 266 can_fail_build=can_fail_build) |
| 266 | 267 |
| 267 if submodules: | 268 if submodules: |
| 268 self('submodule', 'sync', | 269 self('submodule', 'sync', |
| 269 name='submodule sync%s' % step_suffix, | 270 name='submodule sync%s' % step_suffix, |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 338 | 339 |
| 339 Args: | 340 Args: |
| 340 bundle_path (Path): The path of the output bundle. | 341 bundle_path (Path): The path of the output bundle. |
| 341 refs (list): The list of refs to include in the bundle. If None, all | 342 refs (list): The list of refs to include in the bundle. If None, all |
| 342 refs in the Git checkout will be bundled. | 343 refs in the Git checkout will be bundled. |
| 343 kwargs: Forwarded to '__call__'. | 344 kwargs: Forwarded to '__call__'. |
| 344 """ | 345 """ |
| 345 if not rev_list_args: | 346 if not rev_list_args: |
| 346 rev_list_args = ['--all'] | 347 rev_list_args = ['--all'] |
| 347 self('bundle', 'create', bundle_path, *rev_list_args, **kwargs) | 348 self('bundle', 'create', bundle_path, *rev_list_args, **kwargs) |
| OLD | NEW |