summaryrefslogtreecommitdiffstats
path: root/git_superproject.py
diff options
context:
space:
mode:
Diffstat (limited to 'git_superproject.py')
-rw-r--r--git_superproject.py46
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