From ea2e330e43c182dc16b0111ebc69ee5a71ee4ce1 Mon Sep 17 00:00:00 2001 From: Gavin Mak Date: Sat, 11 Mar 2023 06:46:20 +0000 Subject: Format codebase with black and check formatting in CQ Apply rules set by https://gerrit-review.googlesource.com/c/git-repo/+/362954/ across the codebase and fix any lingering errors caught by flake8. Also check black formatting in run_tests (and CQ). Bug: b/267675342 Change-Id: I972d77649dac351150dcfeb1cd1ad0ea2efc1956 Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/363474 Reviewed-by: Mike Frysinger Tested-by: Gavin Mak Commit-Queue: Gavin Mak --- subcmds/prune.py | 107 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 60 insertions(+), 47 deletions(-) (limited to 'subcmds/prune.py') diff --git a/subcmds/prune.py b/subcmds/prune.py index 251accaa..5a68c14a 100644 --- a/subcmds/prune.py +++ b/subcmds/prune.py @@ -19,63 +19,76 @@ from command import DEFAULT_LOCAL_JOBS, PagedCommand class Prune(PagedCommand): - COMMON = True - helpSummary = "Prune (delete) already merged topics" - helpUsage = """ + COMMON = True + helpSummary = "Prune (delete) already merged topics" + helpUsage = """ %prog [...] """ - PARALLEL_JOBS = DEFAULT_LOCAL_JOBS + PARALLEL_JOBS = DEFAULT_LOCAL_JOBS - def _ExecuteOne(self, project): - """Process one project.""" - return project.PruneHeads() + def _ExecuteOne(self, project): + """Process one project.""" + return project.PruneHeads() - def Execute(self, opt, args): - projects = self.GetProjects(args, all_manifests=not opt.this_manifest_only) + def Execute(self, opt, args): + projects = self.GetProjects( + args, all_manifests=not opt.this_manifest_only + ) - # NB: Should be able to refactor this module to display summary as results - # come back from children. - def _ProcessResults(_pool, _output, results): - return list(itertools.chain.from_iterable(results)) + # NB: Should be able to refactor this module to display summary as + # results come back from children. + def _ProcessResults(_pool, _output, results): + return list(itertools.chain.from_iterable(results)) - all_branches = self.ExecuteInParallel( - opt.jobs, - self._ExecuteOne, - projects, - callback=_ProcessResults, - ordered=True) + all_branches = self.ExecuteInParallel( + opt.jobs, + self._ExecuteOne, + projects, + callback=_ProcessResults, + ordered=True, + ) - if not all_branches: - return + if not all_branches: + return - class Report(Coloring): - def __init__(self, config): - Coloring.__init__(self, config, 'status') - self.project = self.printer('header', attr='bold') + class Report(Coloring): + def __init__(self, config): + Coloring.__init__(self, config, "status") + self.project = self.printer("header", attr="bold") - out = Report(all_branches[0].project.config) - out.project('Pending Branches') - out.nl() + out = Report(all_branches[0].project.config) + out.project("Pending Branches") + out.nl() - project = None + project = None - for branch in all_branches: - if project != branch.project: - project = branch.project - out.nl() - out.project('project %s/' % project.RelPath(local=opt.this_manifest_only)) - out.nl() + for branch in all_branches: + if project != branch.project: + project = branch.project + out.nl() + out.project( + "project %s/" + % project.RelPath(local=opt.this_manifest_only) + ) + out.nl() - print('%s %-33s ' % ( - branch.name == project.CurrentBranch and '*' or ' ', - branch.name), end='') + print( + "%s %-33s " + % ( + branch.name == project.CurrentBranch and "*" or " ", + branch.name, + ), + end="", + ) - if not branch.base_exists: - print('(ignoring: tracking branch is gone: %s)' % (branch.base,)) - else: - commits = branch.commits - date = branch.date - print('(%2d commit%s, %s)' % ( - len(commits), - len(commits) != 1 and 's' or ' ', - date)) + if not branch.base_exists: + print( + "(ignoring: tracking branch is gone: %s)" % (branch.base,) + ) + else: + commits = branch.commits + date = branch.date + print( + "(%2d commit%s, %s)" + % (len(commits), len(commits) != 1 and "s" or " ", date) + ) -- cgit v1.2.3-54-g00ecf