summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Boivie <victor.boivie@sonyericsson.com>2011-04-05 11:31:10 +0200
committerShawn O. Pearce <sop@google.com>2011-11-29 14:31:56 -0800
commit841be34968c91c3ea8d8694bc5910e6388f58cbb (patch)
treecd2b3db593611ecad858e841edae17183458f680
parentee1c2f5717fcc137ab887a4aae8a08d50a539b9a (diff)
downloadgit-repo-841be34968c91c3ea8d8694bc5910e6388f58cbb.tar.gz
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
-rwxr-xr-xrepo5
-rw-r--r--subcmds/init.py27
2 files changed, 31 insertions, 1 deletions
diff --git a/repo b/repo
index 1c71f072..0b20a9b8 100755
--- a/repo
+++ b/repo
@@ -139,6 +139,11 @@ group.add_option('--no-repo-verify',
139 dest='no_repo_verify', action='store_true', 139 dest='no_repo_verify', action='store_true',
140 help='do not verify repo source code') 140 help='do not verify repo source code')
141 141
142# Other
143group = init_optparse.add_option_group('Other options')
144group.add_option('--config-name',
145 dest='config_name', action="store_true", default=False,
146 help='Always prompt for name/e-mail')
142 147
143class CloneFailure(Exception): 148class CloneFailure(Exception):
144 """Indicate the remote clone of repo itself failed. 149 """Indicate the remote clone of repo itself failed.
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)