sync: keep generated jobs-checkout help host-independent

The default shown for `--jobs-checkout` comes from `DEFAULT_LOCAL_JOBS`,
which depends on the host CPU count. As a result, regenerating the sync
and smartsync manpages on a different machine can change their output
even though repo's behavior has not changed.

Use shared CPU-based help formatting for `--jobs` and `--jobs-checkout`.
Interactive help still shows the actual default, while generated
manpages describe it without including a host-specific value.
Runtime job selection is unchanged.

Add coverage for both help modes and regenerate the affected manpages.

Change-Id: Ia60e6fcc17b6f4618c52a76217c128eddead8848
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/625381
Reviewed-by: Mike Frysinger <vapier@google.com>
Commit-Queue: Victor Pushkarev <corvinus.v@gmail.com>
Tested-by: Victor Pushkarev <corvinus.v@gmail.com>
Reviewed-by: Gavin Mak <gavinmak@google.com>
This commit is contained in:
Victor Pushkarev authored and gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com committed 2026-09-16 04:51:54 -07:00
1 parent a468ea7752
commit 4b3ada1781
5 files changed
+48 -11

No files matched your search

+16 -6
View File
@@ -17,7 +17,7 @@ import multiprocessing
import optparse
import os
import re
from typing import List, TYPE_CHECKING
from typing import List, Optional, TYPE_CHECKING
from error import InvalidProjectGroupsError
from error import NoSuchProjectError
@@ -152,6 +152,20 @@ class Command:
self._Options(self._optparse)
return self._optparse
@staticmethod
def _GetHelpForCpuJobCount(
default_jobs: Optional[int] = None,
) -> str:
"""Return CPU-based job help, with an explicit default when needed.
Specify default_jobs when additional logic computes effective default.
"""
if GENERATE_MANPAGES:
return "based on number of CPU cores"
default = "%default" if default_jobs is None else str(default_jobs)
return f"{default}; based on number of CPU cores"
def _CommonOptions(self, p, opt_v=True):
"""Initialize the option parser with common options.
@@ -176,11 +190,7 @@ class Command:
)
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}"
default = self._GetHelpForCpuJobCount()
p.add_option(
"-j",
"--jobs",