diff options
| author | Insaf Latypov <saferif@google.com> | 2026-10-13 15:50:11 +0000 |
|---|---|---|
| committer | gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com <gerrit-scoped@luci-project-accounts.iam.gserviceaccount.com> | 2026-10-19 12:20:06 -0700 |
| commit | 46e9866ca0f161604bd45a0c3b7c7887c9415dcb (patch) | |
| tree | 2f70f0e9b78804ee11f96f427b56066bda5e1e4f /subcmds/sync.py | |
| parent | 404aec7b53107a07f29445580f6b5e7a99419757 (diff) | |
| download | git-repo-stable.tar.gz git-repo-stable.zip | |
Add a boolean `sync.smartsync` setting in the per-user repo config
(~/.repoconfig/config):
* true: smart sync by default, as if -s were passed.
* false: never smart sync by default, even if the manifest enables it.
* unset: follow the manifest default, as before.
Add docs/repoconfig.md as the user facing documentation for
~/.repoconfig/config and its settings, and point smart-sync.md and the
`repo sync` help at it.
Bug: 569927750
Test: ./run_tests
Change-Id: Ideb4119fcb5e90f8bb35c493d9e4f8bec7878b77
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/643264
Reviewed-by: Gavin Mak <gavinmak@google.com>
Commit-Queue: Insaf Latypov <saferif@google.com>
Tested-by: Insaf Latypov <saferif@google.com>
Diffstat (limited to 'subcmds/sync.py')
| -rw-r--r-- | subcmds/sync.py | 27 |
1 files changed, 23 insertions, 4 deletions
diff --git a/subcmds/sync.py b/subcmds/sync.py index e83f42345..d6354d4a0 100644 --- a/subcmds/sync.py +++ b/subcmds/sync.py @@ -69,6 +69,7 @@ import event_log from git_command import git_require from git_command import GitCommand from git_config import GetUrlCookieFile +from git_config import RepoConfig from git_refs import HEAD from git_refs import R_HEADS import git_superproject @@ -491,6 +492,10 @@ build as specified by the manifest-server element in the current manifest. The -t/--smart-tag option is similar and allows you to specify a custom tag/label. +Whether '%prog' smart syncs by default can also be controlled with the +sync.smartsync per-user setting; see docs/repoconfig.md. Explicit +-s/--no-smart-sync/-t flags always override it. + The -u/--manifest-server-username and -p/--manifest-server-password options can be used to specify a username and password to authenticate with the manifest server when using the -s or -t option. @@ -2522,22 +2527,36 @@ later is required to fix a server side protocol bug. def _ResolveSmartSyncOption( self, opt: optparse.Values, manifest: XmlManifest ) -> bool: - """Resolve opt.smart_sync from the CLI flags and manifest default. + """Resolve opt.smart_sync from CLI flags, user config and manifest. + + Precedence: CLI flags > per-user settings > per-manifest settings. + See docs/repoconfig.md and docs/smart-sync.md for details. Returns: True if smart_sync was enabled implicitly by the manifest default, - False otherwise. + False otherwise. Smart sync enabled via per-user settings counts + as an explicit user request, not implicit. """ - implicit = ( + user_pref = RepoConfig.ForUser().GetBoolean("sync.smartsync") + default_allowed = ( opt.smart_sync is None and not opt.smart_tag and not opt.manifest_name and not opt.superproject_revision and not opt.local_only + ) + implicit = ( + default_allowed + and user_pref is None and getattr(manifest.default, "sync_smartsync", False) is True ) if opt.smart_sync is None: - opt.smart_sync = implicit + if user_pref is False: + opt.smart_sync = False + elif user_pref is True: + opt.smart_sync = default_allowed + else: + opt.smart_sync = implicit if ( opt.manifest_server_username or opt.manifest_server_password |
