switch to 4 space indent
Leave the recipes/ code at 2 space to match the rest of the recipes
project in other repos.
Reformatted using:
files=( $(
git ls-tree -r --name-only HEAD | \
grep -Ev -e '^(third_party|recipes)/' | \
grep '\.py$';
git grep -l '#!/usr/bin/env.*python' | grep -v '\.py$'
) )
parallel ./yapf -i -- "${files[@]}"
~/chromiumos/chromite/contrib/reflow_overlong_comments "${files[@]}"
The files that still had strings that were too long were manually
reformatted because they were easy and only a few issues.
autoninja.py
clang_format.py
download_from_google_storage.py
fix_encoding.py
gclient_utils.py
git_cache.py
git_common.py
git_map_branches.py
git_reparent_branch.py
gn.py
my_activity.py
owners_finder.py
presubmit_canned_checks.py
reclient_helper.py
reclientreport.py
roll_dep.py
rustfmt.py
siso.py
split_cl.py
subcommand.py
subprocess2.py
swift_format.py
upload_to_google_storage.py
These files still had lines (strings) that were too long, so the pylint
warnings were suppressed with a TODO.
auth.py
gclient.py
gclient_eval.py
gclient_paths.py
gclient_scm.py
gerrit_util.py
git_cl.py
presubmit_canned_checks.py
presubmit_support.py
scm.py
Change-Id: Ia6535c4f2c48d46b589ec1e791dde6c6b2ea858f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/tools/depot_tools/+/4836379
Commit-Queue: Josip Sokcevic <sokcevic@chromium.org>
Auto-Submit: Mike Frysinger <vapier@chromium.org>
Reviewed-by: Josip Sokcevic <sokcevic@chromium.org>
diff --git a/git_migrate_default_branch.py b/git_migrate_default_branch.py
index 11ff4b6..735f049 100644
--- a/git_migrate_default_branch.py
+++ b/git_migrate_default_branch.py
@@ -15,88 +15,89 @@
def GetGerritProject(remote_url):
- """Returns Gerrit project name based on remote git URL."""
- if remote_url is None:
- raise RuntimeError('can\'t detect Gerrit project.')
- project = urllib.parse.urlparse(remote_url).path.strip('/')
- if project.endswith('.git'):
- project = project[:-len('.git')]
- # *.googlesource.com hosts ensure that Git/Gerrit projects don't start with
- # 'a/' prefix, because 'a/' prefix is used to force authentication in
- # gitiles/git-over-https protocol. E.g.,
- # https://chromium.googlesource.com/a/v8/v8 refers to the same repo/project
- # as
- # https://chromium.googlesource.com/v8/v8
- if project.startswith('a/'):
- project = project[len('a/'):]
- return project
+ """Returns Gerrit project name based on remote git URL."""
+ if remote_url is None:
+ raise RuntimeError('can\'t detect Gerrit project.')
+ project = urllib.parse.urlparse(remote_url).path.strip('/')
+ if project.endswith('.git'):
+ project = project[:-len('.git')]
+ # *.googlesource.com hosts ensure that Git/Gerrit projects don't start with
+ # 'a/' prefix, because 'a/' prefix is used to force authentication in
+ # gitiles/git-over-https protocol. E.g.,
+ # https://chromium.googlesource.com/a/v8/v8 refers to the same repo/project
+ # as
+ # https://chromium.googlesource.com/v8/v8
+ if project.startswith('a/'):
+ project = project[len('a/'):]
+ return project
def GetGerritHost(git_host):
- parts = git_host.split('.')
- parts[0] = parts[0] + '-review'
- return '.'.join(parts)
+ parts = git_host.split('.')
+ parts[0] = parts[0] + '-review'
+ return '.'.join(parts)
def main():
- remote = git_common.run('remote')
- # Use first remote as source of truth
- remote = remote.split("\n")[0]
- if not remote:
- raise RuntimeError('Could not find any remote')
- url = scm.GIT.GetConfig(git_common.repo_root(), 'remote.%s.url' % remote)
- host = urllib.parse.urlparse(url).netloc
- if not host:
- raise RuntimeError('Could not find remote host')
+ remote = git_common.run('remote')
+ # Use first remote as source of truth
+ remote = remote.split("\n")[0]
+ if not remote:
+ raise RuntimeError('Could not find any remote')
+ url = scm.GIT.GetConfig(git_common.repo_root(), 'remote.%s.url' % remote)
+ host = urllib.parse.urlparse(url).netloc
+ if not host:
+ raise RuntimeError('Could not find remote host')
- project_head = gerrit_util.GetProjectHead(GetGerritHost(host),
- GetGerritProject(url))
- if project_head != 'refs/heads/main':
- raise RuntimeError("The repository is not migrated yet.")
+ project_head = gerrit_util.GetProjectHead(GetGerritHost(host),
+ GetGerritProject(url))
+ if project_head != 'refs/heads/main':
+ raise RuntimeError("The repository is not migrated yet.")
- # User may have set to fetch only old default branch. Ensure fetch is tracking
- # main too.
- git_common.run('config', '--unset-all',
- 'remote.origin.fetch', 'refs/heads/*')
- git_common.run('config', '--add',
- 'remote.origin.fetch', '+refs/heads/*:refs/remotes/origin/*')
- logging.info("Running fetch...")
- git_common.run('fetch', remote)
- logging.info("Updating remote HEAD...")
- git_common.run('remote', 'set-head', '-a', remote)
+ # User may have set to fetch only old default branch. Ensure fetch is
+ # tracking main too.
+ git_common.run('config', '--unset-all', 'remote.origin.fetch',
+ 'refs/heads/*')
+ git_common.run('config', '--add', 'remote.origin.fetch',
+ '+refs/heads/*:refs/remotes/origin/*')
+ logging.info("Running fetch...")
+ git_common.run('fetch', remote)
+ logging.info("Updating remote HEAD...")
+ git_common.run('remote', 'set-head', '-a', remote)
- branches = git_common.get_branches_info(True)
-
- if 'master' in branches:
- logging.info("Migrating master branch...")
- if 'main' in branches:
- logging.info('You already have master and main branch, consider removing '
- 'master manually:\n'
- ' $ git branch -d master\n')
- else:
- git_common.run('branch', '-m', 'master', 'main')
branches = git_common.get_branches_info(True)
- for name in branches:
- branch = branches[name]
- if not branch:
- continue
+ if 'master' in branches:
+ logging.info("Migrating master branch...")
+ if 'main' in branches:
+ logging.info(
+ 'You already have master and main branch, consider removing '
+ 'master manually:\n'
+ ' $ git branch -d master\n')
+ else:
+ git_common.run('branch', '-m', 'master', 'main')
+ branches = git_common.get_branches_info(True)
- if 'master' in branch.upstream:
- logging.info("Migrating %s branch..." % name)
- new_upstream = branch.upstream.replace('master', 'main')
- git_common.run('branch', '--set-upstream-to', new_upstream, name)
- git_common.remove_merge_base(name)
+ for name in branches:
+ branch = branches[name]
+ if not branch:
+ continue
+
+ if 'master' in branch.upstream:
+ logging.info("Migrating %s branch..." % name)
+ new_upstream = branch.upstream.replace('master', 'main')
+ git_common.run('branch', '--set-upstream-to', new_upstream, name)
+ git_common.remove_merge_base(name)
if __name__ == '__main__':
- fix_encoding.fix_encoding()
- logging.basicConfig(level=logging.INFO)
- with metrics.collector.print_notice_and_exit():
- try:
- logging.info("Starting migration")
- main()
- logging.info("Migration completed")
- except RuntimeError as e:
- logging.error("Error %s" % str(e))
- sys.exit(1)
+ fix_encoding.fix_encoding()
+ logging.basicConfig(level=logging.INFO)
+ with metrics.collector.print_notice_and_exit():
+ try:
+ logging.info("Starting migration")
+ main()
+ logging.info("Migration completed")
+ except RuntimeError as e:
+ logging.error("Error %s" % str(e))
+ sys.exit(1)