diff options
author | Xin Li <delphij@google.com> | 2021-09-14 16:42:37 -0700 |
---|---|---|
committer | Xin Li <delphij@google.com> | 2021-09-20 07:21:22 +0000 |
commit | 0ec2029833ffa85400b729dc3b7039661eb42619 (patch) | |
tree | 37602aec6c97597589b3958ab56bd80d24ece4de /git_superproject.py | |
parent | d8e8ae8990c7f02907f8f86d9f772ca4e4b02f11 (diff) | |
download | git-repo-0ec2029833ffa85400b729dc3b7039661eb42619.tar.gz |
superproject: Move enrollment to opt-out when enabled globallyv2.16.8
Our internal experiments was a success so far and we are enrolling 100%
users now. Instead of asking every two weeks, simply consider a lack of
unexpired choice as accepting the system default.
With this change the user would still be able to override the system
default with --no-use-superproject, or to permanently set the choice in
user's profile with git config --global repo.superprojectchoice.
Bug: [google internal] b/190688390
Change-Id: Idc77a9cbf88a169d90304169e91f0d722dc4ac8b
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/317975
Tested-by: Xin Li <delphij@google.com>
Reviewed-by: Raman Tenneti <rtenneti@google.com>
Diffstat (limited to 'git_superproject.py')
-rw-r--r-- | git_superproject.py | 46 |
1 files changed, 10 insertions, 36 deletions
diff --git a/git_superproject.py b/git_superproject.py index 1dd59435..935e1250 100644 --- a/git_superproject.py +++ b/git_superproject.py | |||
@@ -370,7 +370,7 @@ def _UseSuperprojectFromConfiguration(): | |||
370 | user_value = user_cfg.GetBoolean('repo.superprojectChoice') | 370 | user_value = user_cfg.GetBoolean('repo.superprojectChoice') |
371 | if user_value is not None: | 371 | if user_value is not None: |
372 | user_expiration = user_cfg.GetInt('repo.superprojectChoiceExpire') | 372 | user_expiration = user_cfg.GetInt('repo.superprojectChoiceExpire') |
373 | if user_expiration is not None and (user_expiration <= 0 or user_expiration >= time_now): | 373 | if user_expiration is None or user_expiration <= 0 or user_expiration >= time_now: |
374 | # TODO(b/190688390) - Remove prompt when we are comfortable with the new | 374 | # TODO(b/190688390) - Remove prompt when we are comfortable with the new |
375 | # default value. | 375 | # default value. |
376 | if user_value: | 376 | if user_value: |
@@ -388,44 +388,18 @@ def _UseSuperprojectFromConfiguration(): | |||
388 | system_value = system_cfg.GetBoolean('repo.superprojectChoice') | 388 | system_value = system_cfg.GetBoolean('repo.superprojectChoice') |
389 | if system_value: | 389 | if system_value: |
390 | # The system configuration is proposing that we should enable the | 390 | # The system configuration is proposing that we should enable the |
391 | # use of superproject. Present this to user for confirmation if we | 391 | # use of superproject. Treat the user as enrolled for two weeks. |
392 | # are on a TTY, or, when we are not on a TTY, accept the system | ||
393 | # default for this time only. | ||
394 | # | 392 | # |
395 | # TODO(b/190688390) - Remove prompt when we are comfortable with the new | 393 | # TODO(b/190688390) - Remove prompt when we are comfortable with the new |
396 | # default value. | 394 | # default value. |
397 | prompt = ('Repo can now use Git submodules (go/android-submodules-quickstart) ' | 395 | userchoice = True |
398 | 'instead of manifests to represent the state of the Android ' | 396 | time_choiceexpire = time_now + (86400 * 14) |
399 | 'superproject, which results in faster syncs and better atomicity.\n\n') | 397 | user_cfg.SetString('repo.superprojectChoiceExpire', str(time_choiceexpire)) |
400 | if sys.stdout.isatty(): | 398 | user_cfg.SetBoolean('repo.superprojectChoice', userchoice) |
401 | prompt += 'Would you like to opt in for two weeks (y/N)? ' | 399 | print('You are automatically enrolled in Git submodules experiment ' |
402 | response = input(prompt).lower() | 400 | '(go/android-submodules-quickstart) for another two weeks.\n', |
403 | time_choiceexpire = time_now + (86400 * 14) | 401 | file=sys.stderr) |
404 | if response in ('y', 'yes'): | 402 | return True |
405 | userchoice = True | ||
406 | elif response in ('a', 'always'): | ||
407 | userchoice = True | ||
408 | time_choiceexpire = 0 | ||
409 | elif response == 'never': | ||
410 | userchoice = False | ||
411 | time_choiceexpire = 0 | ||
412 | elif response in ('n', 'no'): | ||
413 | userchoice = False | ||
414 | else: | ||
415 | # Unrecognized user response, assume the intention was no, but | ||
416 | # only for 2 hours instead of 2 weeks to balance between not | ||
417 | # being overly pushy while still retain the opportunity to | ||
418 | # enroll. | ||
419 | userchoice = False | ||
420 | time_choiceexpire = time_now + 7200 | ||
421 | |||
422 | user_cfg.SetString('repo.superprojectChoiceExpire', str(time_choiceexpire)) | ||
423 | user_cfg.SetBoolean('repo.superprojectChoice', userchoice) | ||
424 | |||
425 | return userchoice | ||
426 | else: | ||
427 | print('Accepting once since we are not on a TTY', file=sys.stderr) | ||
428 | return True | ||
429 | 403 | ||
430 | # For all other cases, we would not use superproject by default. | 404 | # For all other cases, we would not use superproject by default. |
431 | return False | 405 | return False |