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 | |
| parent | 404aec7b53107a07f29445580f6b5e7a99419757 (diff) | |
| download | git-repo-2.70.tar.gz | |
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')
| -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 | |||
| 69 | from git_command import git_require | 69 | from git_command import git_require |
| 70 | from git_command import GitCommand | 70 | from git_command import GitCommand |
| 71 | from git_config import GetUrlCookieFile | 71 | from git_config import GetUrlCookieFile |
| 72 | from git_config import RepoConfig | ||
| 72 | from git_refs import HEAD | 73 | from git_refs import HEAD |
| 73 | from git_refs import R_HEADS | 74 | from git_refs import R_HEADS |
| 74 | import git_superproject | 75 | import git_superproject |
| @@ -491,6 +492,10 @@ build as specified by the manifest-server element in the current | |||
| 491 | manifest. The -t/--smart-tag option is similar and allows you to | 492 | manifest. The -t/--smart-tag option is similar and allows you to |
| 492 | specify a custom tag/label. | 493 | specify a custom tag/label. |
| 493 | 494 | ||
| 495 | Whether '%prog' smart syncs by default can also be controlled with the | ||
| 496 | sync.smartsync per-user setting; see docs/repoconfig.md. Explicit | ||
| 497 | -s/--no-smart-sync/-t flags always override it. | ||
| 498 | |||
| 494 | The -u/--manifest-server-username and -p/--manifest-server-password | 499 | The -u/--manifest-server-username and -p/--manifest-server-password |
| 495 | options can be used to specify a username and password to authenticate | 500 | options can be used to specify a username and password to authenticate |
| 496 | with the manifest server when using the -s or -t option. | 501 | 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. | |||
| 2522 | def _ResolveSmartSyncOption( | 2527 | def _ResolveSmartSyncOption( |
| 2523 | self, opt: optparse.Values, manifest: XmlManifest | 2528 | self, opt: optparse.Values, manifest: XmlManifest |
| 2524 | ) -> bool: | 2529 | ) -> bool: |
| 2525 | """Resolve opt.smart_sync from the CLI flags and manifest default. | 2530 | """Resolve opt.smart_sync from CLI flags, user config and manifest. |
| 2531 | |||
| 2532 | Precedence: CLI flags > per-user settings > per-manifest settings. | ||
| 2533 | See docs/repoconfig.md and docs/smart-sync.md for details. | ||
| 2526 | 2534 | ||
| 2527 | Returns: | 2535 | Returns: |
| 2528 | True if smart_sync was enabled implicitly by the manifest default, | 2536 | True if smart_sync was enabled implicitly by the manifest default, |
| 2529 | False otherwise. | 2537 | False otherwise. Smart sync enabled via per-user settings counts |
| 2538 | as an explicit user request, not implicit. | ||
| 2530 | """ | 2539 | """ |
| 2531 | implicit = ( | 2540 | user_pref = RepoConfig.ForUser().GetBoolean("sync.smartsync") |
| 2541 | default_allowed = ( | ||
| 2532 | opt.smart_sync is None | 2542 | opt.smart_sync is None |
| 2533 | and not opt.smart_tag | 2543 | and not opt.smart_tag |
| 2534 | and not opt.manifest_name | 2544 | and not opt.manifest_name |
| 2535 | and not opt.superproject_revision | 2545 | and not opt.superproject_revision |
| 2536 | and not opt.local_only | 2546 | and not opt.local_only |
| 2547 | ) | ||
| 2548 | implicit = ( | ||
| 2549 | default_allowed | ||
| 2550 | and user_pref is None | ||
| 2537 | and getattr(manifest.default, "sync_smartsync", False) is True | 2551 | and getattr(manifest.default, "sync_smartsync", False) is True |
| 2538 | ) | 2552 | ) |
| 2539 | if opt.smart_sync is None: | 2553 | if opt.smart_sync is None: |
| 2540 | opt.smart_sync = implicit | 2554 | if user_pref is False: |
| 2555 | opt.smart_sync = False | ||
| 2556 | elif user_pref is True: | ||
| 2557 | opt.smart_sync = default_allowed | ||
| 2558 | else: | ||
| 2559 | opt.smart_sync = implicit | ||
| 2541 | 2560 | ||
| 2542 | if ( | 2561 | if ( |
| 2543 | opt.manifest_server_username or opt.manifest_server_password | 2562 | opt.manifest_server_username or opt.manifest_server_password |
