mirror of
https://gerrit.googlesource.com/git-repo
synced 2024-12-21 07:16:21 +00:00
Don't prompt the user for name/email unless necessary
If the user has already configured a workspace, use these values when re-running 'repo init'. Otherwise, if the user has global name and e-mail set, use these. It's always possible to override this and be prompted by specifying --config-name when running 'repo init'. Change-Id: If45f0e4b14884071439fb02709dc5cb53f070f60
This commit is contained in:
parent
ee1c2f5717
commit
841be34968
5
repo
5
repo
@ -139,6 +139,11 @@ group.add_option('--no-repo-verify',
|
|||||||
dest='no_repo_verify', action='store_true',
|
dest='no_repo_verify', action='store_true',
|
||||||
help='do not verify repo source code')
|
help='do not verify repo source code')
|
||||||
|
|
||||||
|
# Other
|
||||||
|
group = init_optparse.add_option_group('Other options')
|
||||||
|
group.add_option('--config-name',
|
||||||
|
dest='config_name', action="store_true", default=False,
|
||||||
|
help='Always prompt for name/e-mail')
|
||||||
|
|
||||||
class CloneFailure(Exception):
|
class CloneFailure(Exception):
|
||||||
"""Indicate the remote clone of repo itself failed.
|
"""Indicate the remote clone of repo itself failed.
|
||||||
|
@ -114,6 +114,12 @@ to update the working directory files.
|
|||||||
dest='no_repo_verify', action='store_true',
|
dest='no_repo_verify', action='store_true',
|
||||||
help='do not verify repo source code')
|
help='do not verify repo source code')
|
||||||
|
|
||||||
|
# Other
|
||||||
|
g = p.add_option_group('Other options')
|
||||||
|
g.add_option('--config-name',
|
||||||
|
dest='config_name', action="store_true", default=False,
|
||||||
|
help='Always prompt for name/e-mail')
|
||||||
|
|
||||||
def _SyncManifest(self, opt):
|
def _SyncManifest(self, opt):
|
||||||
m = self.manifest.manifestProject
|
m = self.manifest.manifestProject
|
||||||
is_new = not m.Exists
|
is_new = not m.Exists
|
||||||
@ -212,6 +218,24 @@ fatal: missing manifest url (-u) and no default found.
|
|||||||
return value
|
return value
|
||||||
return a
|
return a
|
||||||
|
|
||||||
|
def _ShouldConfigureUser(self):
|
||||||
|
gc = self.manifest.globalConfig
|
||||||
|
mp = self.manifest.manifestProject
|
||||||
|
|
||||||
|
# If we don't have local settings, get from global.
|
||||||
|
if not mp.config.Has('user.name') or not mp.config.Has('user.email'):
|
||||||
|
if not gc.Has('user.name') or not gc.Has('user.email'):
|
||||||
|
return True
|
||||||
|
|
||||||
|
mp.config.SetString('user.name', gc.GetString('user.name'))
|
||||||
|
mp.config.SetString('user.email', gc.GetString('user.email'))
|
||||||
|
|
||||||
|
print ''
|
||||||
|
print 'Your identity is: %s <%s>' % (mp.config.GetString('user.name'),
|
||||||
|
mp.config.GetString('user.email'))
|
||||||
|
print 'If you want to change this, please re-run \'repo init\' with --config-name'
|
||||||
|
return False
|
||||||
|
|
||||||
def _ConfigureUser(self):
|
def _ConfigureUser(self):
|
||||||
mp = self.manifest.manifestProject
|
mp = self.manifest.manifestProject
|
||||||
|
|
||||||
@ -294,7 +318,8 @@ fatal: missing manifest url (-u) and no default found.
|
|||||||
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:
|
||||||
self._ConfigureUser()
|
if opt.config_name or self._ShouldConfigureUser():
|
||||||
|
self._ConfigureUser()
|
||||||
self._ConfigureColor()
|
self._ConfigureColor()
|
||||||
|
|
||||||
self._ConfigureDepth(opt)
|
self._ConfigureDepth(opt)
|
||||||
|
Loading…
Reference in New Issue
Block a user