From df8b1cba47fc29d045efceec8cbb43b9182acbbb Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Mon, 26 Jul 2021 15:59:20 -0400 Subject: man: make output system independent The current help output might change based on the number of CPU cores available (since it reflects the dynamic --jobs logic). This is good for users running repo locally, but not good for shipping static man pages. Hook the help output to have it generate the same output all the time. Change-Id: I3098ceddc0ad914b0b8e3b25d660b5a264cb41ee Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/312882 Reviewed-by: Roger Shimizu Reviewed-by: Mike Frysinger Tested-by: Mike Frysinger --- command.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'command.py') diff --git a/command.py b/command.py index 4087cab5..b972a0be 100644 --- a/command.py +++ b/command.py @@ -24,6 +24,10 @@ from error import InvalidProjectGroupsError import progress +# Are we generating man-pages? +GENERATE_MANPAGES = os.environ.get('_REPO_GENERATE_MANPAGES_') == ' indeed! ' + + # Number of projects to submit to a single worker process at a time. # This number represents a tradeoff between the overhead of IPC and finer # grained opportunity for parallelism. This particular value was chosen by @@ -122,10 +126,14 @@ class Command(object): help='only show errors') if self.PARALLEL_JOBS is not None: + default = 'based on number of CPU cores' + if not GENERATE_MANPAGES: + # Only include active cpu count if we aren't generating man pages. + default = f'%default; {default}' p.add_option( '-j', '--jobs', type=int, default=self.PARALLEL_JOBS, - help='number of jobs to run in parallel (default: %s)' % self.PARALLEL_JOBS) + help=f'number of jobs to run in parallel (default: {default})') def _Options(self, p): """Initialize the option parser with subcommand-specific options.""" -- cgit v1.2.3-54-g00ecf