summaryrefslogtreecommitdiffstats
path: root/subcmds/init.py
diff options
context:
space:
mode:
authorVictor Boivie <victor.boivie@sonyericsson.com>2011-04-19 10:50:12 +0200
committerShawn O. Pearce <sop@google.com>2011-11-29 14:24:58 -0800
commitee1c2f5717fcc137ab887a4aae8a08d50a539b9a (patch)
tree7a95e6ed8f8b74aac5ba59cbd04e6f24938f2e54 /subcmds/init.py
parent6a1f73738071e299f600017d99f7252d41b96b4b (diff)
downloadgit-repo-ee1c2f5717fcc137ab887a4aae8a08d50a539b9a.tar.gz
Default repo manifest settings in git config
A default manifest URL can be specified using: git config --global repo-manifest.<id>.url <url> A default manifest server can be specified using: git config --global repo-manifest.<id>.server <url> A default git mirror reference can be specified using: git config --global repo-manifest.<id>.reference <path> This will allow the user to use 'repo init -u <id>' as a shorter alternative to specifying the full URL. Also, manifest server will not have to be specified in the manifest XML and the reference will not have to be specified on the command line. If they are, they will override these default values however. Change-Id: Ifdbc160bd5909ec7df9efb0c5d7136f1d9351754 Signed-off-by: Victor Boivie <victor.boivie@sonyericsson.com>
Diffstat (limited to 'subcmds/init.py')
-rw-r--r--subcmds/init.py39
1 files changed, 36 insertions, 3 deletions
diff --git a/subcmds/init.py b/subcmds/init.py
index 1c23d620..e80d698b 100644
--- a/subcmds/init.py
+++ b/subcmds/init.py
@@ -23,6 +23,7 @@ from error import ManifestParseError
23from project import SyncBuffer 23from project import SyncBuffer
24from git_config import GitConfig 24from git_config import GitConfig
25from git_command import git_require, MIN_GIT_VERSION 25from git_command import git_require, MIN_GIT_VERSION
26from git_config import GitConfig
26 27
27class Init(InteractiveCommand, MirrorSafeCommand): 28class Init(InteractiveCommand, MirrorSafeCommand):
28 common = True 29 common = True
@@ -36,6 +37,20 @@ The latest repo source code and manifest collection is downloaded
36from the server and is installed in the .repo/ directory in the 37from the server and is installed in the .repo/ directory in the
37current working directory. 38current working directory.
38 39
40The optional -u argument can be used to specify a URL to the
41manifest project. It is also possible to have a git configuration
42section as below to use 'identifier' as argument to -u:
43
44 [repo-manifest "identifier"]
45 url = ...
46 server = ...
47 reference = ...
48
49Only the url is required - the others are optional.
50
51If no -u argument is specified, the 'repo-manifest' section named
52'default' will be used if present.
53
39The optional -b argument can be used to select the manifest branch 54The optional -b argument can be used to select the manifest branch
40to checkout and use. If no branch is specified, master is assumed. 55to checkout and use. If no branch is specified, master is assumed.
41 56
@@ -69,7 +84,7 @@ to update the working directory files.
69 # Manifest 84 # Manifest
70 g = p.add_option_group('Manifest options') 85 g = p.add_option_group('Manifest options')
71 g.add_option('-u', '--manifest-url', 86 g.add_option('-u', '--manifest-url',
72 dest='manifest_url', 87 dest='manifest_url', default='default',
73 help='manifest repository location', metavar='URL') 88 help='manifest repository location', metavar='URL')
74 g.add_option('-b', '--manifest-branch', 89 g.add_option('-b', '--manifest-branch',
75 dest='manifest_branch', 90 dest='manifest_branch',
@@ -102,10 +117,25 @@ to update the working directory files.
102 def _SyncManifest(self, opt): 117 def _SyncManifest(self, opt):
103 m = self.manifest.manifestProject 118 m = self.manifest.manifestProject
104 is_new = not m.Exists 119 is_new = not m.Exists
120 manifest_server = None
121
122 # The manifest url may point out a manifest section in the config
123 key = 'repo-manifest.%s.' % opt.manifest_url
124 if GitConfig.ForUser().GetString(key + 'url'):
125 opt.manifest_url = GitConfig.ForUser().GetString(key + 'url')
126
127 # Also copy other options to the manifest config if not specified already.
128 if not opt.reference:
129 opt.reference = GitConfig.ForUser().GetString(key + 'reference')
130 manifest_server = GitConfig.ForUser().GetString(key + 'server')
105 131
106 if is_new: 132 if is_new:
107 if not opt.manifest_url: 133 if not opt.manifest_url or opt.manifest_url == 'default':
108 print >>sys.stderr, 'fatal: manifest url (-u) is required.' 134 print >>sys.stderr, """\
135fatal: missing manifest url (-u) and no default found.
136
137 tip: The global git configuration key 'repo-manifest.default.url' can
138 be used to specify a default url."""
109 sys.exit(1) 139 sys.exit(1)
110 140
111 if not opt.quiet: 141 if not opt.quiet:
@@ -129,6 +159,9 @@ to update the working directory files.
129 r.ResetFetch() 159 r.ResetFetch()
130 r.Save() 160 r.Save()
131 161
162 if manifest_server:
163 m.config.SetString('repo.manifest-server', manifest_server)
164
132 if opt.reference: 165 if opt.reference:
133 m.config.SetString('repo.reference', opt.reference) 166 m.config.SetString('repo.reference', opt.reference)
134 167