summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--manifest_xml.py6
-rwxr-xr-xrepo4
-rw-r--r--subcmds/init.py39
3 files changed, 43 insertions, 6 deletions
diff --git a/manifest_xml.py b/manifest_xml.py
index 9189eec4..c9e5c405 100644
--- a/manifest_xml.py
+++ b/manifest_xml.py
@@ -228,7 +228,11 @@ class XmlManifest(object):
228 @property 228 @property
229 def manifest_server(self): 229 def manifest_server(self):
230 self._Load() 230 self._Load()
231 return self._manifest_server 231
232 if self._manifest_server:
233 return self._manifest_server
234
235 return self.manifestProject.config.GetString('repo.manifest-server')
232 236
233 @property 237 @property
234 def IsMirror(self): 238 def IsMirror(self):
diff --git a/repo b/repo
index 0e779833..1c71f072 100755
--- a/repo
+++ b/repo
@@ -28,7 +28,7 @@ if __name__ == '__main__':
28del magic 28del magic
29 29
30# increment this whenever we make important changes to this script 30# increment this whenever we make important changes to this script
31VERSION = (1, 13) 31VERSION = (1, 14)
32 32
33# increment this if the MAINTAINER_KEYS block is modified 33# increment this if the MAINTAINER_KEYS block is modified
34KEYRING_VERSION = (1,0) 34KEYRING_VERSION = (1,0)
@@ -149,7 +149,7 @@ def _Init(args):
149 """Installs repo by cloning it over the network. 149 """Installs repo by cloning it over the network.
150 """ 150 """
151 opt, args = init_optparse.parse_args(args) 151 opt, args = init_optparse.parse_args(args)
152 if args or not opt.manifest_url: 152 if args:
153 init_optparse.print_usage() 153 init_optparse.print_usage()
154 sys.exit(1) 154 sys.exit(1)
155 155
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