init: hide summary output when using --quiet

Change-Id: I5e30a6d6a1c95fb8d75d8b0f4d63b497e9aac526
Reviewed-on: https://gerrit-review.googlesource.com/c/git-repo/+/256452
Reviewed-by: David Pursehouse <dpursehouse@collab.net>
Tested-by: Mike Frysinger <vapier@google.com>
This commit is contained in:
Mike Frysinger 2020-02-21 22:48:40 -05:00
parent 75264789c0
commit 0b888912cb

View File

@ -347,7 +347,7 @@ to update the working directory files.
return value return value
return a return a
def _ShouldConfigureUser(self): def _ShouldConfigureUser(self, opt):
gc = self.manifest.globalConfig gc = self.manifest.globalConfig
mp = self.manifest.manifestProject mp = self.manifest.manifestProject
@ -359,20 +359,23 @@ to update the working directory files.
mp.config.SetString('user.name', gc.GetString('user.name')) mp.config.SetString('user.name', gc.GetString('user.name'))
mp.config.SetString('user.email', gc.GetString('user.email')) mp.config.SetString('user.email', gc.GetString('user.email'))
if not opt.quiet:
print() print()
print('Your identity is: %s <%s>' % (mp.config.GetString('user.name'), print('Your identity is: %s <%s>' % (mp.config.GetString('user.name'),
mp.config.GetString('user.email'))) mp.config.GetString('user.email')))
print('If you want to change this, please re-run \'repo init\' with --config-name') print("If you want to change this, please re-run 'repo init' with --config-name")
return False return False
def _ConfigureUser(self): def _ConfigureUser(self, opt):
mp = self.manifest.manifestProject mp = self.manifest.manifestProject
while True: while True:
if not opt.quiet:
print() print()
name = self._Prompt('Your Name', mp.UserName) name = self._Prompt('Your Name', mp.UserName)
email = self._Prompt('Your Email', mp.UserEmail) email = self._Prompt('Your Email', mp.UserEmail)
if not opt.quiet:
print() print()
print('Your identity is: %s <%s>' % (name, email)) print('Your identity is: %s <%s>' % (name, email))
print('is this correct [y/N]? ', end='') print('is this correct [y/N]? ', end='')
@ -445,15 +448,16 @@ to update the working directory files.
# We store the depth in the main manifest project. # We store the depth in the main manifest project.
self.manifest.manifestProject.config.SetString('repo.depth', depth) self.manifest.manifestProject.config.SetString('repo.depth', depth)
def _DisplayResult(self): def _DisplayResult(self, opt):
if self.manifest.IsMirror: if self.manifest.IsMirror:
init_type = 'mirror ' init_type = 'mirror '
else: else:
init_type = '' init_type = ''
if not opt.quiet:
print() print()
print('repo %shas been initialized in %s' print('repo %shas been initialized in %s' %
% (init_type, self.manifest.topdir)) (init_type, self.manifest.topdir))
current_dir = os.getcwd() current_dir = os.getcwd()
if current_dir != self.manifest.topdir: if current_dir != self.manifest.topdir:
@ -487,8 +491,8 @@ to update the working directory files.
self._LinkManifest(opt.manifest_name) self._LinkManifest(opt.manifest_name)
if os.isatty(0) and os.isatty(1) and not self.manifest.IsMirror: if os.isatty(0) and os.isatty(1) and not self.manifest.IsMirror:
if opt.config_name or self._ShouldConfigureUser(): if opt.config_name or self._ShouldConfigureUser(opt):
self._ConfigureUser() self._ConfigureUser(opt)
self._ConfigureColor() self._ConfigureColor()
self._DisplayResult() self._DisplayResult(opt)