Commit 8f09549f authored by Yuanjun Huang's avatar Yuanjun Huang Committed by LUCI CQ

[python3] Solve soft errors in the recipes of git module

These soft errors will become hard failures and block the proto module
to be marked PY2+3 in upstream recipe engine repo.


Bug: 1227140
Change-Id: I0e5fdebe7e7cf43552b525d63c12f82c96c49902
Recipe-Nontrivial-Roll: build_limited
Recipe-Nontrivial-Roll: chrome_release
Recipe-Nontrivial-Roll: infra
Recipe-Nontrivial-Roll: build
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/3152784
Commit-Queue: Yuanjun Huang <yuanjunh@google.com>
Reviewed-by: 's avatarYiwei Zhang <yiwzhang@google.com>
Reviewed-by: 's avatarGavin Mak <gavinmak@google.com>
parent 0969961c
......@@ -360,13 +360,13 @@ Returns:
PYTHON_VERSION_COMPATIBILITY: PY2+3
#### **class [GitApi](/recipes/recipe_modules/git/api.py#18)([RecipeApi][recipe_engine/wkt/RecipeApi]):**
#### **class [GitApi](/recipes/recipe_modules/git/api.py#19)([RecipeApi][recipe_engine/wkt/RecipeApi]):**
&mdash; **def [\_\_call\_\_](/recipes/recipe_modules/git/api.py#21)(self, \*args, \*\*kwargs):**
&mdash; **def [\_\_call\_\_](/recipes/recipe_modules/git/api.py#22)(self, \*args, \*\*kwargs):**
Returns a git command step.
&mdash; **def [bundle\_create](/recipes/recipe_modules/git/api.py#389)(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.
......@@ -376,11 +376,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#48)(self, file_path, commit_hash, remote_name=None, \*\*kwargs):**
&mdash; **def [cat\_file\_at\_commit](/recipes/recipe_modules/git/api.py#49)(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#122)(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, can_fail_build=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):**
&mdash; **def [checkout](/recipes/recipe_modules/git/api.py#123)(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, can_fail_build=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):**
Performs a full git checkout and returns sha1 of checked out revision.
......@@ -419,7 +419,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#358)(self, prop_name, \*\*kwargs):**
&mdash; **def [config\_get](/recipes/recipe_modules/git/api.py#359)(self, prop_name, \*\*kwargs):**
Returns git config output.
......@@ -429,7 +429,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#56)(self, previous_result=None, can_fail_build=False, \*\*kwargs):**
&mdash; **def [count\_objects](/recipes/recipe_modules/git/api.py#57)(self, previous_result=None, can_fail_build=False, \*\*kwargs):**
Returns `git count-objects` result as a dict.
......@@ -442,11 +442,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#42)(self, remote_name=None, \*\*kwargs):**
&mdash; **def [fetch\_tags](/recipes/recipe_modules/git/api.py#43)(self, remote_name=None, \*\*kwargs):**
Fetches all tags from the remote.
&mdash; **def [get\_remote\_url](/recipes/recipe_modules/git/api.py#377)(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.
......@@ -456,11 +456,11 @@ Args:
Returns: (str) The URL of the remote Git repository, or None.
&mdash; **def [get\_timestamp](/recipes/recipe_modules/git/api.py#329)(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 [new\_branch](/recipes/recipe_modules/git/api.py#402)(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.
......@@ -472,7 +472,7 @@ Args:
* upstream_current (bool): whether to use '--upstream_current'.
* kwargs: Forwarded to '__call__'.
&mdash; **def [rebase](/recipes/recipe_modules/git/api.py#338)(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
......
......@@ -70,7 +70,7 @@ class BotUpdateApi(recipe_api.RecipeApi):
raise self.m.step.InfraFailure(
'invalid (host, project) pair in '
'buildbucket.build.input.gitiles_commit: '
'(%r, %r) does not match any of configured gclient solutions '
'(%s, %s) does not match any of configured gclient solutions '
'and not present in gclient_config.repo_path_map' % (
commit.host, commit.project))
......
[
{
"failure": {
"humanReason": "invalid (host, project) pair in buildbucket.build.input.gitiles_commit: (u'unrecognized', u'repo') does not match any of configured gclient solutions and not present in gclient_config.repo_path_map"
"humanReason": "invalid (host, project) pair in buildbucket.build.input.gitiles_commit: (unrecognized, repo) does not match any of configured gclient solutions and not present in gclient_config.repo_path_map"
},
"name": "$result"
}
......
......@@ -14,6 +14,7 @@ except NameError: # pragma: no cover
_INTEGER_TYPES = (int,)
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)
......@@ -88,7 +89,7 @@ class GitApi(recipe_api.RecipeApi):
result[name] = int(value.strip())
def results_to_text(results):
return [' %s: %s' % (k, v) for k, v in results.items()]
return [' %s: %s' % (k, v) for k, v in sorted(results.items())]
step_result.presentation.logs['result'] = results_to_text(result)
......@@ -113,7 +114,7 @@ class GitApi(recipe_api.RecipeApi):
return result
except Exception as ex:
if step_result:
step_result.presentation.logs['exception'] = ['%r' % ex]
step_result.presentation.logs['exception'] = recipe_util.format_ex(ex)
step_result.presentation.status = self.m.step.WARNING
if can_fail_build:
raise recipe_api.InfraFailure('count-objects failed: %s' % ex)
......@@ -292,13 +293,13 @@ class GitApi(recipe_api.RecipeApi):
rev_parse_step = self('rev-parse', 'HEAD',
name='read revision',
stdout=self.m.raw_io.output(),
stdout=self.m.raw_io.output_text(),
can_fail_build=False,
step_test_data=lambda:
self.m.raw_io.test_api.stream_output('deadbeef'))
self.m.raw_io.test_api.stream_output_text('deadbeef'))
if rev_parse_step.presentation.status == 'SUCCESS':
sha = rev_parse_step.stdout.strip().decode('utf-8')
sha = rev_parse_step.stdout.strip()
retVal = sha
rev_parse_step.presentation.step_text = "<br/>checked out %r<br/>" % sha
if set_got_revision:
......
......@@ -48,7 +48,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -48,7 +48,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -50,7 +50,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -47,7 +47,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -48,7 +48,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -48,7 +48,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -49,7 +49,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -48,7 +48,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -48,7 +48,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -48,7 +48,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -23,12 +23,12 @@
"~followup_annotations": [
"@@@STEP_LOG_LINE@result@ count: 1000@@@",
"@@@STEP_LOG_LINE@result@ garbage: 1000@@@",
"@@@STEP_LOG_LINE@result@ packs: 1000@@@",
"@@@STEP_LOG_LINE@result@ in_pack: 1000@@@",
"@@@STEP_LOG_LINE@result@ size-pack: 1000@@@",
"@@@STEP_LOG_LINE@result@ size-garbage: 1000@@@",
"@@@STEP_LOG_LINE@result@ packs: 1000@@@",
"@@@STEP_LOG_LINE@result@ prune-packable: 1000@@@",
"@@@STEP_LOG_LINE@result@ size: 1000@@@",
"@@@STEP_LOG_LINE@result@ size-garbage: 1000@@@",
"@@@STEP_LOG_LINE@result@ size-pack: 1000@@@",
"@@@STEP_LOG_END@result@@@"
]
},
......@@ -61,42 +61,42 @@
"@@@STEP_TEXT@size delta: +1.95 MiB@@@",
"@@@STEP_LOG_LINE@result@ count: 2000@@@",
"@@@STEP_LOG_LINE@result@ garbage: 2000@@@",
"@@@STEP_LOG_LINE@result@ packs: 2000@@@",
"@@@STEP_LOG_LINE@result@ in_pack: 2000@@@",
"@@@STEP_LOG_LINE@result@ size-pack: 2000@@@",
"@@@STEP_LOG_LINE@result@ size-garbage: 2000@@@",
"@@@STEP_LOG_LINE@result@ packs: 2000@@@",
"@@@STEP_LOG_LINE@result@ prune-packable: 2000@@@",
"@@@STEP_LOG_LINE@result@ size: 2000@@@",
"@@@STEP_LOG_LINE@result@ size-garbage: 2000@@@",
"@@@STEP_LOG_LINE@result@ size-pack: 2000@@@",
"@@@STEP_LOG_END@result@@@",
"@@@STEP_LOG_LINE@delta@before:@@@",
"@@@STEP_LOG_LINE@delta@ count: 1000@@@",
"@@@STEP_LOG_LINE@delta@ garbage: 1000@@@",
"@@@STEP_LOG_LINE@delta@ packs: 1000@@@",
"@@@STEP_LOG_LINE@delta@ in_pack: 1000@@@",
"@@@STEP_LOG_LINE@delta@ size-pack: 1000@@@",
"@@@STEP_LOG_LINE@delta@ size-garbage: 1000@@@",
"@@@STEP_LOG_LINE@delta@ packs: 1000@@@",
"@@@STEP_LOG_LINE@delta@ prune-packable: 1000@@@",
"@@@STEP_LOG_LINE@delta@ size: 1000@@@",
"@@@STEP_LOG_LINE@delta@ size-garbage: 1000@@@",
"@@@STEP_LOG_LINE@delta@ size-pack: 1000@@@",
"@@@STEP_LOG_LINE@delta@@@@",
"@@@STEP_LOG_LINE@delta@after:@@@",
"@@@STEP_LOG_LINE@delta@ count: 2000@@@",
"@@@STEP_LOG_LINE@delta@ garbage: 2000@@@",
"@@@STEP_LOG_LINE@delta@ packs: 2000@@@",
"@@@STEP_LOG_LINE@delta@ in_pack: 2000@@@",
"@@@STEP_LOG_LINE@delta@ size-pack: 2000@@@",
"@@@STEP_LOG_LINE@delta@ size-garbage: 2000@@@",
"@@@STEP_LOG_LINE@delta@ packs: 2000@@@",
"@@@STEP_LOG_LINE@delta@ prune-packable: 2000@@@",
"@@@STEP_LOG_LINE@delta@ size: 2000@@@",
"@@@STEP_LOG_LINE@delta@ size-garbage: 2000@@@",
"@@@STEP_LOG_LINE@delta@ size-pack: 2000@@@",
"@@@STEP_LOG_LINE@delta@@@@",
"@@@STEP_LOG_LINE@delta@delta:@@@",
"@@@STEP_LOG_LINE@delta@ count: 1000@@@",
"@@@STEP_LOG_LINE@delta@ garbage: 1000@@@",
"@@@STEP_LOG_LINE@delta@ in_pack: 1000@@@",
"@@@STEP_LOG_LINE@delta@ packs: 1000@@@",
"@@@STEP_LOG_LINE@delta@ prune-packable: 1000@@@",
"@@@STEP_LOG_LINE@delta@ size-pack: 1000@@@",
"@@@STEP_LOG_LINE@delta@ size-garbage: 1000@@@",
"@@@STEP_LOG_LINE@delta@ in_pack: 1000@@@",
"@@@STEP_LOG_LINE@delta@ size: 1000@@@",
"@@@STEP_LOG_LINE@delta@ size-garbage: 1000@@@",
"@@@STEP_LOG_LINE@delta@ size-pack: 1000@@@",
"@@@STEP_LOG_END@delta@@@"
]
},
......@@ -121,7 +121,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -48,7 +48,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -48,7 +48,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......@@ -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@@@"
]
......
......@@ -48,7 +48,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......@@ -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@@@"
]
......
......@@ -49,7 +49,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -96,7 +96,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -48,7 +48,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......@@ -182,9 +182,9 @@
"The recipe has crashed at point 'Uncaught exception'!",
"",
"Traceback (most recent call last):",
" File \"RECIPE_REPO[depot_tools]/recipes/recipe_modules/git/examples/full.py\", line 85, in RunSteps",
" upstream_current=True)",
" File \"RECIPE_REPO[depot_tools]/recipes/recipe_modules/git/api.py\", line 419, in new_branch",
" File \"RECIPE_REPO[depot_tools]/recipes/recipe_modules/git/examples/full.py\", line 83, 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 420, in new_branch",
" raise ValueError('Can not define both upstream and upstream_current')",
"ValueError: Can not define both upstream and upstream_current"
]
......
......@@ -48,7 +48,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -48,7 +48,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -50,7 +50,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@"
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@"
]
},
{
......
......@@ -48,7 +48,7 @@
"infra_step": true,
"name": "read revision",
"~followup_annotations": [
"@@@STEP_TEXT@<br/>checked out u'deadbeef'<br/>@@@",
"@@@STEP_TEXT@<br/>checked out 'deadbeef'<br/>@@@",
"@@@SET_BUILD_PROPERTY@got_revision@\"deadbeef\"@@@"
]
},
......
......@@ -80,9 +80,7 @@ def RunSteps(api):
api.git.new_branch('refactor') # Upstream is origin/main by default.
if api.properties.get('set_both_upstream_and_upstream_current'):
api.git.new_branch('failed_new_branch',
upstream='will_fail',
upstream_current=True)
api.git.new_branch('failed_new_branch', upstream='will_fail', upstream_current=True) #pylint: disable = line-too-long
# And use upstream kwarg to set up different upstream for tracking.
api.git.new_branch('feature', upstream='refactor')
# A new branching tracking the current branch, which is 'feature'.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment