def _UseSuperprojectFromConfiguration(): """Returns the user choice of whether to use superproject.""" user_cfg = RepoConfig.ForUser() time_now = int(time.time()) user_value = user_cfg.GetBoolean('repo.superprojectChoice') if user_value is not None: user_expiration = user_cfg.GetInt('repo.superprojectChoiceExpire') if user_expiration is None or user_expiration <= 0 or user_expiration >= time_now: # TODO(b/190688390) - Remove prompt when we are comfortable with the new # default value. if user_value: print(( 'You are currently enrolled in Git submodules experiment ' '(go/android-submodules-quickstart). Use --no-use-superproject ' 'to override.\n'), file=sys.stderr) else: print(( 'You are not currently enrolled in Git submodules experiment ' '(go/android-submodules-quickstart). Use --use-superproject ' 'to override.\n'), file=sys.stderr) return user_value # We don't have an unexpired choice, ask for one. system_cfg = RepoConfig.ForSystem() system_value = system_cfg.GetBoolean('repo.superprojectChoice') if system_value: # The system configuration is proposing that we should enable the # use of superproject. Treat the user as enrolled for two weeks. # # TODO(b/190688390) - Remove prompt when we are comfortable with the new # default value. userchoice = True time_choiceexpire = time_now + (86400 * 14) user_cfg.SetString('repo.superprojectChoiceExpire', str(time_choiceexpire)) user_cfg.SetBoolean('repo.superprojectChoice', userchoice) print( 'You are automatically enrolled in Git submodules experiment ' '(go/android-submodules-quickstart) for another two weeks.\n', file=sys.stderr) return True # For all other cases, we would not use superproject by default. return False
def _ExpandAlias(self, name): """Look up user registered aliases.""" # We don't resolve aliases for existing subcommands. This matches git. if name in self.commands: return name, [] key = 'alias.%s' % (name, ) alias = RepoConfig.ForRepository(self.repodir).GetString(key) if alias is None: alias = RepoConfig.ForUser().GetString(key) if alias is None: return name, [] args = alias.strip().split(' ', 1) name = args[0] if len(args) == 2: args = shlex.split(args[1]) else: args = [] return name, args