summaryrefslogtreecommitdiffstats
path: root/subcmds/init.py
diff options
context:
space:
mode:
Diffstat (limited to 'subcmds/init.py')
-rw-r--r--subcmds/init.py27
1 files changed, 26 insertions, 1 deletions
diff --git a/subcmds/init.py b/subcmds/init.py
index e80d698b..a653c80d 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -114,6 +114,12 @@ to update the working directory files.
114 dest='no_repo_verify', action='store_true', 114 dest='no_repo_verify', action='store_true',
115 help='do not verify repo source code') 115 help='do not verify repo source code')
116 116
117 # Other
118 g = p.add_option_group('Other options')
119 g.add_option('--config-name',
120 dest='config_name', action="store_true", default=False,
121 help='Always prompt for name/e-mail')
122
117 def _SyncManifest(self, opt): 123 def _SyncManifest(self, opt):
118 m = self.manifest.manifestProject 124 m = self.manifest.manifestProject
119 is_new = not m.Exists 125 is_new = not m.Exists
@@ -212,6 +218,24 @@ fatal: missing manifest url (-u) and no default found.
212 return value 218 return value
213 return a 219 return a
214 220
221 def _ShouldConfigureUser(self):
222 gc = self.manifest.globalConfig
223 mp = self.manifest.manifestProject
224
225 # If we don't have local settings, get from global.
226 if not mp.config.Has('user.name') or not mp.config.Has('user.email'):
227 if not gc.Has('user.name') or not gc.Has('user.email'):
228 return True
229
230 mp.config.SetString('user.name', gc.GetString('user.name'))
231 mp.config.SetString('user.email', gc.GetString('user.email'))
232
233 print ''
234 print 'Your identity is: %s <%s>' % (mp.config.GetString('user.name'),
235 mp.config.GetString('user.email'))
236 print 'If you want to change this, please re-run \'repo init\' with --config-name'
237 return False
238
215 def _ConfigureUser(self): 239 def _ConfigureUser(self):
216 mp = self.manifest.manifestProject 240 mp = self.manifest.manifestProject
217 241
@@ -294,7 +318,8 @@ fatal: missing manifest url (-u) and no default found.
294 self._LinkManifest(opt.manifest_name) 318 self._LinkManifest(opt.manifest_name)
295 319
296 if os.isatty(0) and os.isatty(1) and not self.manifest.IsMirror: 320 if os.isatty(0) and os.isatty(1) and not self.manifest.IsMirror:
297 self._ConfigureUser() 321 if opt.config_name or self._ShouldConfigureUser():
322 self._ConfigureUser()
298 self._ConfigureColor() 323 self._ConfigureColor()
299 324
300 self._ConfigureDepth(opt) 325 self._ConfigureDepth(opt)