[git] Remove usage of recipe_util.format_ex

This function was a shim to ensure consistency between Python 2 and 3.
It's no longer necessary now that recipes don't support Python 2
anymore, and is being deleted in crrev.com/c/6133284.

Also update two tests to be less sensitive to the exact format of the
summary markdown produced when an exception occurs, since some single
quotes are now changed to double quotes.

Change-Id: Ia8a7bd9be5f03302049f6798c51b8e4e8bdc9784
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/6142074
Reviewed-by: Gavin Mak <gavinmak@google.com>
Auto-Submit: Oliver Newman <olivernewman@google.com>
Commit-Queue: Oliver Newman <olivernewman@google.com>
changes/74/6142074/4
Oliver Newman 6 months ago committed by LUCI CQ
parent 58625e82c6
commit 44a8a8d49a

@ -432,13 +432,13 @@ Returns:
[DEPS](/recipes/recipe_modules/git/__init__.py#3): [depot\_tools](#recipe_modules-depot_tools), [recipe\_engine/buildbucket][recipe_engine/recipe_modules/buildbucket], [recipe\_engine/context][recipe_engine/recipe_modules/context], [recipe\_engine/path][recipe_engine/recipe_modules/path], [recipe\_engine/platform][recipe_engine/recipe_modules/platform], [recipe\_engine/properties][recipe_engine/recipe_modules/properties], [recipe\_engine/raw\_io][recipe_engine/recipe_modules/raw_io], [recipe\_engine/runtime][recipe_engine/recipe_modules/runtime], [recipe\_engine/step][recipe_engine/recipe_modules/step]
#### **class [GitApi](/recipes/recipe_modules/git/api.py#11)([RecipeApi][recipe_engine/wkt/RecipeApi]):**
#### **class [GitApi](/recipes/recipe_modules/git/api.py#10)([RecipeApi][recipe_engine/wkt/RecipeApi]):**
&mdash; **def [\_\_call\_\_](/recipes/recipe_modules/git/api.py#14)(self, \*args, \*\*kwargs):**
&mdash; **def [\_\_call\_\_](/recipes/recipe_modules/git/api.py#13)(self, \*args, \*\*kwargs):**
Returns a git command step.
&mdash; **def [bundle\_create](/recipes/recipe_modules/git/api.py#391)(self, bundle_path, rev_list_args=None, \*\*kwargs):**
&mdash; **def [bundle\_create](/recipes/recipe_modules/git/api.py#390)(self, bundle_path, rev_list_args=None, \*\*kwargs):**
Runs 'git bundle create' on a Git repository.
@ -448,11 +448,11 @@ Args:
refs in the Git checkout will be bundled.
* kwargs: Forwarded to '__call__'.
&mdash; **def [cat\_file\_at\_commit](/recipes/recipe_modules/git/api.py#34)(self, file_path, commit_hash, remote_name=None, \*\*kwargs):**
&mdash; **def [cat\_file\_at\_commit](/recipes/recipe_modules/git/api.py#33)(self, file_path, commit_hash, remote_name=None, \*\*kwargs):**
Outputs the contents of a file at a given revision.
&mdash; **def [checkout](/recipes/recipe_modules/git/api.py#107)(self, url, ref=None, dir_path=None, recursive=False, submodules=True, submodule_update_force=False, keep_paths=None, step_suffix=None, curl_trace_file=None, raise_on_failure=True, set_got_revision=False, remote_name=None, display_fetch_size=None, file_name=None, submodule_update_recursive=True, use_git_cache=False, progress=True, tags=False, depth=None):**
&mdash; **def [checkout](/recipes/recipe_modules/git/api.py#106)(self, url, ref=None, dir_path=None, recursive=False, submodules=True, submodule_update_force=False, keep_paths=None, step_suffix=None, curl_trace_file=None, raise_on_failure=True, set_got_revision=False, remote_name=None, display_fetch_size=None, file_name=None, submodule_update_recursive=True, use_git_cache=False, progress=True, tags=False, depth=None):**
Performs a full git checkout and returns sha1 of checked out revision.
@ -493,7 +493,7 @@ Args:
Returns: If the checkout was successful, this returns the commit hash of
the checked-out-repo. Otherwise this returns None.
&mdash; **def [config\_get](/recipes/recipe_modules/git/api.py#360)(self, prop_name, \*\*kwargs):**
&mdash; **def [config\_get](/recipes/recipe_modules/git/api.py#359)(self, prop_name, \*\*kwargs):**
Returns git config output.
@ -503,7 +503,7 @@ Args:
Returns: (str) The Git config output, or None if no output was generated.
&mdash; **def [count\_objects](/recipes/recipe_modules/git/api.py#42)(self, previous_result=None, raise_on_failure=False, \*\*kwargs):**
&mdash; **def [count\_objects](/recipes/recipe_modules/git/api.py#41)(self, previous_result=None, raise_on_failure=False, \*\*kwargs):**
Returns `git count-objects` result as a dict.
@ -516,11 +516,11 @@ Args:
Returns:
A dict of count-object values, or None if count-object run failed.
&mdash; **def [fetch\_tags](/recipes/recipe_modules/git/api.py#28)(self, remote_name=None, \*\*kwargs):**
&mdash; **def [fetch\_tags](/recipes/recipe_modules/git/api.py#27)(self, remote_name=None, \*\*kwargs):**
Fetches all tags from the remote.
&mdash; **def [get\_remote\_url](/recipes/recipe_modules/git/api.py#379)(self, remote_name=None, \*\*kwargs):**
&mdash; **def [get\_remote\_url](/recipes/recipe_modules/git/api.py#378)(self, remote_name=None, \*\*kwargs):**
Returns the remote Git repository URL, or None.
@ -530,11 +530,11 @@ Args:
Returns: (str) The URL of the remote Git repository, or None.
&mdash; **def [get\_timestamp](/recipes/recipe_modules/git/api.py#331)(self, commit='HEAD', test_data=None, \*\*kwargs):**
&mdash; **def [get\_timestamp](/recipes/recipe_modules/git/api.py#330)(self, commit='HEAD', test_data=None, \*\*kwargs):**
Find and return the timestamp of the given commit.
&mdash; **def [ls\_remote](/recipes/recipe_modules/git/api.py#472)(self, url, ref, name=None, \*\*kwargs):**
&mdash; **def [ls\_remote](/recipes/recipe_modules/git/api.py#471)(self, url, ref, name=None, \*\*kwargs):**
Request the head revision for a given ref using ls-remote. Raise a
StepFailure if the ref does not exist, or more than one ref was found.
@ -546,7 +546,7 @@ Args:
Returns: A git revision.
&mdash; **def [new\_branch](/recipes/recipe_modules/git/api.py#404)(self, branch, name=None, upstream=None, upstream_current=False, \*\*kwargs):**
&mdash; **def [new\_branch](/recipes/recipe_modules/git/api.py#403)(self, branch, name=None, upstream=None, upstream_current=False, \*\*kwargs):**
Runs git new-branch on a Git repository, to be used before git cl
upload.
@ -558,7 +558,7 @@ Args:
* upstream_current (bool): whether to use '--upstream_current'.
* kwargs: Forwarded to '__call__'.
&mdash; **def [number](/recipes/recipe_modules/git/api.py#435)(self, commitrefs=None, test_values=None):**
&mdash; **def [number](/recipes/recipe_modules/git/api.py#434)(self, commitrefs=None, test_values=None):**
Computes the generation number of some commits.
@ -575,7 +575,7 @@ A list of strings containing the generation numbers of the commits.
If non-empty commitrefs was provided, the order of the returned
numbers will correspond to the order of the provided commitrefs.
&mdash; **def [rebase](/recipes/recipe_modules/git/api.py#340)(self, name_prefix, branch, dir_path, remote_name=None, \*\*kwargs):**
&mdash; **def [rebase](/recipes/recipe_modules/git/api.py#339)(self, name_prefix, branch, dir_path, remote_name=None, \*\*kwargs):**
Runs rebase HEAD onto branch

@ -3,7 +3,7 @@
# found in the LICENSE file.
from recipe_engine.post_process import (DropExpectation, StatusSuccess,
SummaryMarkdown)
SummaryMarkdownRE)
PYTHON_VERSION_COMPATIBILITY = 'PY3'
@ -69,9 +69,8 @@ def GenTests(api):
),
api.expect_exception('DepsDiffException'),
api.post_process(
SummaryMarkdown,
"Uncaught Exception: DepsDiffException('Unexpected result: autoroll "
"diff found 0 files changed')"),
SummaryMarkdownRE,
"Unexpected result: autoroll diff found 0 files changed"),
api.post_process(DropExpectation),
status="INFRA_FAILURE")
@ -85,9 +84,8 @@ def GenTests(api):
),
api.expect_exception('DepsDiffException'),
api.post_process(
SummaryMarkdown,
"Uncaught Exception: DepsDiffException('Couldn't checkout previous "
"ref: fatal: bad object abcdef1234567890')"),
SummaryMarkdownRE,
"Couldn't checkout previous ref: fatal: bad object abcdef1234567890"),
api.post_process(DropExpectation),
status="INFRA_FAILURE")

@ -6,7 +6,6 @@ import itertools
import re
from recipe_engine import recipe_api
from recipe_engine import util as recipe_util
class GitApi(recipe_api.RecipeApi):
_GIT_HASH_RE = re.compile('[0-9a-f]{40}', re.IGNORECASE)
@ -98,7 +97,7 @@ class GitApi(recipe_api.RecipeApi):
return result
except Exception as ex:
if step_result:
step_result.presentation.logs['exception'] = recipe_util.format_ex(ex)
step_result.presentation.logs['exception'] = repr(ex)
step_result.presentation.status = self.m.step.WARNING
if raise_on_failure:
raise recipe_api.InfraFailure('count-objects failed: %s' % ex)

@ -97,7 +97,7 @@
"infra_step": true,
"name": "count-objects",
"~followup_annotations": [
"@@@STEP_LOG_LINE@exception@ValueError('invalid literal for int() with base 10: 'xxx'')@@@",
"@@@STEP_LOG_LINE@exception@ValueError(\"invalid literal for int() with base 10: 'xxx'\")@@@",
"@@@STEP_LOG_END@exception@@@",
"@@@STEP_WARNINGS@@@"
]

@ -97,7 +97,7 @@
"infra_step": true,
"name": "count-objects",
"~followup_annotations": [
"@@@STEP_LOG_LINE@exception@ValueError('invalid literal for int() with base 10: 'xxx'')@@@",
"@@@STEP_LOG_LINE@exception@ValueError(\"invalid literal for int() with base 10: 'xxx'\")@@@",
"@@@STEP_LOG_END@exception@@@",
"@@@STEP_WARNINGS@@@"
]

@ -197,7 +197,7 @@
" File \"RECIPE_REPO[depot_tools]/recipes/recipe_modules/git/examples/full.py\", line 82, in RunSteps",
" api.git.new_branch('failed_new_branch', upstream='will_fail', upstream_current=True) #pylint: disable = line-too-long",
" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^",
" File \"RECIPE_REPO[depot_tools]/recipes/recipe_modules/git/api.py\", line 421, in new_branch",
" File \"RECIPE_REPO[depot_tools]/recipes/recipe_modules/git/api.py\", line 420, in new_branch",
" raise ValueError('Can not define both upstream and upstream_current')",
"ValueError: Can not define both upstream and upstream_current"
]

Loading…
Cancel
Save