| 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 re | 5 import re |
| 6 | 6 |
| 7 from slave import recipe_api | 7 from recipe_engine import recipe_api |
| 8 | 8 |
| 9 | 9 |
| 10 class CommitPositionApi(recipe_api.RecipeApi): | 10 class CommitPositionApi(recipe_api.RecipeApi): |
| 11 """Recipe module providing commit position parsing and manipulation.""" | 11 """Recipe module providing commit position parsing and manipulation.""" |
| 12 RE_COMMIT_POSITION = re.compile('(?P<branch>.+)@{#(?P<revision>\d+)}') | 12 RE_COMMIT_POSITION = re.compile('(?P<branch>.+)@{#(?P<revision>\d+)}') |
| 13 COMMIT_POS_STR = 'Cr-Commit-Position: refs/heads/master@{#%d}' | 13 COMMIT_POS_STR = 'Cr-Commit-Position: refs/heads/master@{#%d}' |
| 14 | 14 |
| 15 @classmethod | 15 @classmethod |
| 16 def parse(cls, value): | 16 def parse(cls, value): |
| 17 match = cls.RE_COMMIT_POSITION.match(value) | 17 match = cls.RE_COMMIT_POSITION.match(value) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 stdout=self.m.raw_io.output(), | 70 stdout=self.m.raw_io.output(), |
| 71 name='resolving hash ' + sha) | 71 name='resolving hash ' + sha) |
| 72 try: | 72 try: |
| 73 result = int(self.parse_revision(str(step_result.stdout))) | 73 result = int(self.parse_revision(str(step_result.stdout))) |
| 74 except ValueError: | 74 except ValueError: |
| 75 raise self.m.step.StepFailure( | 75 raise self.m.step.StepFailure( |
| 76 'Could not parse commit position from git output: ' + | 76 'Could not parse commit position from git output: ' + |
| 77 (step_result.stdout or '')) | 77 (step_result.stdout or '')) |
| 78 return result | 78 return result |
| 79 | 79 |
| OLD | NEW |