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