mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Fix flake8 warnings for some files
Change-Id: If67f8660cfb0479f0e710b3566285ef401fcf077 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/355969 Tested-by: Sergiy Belozorov <sergiyb@chromium.org> Reviewed-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
parent
37ae75f27d
commit
78e82ec78e
@ -320,7 +320,8 @@ class Command(object):
|
|||||||
for arg in args:
|
for arg in args:
|
||||||
# We have to filter by manifest groups in case the requested project is
|
# We have to filter by manifest groups in case the requested project is
|
||||||
# checked out multiple times or differently based on them.
|
# checked out multiple times or differently based on them.
|
||||||
projects = [project for project in manifest.GetProjectsWithName(
|
projects = [project
|
||||||
|
for project in manifest.GetProjectsWithName(
|
||||||
arg, all_manifests=all_manifests)
|
arg, all_manifests=all_manifests)
|
||||||
if project.MatchesGroups(groups)]
|
if project.MatchesGroups(groups)]
|
||||||
|
|
||||||
|
@ -159,12 +159,12 @@ def git_require(min_version, fail=False, msg=''):
|
|||||||
|
|
||||||
|
|
||||||
def _build_env(
|
def _build_env(
|
||||||
_kwargs_only=(),
|
_kwargs_only=(),
|
||||||
bare: Optional[bool] = False,
|
bare: Optional[bool] = False,
|
||||||
disable_editor: Optional[bool] = False,
|
disable_editor: Optional[bool] = False,
|
||||||
ssh_proxy: Optional[Any] = None,
|
ssh_proxy: Optional[Any] = None,
|
||||||
gitdir: Optional[str] = None,
|
gitdir: Optional[str] = None,
|
||||||
objdir: Optional[str] = None
|
objdir: Optional[str] = None
|
||||||
):
|
):
|
||||||
"""Constucts an env dict for command execution."""
|
"""Constucts an env dict for command execution."""
|
||||||
|
|
||||||
@ -194,8 +194,7 @@ def _build_env(
|
|||||||
env['GIT_OBJECT_DIRECTORY'] = objdir
|
env['GIT_OBJECT_DIRECTORY'] = objdir
|
||||||
|
|
||||||
alt_objects = os.path.join(gitdir, 'objects') if gitdir else None
|
alt_objects = os.path.join(gitdir, 'objects') if gitdir else None
|
||||||
if (alt_objects and
|
if alt_objects and os.path.realpath(alt_objects) != os.path.realpath(objdir):
|
||||||
os.path.realpath(alt_objects) != os.path.realpath(objdir)):
|
|
||||||
# Allow git to search the original place in case of local or unique refs
|
# Allow git to search the original place in case of local or unique refs
|
||||||
# that git will attempt to resolve even if we aren't fetching them.
|
# that git will attempt to resolve even if we aren't fetching them.
|
||||||
env['GIT_ALTERNATE_OBJECT_DIRECTORIES'] = alt_objects
|
env['GIT_ALTERNATE_OBJECT_DIRECTORIES'] = alt_objects
|
||||||
@ -236,11 +235,11 @@ class GitCommand(object):
|
|||||||
gitdir = gitdir.replace('\\', '/')
|
gitdir = gitdir.replace('\\', '/')
|
||||||
|
|
||||||
env = _build_env(
|
env = _build_env(
|
||||||
disable_editor=disable_editor,
|
disable_editor=disable_editor,
|
||||||
ssh_proxy=ssh_proxy,
|
ssh_proxy=ssh_proxy,
|
||||||
objdir=objdir,
|
objdir=objdir,
|
||||||
gitdir=gitdir,
|
gitdir=gitdir,
|
||||||
bare=bare,
|
bare=bare,
|
||||||
)
|
)
|
||||||
|
|
||||||
command = [GIT]
|
command = [GIT]
|
||||||
@ -279,7 +278,8 @@ class GitCommand(object):
|
|||||||
if 'GIT_OBJECT_DIRECTORY' in env:
|
if 'GIT_OBJECT_DIRECTORY' in env:
|
||||||
dbg += ': export GIT_OBJECT_DIRECTORY=%s\n' % env['GIT_OBJECT_DIRECTORY']
|
dbg += ': export GIT_OBJECT_DIRECTORY=%s\n' % env['GIT_OBJECT_DIRECTORY']
|
||||||
if 'GIT_ALTERNATE_OBJECT_DIRECTORIES' in env:
|
if 'GIT_ALTERNATE_OBJECT_DIRECTORIES' in env:
|
||||||
dbg += ': export GIT_ALTERNATE_OBJECT_DIRECTORIES=%s\n' % env['GIT_ALTERNATE_OBJECT_DIRECTORIES']
|
dbg += ': export GIT_ALTERNATE_OBJECT_DIRECTORIES=%s\n' % (
|
||||||
|
env['GIT_ALTERNATE_OBJECT_DIRECTORIES'])
|
||||||
|
|
||||||
dbg += ': '
|
dbg += ': '
|
||||||
dbg += ' '.join(command)
|
dbg += ' '.join(command)
|
||||||
@ -295,13 +295,13 @@ class GitCommand(object):
|
|||||||
with Trace('git command %s %s with debug: %s', LAST_GITDIR, command, dbg):
|
with Trace('git command %s %s with debug: %s', LAST_GITDIR, command, dbg):
|
||||||
try:
|
try:
|
||||||
p = subprocess.Popen(command,
|
p = subprocess.Popen(command,
|
||||||
cwd=cwd,
|
cwd=cwd,
|
||||||
env=env,
|
env=env,
|
||||||
encoding='utf-8',
|
encoding='utf-8',
|
||||||
errors='backslashreplace',
|
errors='backslashreplace',
|
||||||
stdin=stdin,
|
stdin=stdin,
|
||||||
stdout=stdout,
|
stdout=stdout,
|
||||||
stderr=stderr)
|
stderr=stderr)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise GitError('%s: %s' % (command[1], e))
|
raise GitError('%s: %s' % (command[1], e))
|
||||||
|
|
||||||
|
@ -188,7 +188,7 @@ class GitConfig(object):
|
|||||||
if v in ('false', 'no'):
|
if v in ('false', 'no'):
|
||||||
return False
|
return False
|
||||||
print(f"warning: expected {name} to represent a boolean, got {v} instead",
|
print(f"warning: expected {name} to represent a boolean, got {v} instead",
|
||||||
file=sys.stderr)
|
file=sys.stderr)
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def SetBoolean(self, name, value):
|
def SetBoolean(self, name, value):
|
||||||
@ -197,7 +197,7 @@ class GitConfig(object):
|
|||||||
value = 'true' if value else 'false'
|
value = 'true' if value else 'false'
|
||||||
self.SetString(name, value)
|
self.SetString(name, value)
|
||||||
|
|
||||||
def GetString(self, name: str, all_keys: bool = False) -> Union[str, None]:
|
def GetString(self, name: str, all_keys: bool = False) -> Union[str, None]:
|
||||||
"""Get the first value for a key, or None if it is not defined.
|
"""Get the first value for a key, or None if it is not defined.
|
||||||
|
|
||||||
This configuration file is used first, if the key is not
|
This configuration file is used first, if the key is not
|
||||||
|
@ -54,6 +54,7 @@ class SyncNetworkHalfResult(NamedTuple):
|
|||||||
# commit already present.
|
# commit already present.
|
||||||
remote_fetched: bool
|
remote_fetched: bool
|
||||||
|
|
||||||
|
|
||||||
# Maximum sleep time allowed during retries.
|
# Maximum sleep time allowed during retries.
|
||||||
MAXIMUM_RETRY_SLEEP_SEC = 3600.0
|
MAXIMUM_RETRY_SLEEP_SEC = 3600.0
|
||||||
# +-10% random jitter is added to each Fetches retry sleep duration.
|
# +-10% random jitter is added to each Fetches retry sleep duration.
|
||||||
@ -63,6 +64,7 @@ RETRY_JITTER_PERCENT = 0.1
|
|||||||
# TODO(vapier): Remove knob once behavior is verified.
|
# TODO(vapier): Remove knob once behavior is verified.
|
||||||
_ALTERNATES = os.environ.get('REPO_USE_ALTERNATES') == '1'
|
_ALTERNATES = os.environ.get('REPO_USE_ALTERNATES') == '1'
|
||||||
|
|
||||||
|
|
||||||
def _lwrite(path, content):
|
def _lwrite(path, content):
|
||||||
lock = '%s.lock' % path
|
lock = '%s.lock' % path
|
||||||
|
|
||||||
@ -3415,6 +3417,7 @@ class RepoProject(MetaProject):
|
|||||||
except OSError:
|
except OSError:
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
|
|
||||||
class ManifestProject(MetaProject):
|
class ManifestProject(MetaProject):
|
||||||
"""The MetaProject for manifests."""
|
"""The MetaProject for manifests."""
|
||||||
|
|
||||||
@ -3845,11 +3848,12 @@ class ManifestProject(MetaProject):
|
|||||||
self.config.SetBoolean('repo.superproject', use_superproject)
|
self.config.SetBoolean('repo.superproject', use_superproject)
|
||||||
|
|
||||||
if not standalone_manifest:
|
if not standalone_manifest:
|
||||||
if not self.Sync_NetworkHalf(
|
success = self.Sync_NetworkHalf(
|
||||||
is_new=is_new, quiet=not verbose, verbose=verbose,
|
is_new=is_new, quiet=not verbose, verbose=verbose,
|
||||||
clone_bundle=clone_bundle, current_branch_only=current_branch_only,
|
clone_bundle=clone_bundle, current_branch_only=current_branch_only,
|
||||||
tags=tags, submodules=submodules, clone_filter=clone_filter,
|
tags=tags, submodules=submodules, clone_filter=clone_filter,
|
||||||
partial_clone_exclude=self.manifest.PartialCloneExclude).success:
|
partial_clone_exclude=self.manifest.PartialCloneExclude).success
|
||||||
|
if not success:
|
||||||
r = self.GetRemote()
|
r = self.GetRemote()
|
||||||
print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr)
|
print('fatal: cannot obtain manifest %s' % r.url, file=sys.stderr)
|
||||||
|
|
||||||
|
@ -615,9 +615,8 @@ Gerrit Code Review: https://www.gerritcodereview.com/
|
|||||||
hook = RepoHook.FromSubcmd(
|
hook = RepoHook.FromSubcmd(
|
||||||
hook_type='pre-upload', manifest=manifest,
|
hook_type='pre-upload', manifest=manifest,
|
||||||
opt=opt, abort_if_user_denies=True)
|
opt=opt, abort_if_user_denies=True)
|
||||||
if not hook.Run(
|
if not hook.Run(project_list=pending_proj_names,
|
||||||
project_list=pending_proj_names,
|
worktree_list=pending_worktrees):
|
||||||
worktree_list=pending_worktrees):
|
|
||||||
ret = 1
|
ret = 1
|
||||||
if ret:
|
if ret:
|
||||||
return ret
|
return ret
|
||||||
|
Loading…
Reference in New Issue
Block a user