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 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
252 rev_parse_step = self('rev-parse', 'HEAD', | 253 rev_parse_step = self('rev-parse', 'HEAD', |
253 cwd=dir_path, | 254 cwd=dir_path, |
254 name='set got_revision', | 255 name='set got_revision', |
255 stdout=self.m.raw_io.output(), | 256 stdout=self.m.raw_io.output(), |
256 can_fail_build=False) | 257 can_fail_build=False) |
257 | 258 |
258 if rev_parse_step.presentation.status == 'SUCCESS': | 259 if rev_parse_step.presentation.status == 'SUCCESS': |
259 sha = rev_parse_step.stdout.strip() | 260 sha = rev_parse_step.stdout.strip() |
260 rev_parse_step.presentation.properties['got_revision'] = sha | 261 rev_parse_step.presentation.properties['got_revision'] = sha |
261 | 262 |
262 clean_args = list(self.m.itertools.chain( | 263 clean_args = list(itertools.chain( |
263 *[('-e', path) for path in keep_paths or []])) | 264 *[('-e', path) for path in keep_paths or []])) |
264 | 265 |
265 self('clean', '-f', '-d', '-x', *clean_args, | 266 self('clean', '-f', '-d', '-x', *clean_args, |
266 name='git clean%s' % step_suffix, | 267 name='git clean%s' % step_suffix, |
267 cwd=dir_path, | 268 cwd=dir_path, |
268 can_fail_build=can_fail_build) | 269 can_fail_build=can_fail_build) |
269 | 270 |
270 if submodules: | 271 if submodules: |
271 self('submodule', 'sync', | 272 self('submodule', 'sync', |
272 name='submodule sync%s' % step_suffix, | 273 name='submodule sync%s' % step_suffix, |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 | 342 |
342 Args: | 343 Args: |
343 bundle_path (Path): The path of the output bundle. | 344 bundle_path (Path): The path of the output bundle. |
344 refs (list): The list of refs to include in the bundle. If None, all | 345 refs (list): The list of refs to include in the bundle. If None, all |
345 refs in the Git checkout will be bundled. | 346 refs in the Git checkout will be bundled. |
346 kwargs: Forwarded to '__call__'. | 347 kwargs: Forwarded to '__call__'. |
347 """ | 348 """ |
348 if not rev_list_args: | 349 if not rev_list_args: |
349 rev_list_args = ['--all'] | 350 rev_list_args = ['--all'] |
350 self('bundle', 'create', bundle_path, *rev_list_args, **kwargs) | 351 self('bundle', 'create', bundle_path, *rev_list_args, **kwargs) |
OLD | NEW |