aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--docs/manpages/gbp-create-remote-repo.sgml10
-rw-r--r--gbp/config.py5
-rw-r--r--gbp/scripts/create_remote_repo.py41
3 files changed, 40 insertions, 16 deletions
diff --git a/docs/manpages/gbp-create-remote-repo.sgml b/docs/manpages/gbp-create-remote-repo.sgml
index 0a21d35c..e680f9e8 100644
--- a/docs/manpages/gbp-create-remote-repo.sgml
+++ b/docs/manpages/gbp-create-remote-repo.sgml
@@ -24,6 +24,7 @@
<arg><option>--color=</option><replaceable>[auto|on|off]</replaceable></arg>
<arg><option>--remote-url-pattern=</option><replaceable>url-pattern</replaceable></arg>
<arg><option>--remote-name=</option><replaceable>name</replaceable></arg>
+ <arg><option>--template-dir=</option><replaceable>directory</replaceable></arg>
<arg><option>--[no-]pristine-tar</option></arg>
<arg><option>--debian-branch=</option><replaceable>branch_name</replaceable></arg>
<arg><option>--upstream-branch=</option><replaceable>branch_name</replaceable></arg>
@@ -68,6 +69,15 @@
</listitem>
</varlistentry>
<varlistentry>
+ <term><option>--template-dir</option>=<replaceable>directory</replaceable>
+ </term>
+ <listitem>
+ <para>Template directory to pass to <command>git init</command> on the remote
+ side. This can be used to customize the remote repository, e.g. to set up hooks.
+ </para>
+ </listitem>
+ </varlistentry>
+ <varlistentry>
<term><option>--debian-branch</option>=<replaceable>branch_name</replaceable>
</term>
<listitem>
diff --git a/gbp/config.py b/gbp/config.py
index 909e8e73..c6805df2 100644
--- a/gbp/config.py
+++ b/gbp/config.py
@@ -124,7 +124,8 @@ class GbpOptionParser(OptionParser):
'submodules' : 'False',
'time-machine' : 1,
'pbuilder-autoconf' : 'True',
- 'pbuilder-options': ''
+ 'pbuilder-options': '',
+ 'template-dir': '',
}
help = {
'debian-branch':
@@ -208,6 +209,8 @@ class GbpOptionParser(OptionParser):
"Wheter to configure pbuilder automatically. Default is '%(pbuilder-autoconf)s'",
'pbuilder-options':
"Options to pass to pbuilder, default is '%(pbuilder-options)s'",
+ 'template-dir':
+ "Template directory used by git init, default is %(template-dir)s",
}
def_config_files = [ '/etc/git-buildpackage/gbp.conf',
diff --git a/gbp/scripts/create_remote_repo.py b/gbp/scripts/create_remote_repo.py
index 65e295fa..d1a36c63 100644
--- a/gbp/scripts/create_remote_repo.py
+++ b/gbp/scripts/create_remote_repo.py
@@ -1,6 +1,6 @@
# vim: set fileencoding=utf-8 :
#
-# (C) 2010 Guido Guenther <agx@sigxcpu.org>
+# (C) 2010,2012 Guido Günther <agx@sigxcpu.org>
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
@@ -16,9 +16,7 @@
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# Based on the aa-create-git-repo and dom-new-git-repo shell scripts
-
"""Create a remote repo based on the current one"""
-# TODO: allow to add hooks by default
import sys
import os, os.path
@@ -71,21 +69,21 @@ def sort_dict(d):
s.append((key, d[key]))
return s
-def parse_url(remote_url, name, pkg):
+def parse_url(remote_url, name, pkg, template_dir=None):
"""
Sanity check our remote URL
>>> sort_dict(parse_url("ssh://host/path/%(pkg)s", "origin", "package"))
- [('base', ''), ('dir', '/path/package'), ('host', 'host'), ('name', 'origin'), ('pkg', 'package'), ('port', None), ('scheme', 'ssh'), ('url', 'ssh://host/path/package')]
+ [('base', ''), ('dir', '/path/package'), ('host', 'host'), ('name', 'origin'), ('pkg', 'package'), ('port', None), ('scheme', 'ssh'), ('template-dir', None), ('url', 'ssh://host/path/package')]
>>> sort_dict(parse_url("ssh://host:22/path/repo.git", "origin", "package"))
- [('base', ''), ('dir', '/path/repo.git'), ('host', 'host'), ('name', 'origin'), ('pkg', 'package'), ('port', '22'), ('scheme', 'ssh'), ('url', 'ssh://host:22/path/repo.git')]
+ [('base', ''), ('dir', '/path/repo.git'), ('host', 'host'), ('name', 'origin'), ('pkg', 'package'), ('port', '22'), ('scheme', 'ssh'), ('template-dir', None), ('url', 'ssh://host:22/path/repo.git')]
>>> sort_dict(parse_url("ssh://host:22/~/path/%(pkg)s.git", "origin", "package"))
- [('base', '~/'), ('dir', 'path/package.git'), ('host', 'host'), ('name', 'origin'), ('pkg', 'package'), ('port', '22'), ('scheme', 'ssh'), ('url', 'ssh://host:22/~/path/package.git')]
+ [('base', '~/'), ('dir', 'path/package.git'), ('host', 'host'), ('name', 'origin'), ('pkg', 'package'), ('port', '22'), ('scheme', 'ssh'), ('template-dir', None), ('url', 'ssh://host:22/~/path/package.git')]
- >>> sort_dict(parse_url("ssh://host:22/~user/path/%(pkg)s.git", "origin", "package"))
- [('base', '~user/'), ('dir', 'path/package.git'), ('host', 'host'), ('name', 'origin'), ('pkg', 'package'), ('port', '22'), ('scheme', 'ssh'), ('url', 'ssh://host:22/~user/path/package.git')]
+ >>> sort_dict(parse_url("ssh://host:22/~user/path/%(pkg)s.git", "origin", "package", "/doesnot/exist"))
+ [('base', '~user/'), ('dir', 'path/package.git'), ('host', 'host'), ('name', 'origin'), ('pkg', 'package'), ('port', '22'), ('scheme', 'ssh'), ('template-dir', '/doesnot/exist'), ('url', 'ssh://host:22/~user/path/package.git')]
>>> parse_url("git://host/repo.git", "origin", "package")
Traceback (most recent call last):
@@ -138,7 +136,8 @@ def parse_url(remote_url, name, pkg):
'host': host,
'port': port,
'name': name,
- 'scheme': scheme }
+ 'scheme': scheme,
+ 'template-dir': template_dir}
return remote
@@ -146,10 +145,18 @@ def build_remote_script(remote):
"""
Create the script that will be run on the remote side
- >>> build_remote_script({'base': 'base', 'dir': 'dir', 'pkg': 'pkg'})
+ >>> build_remote_script({'base': 'base', 'dir': 'dir', 'pkg': 'pkg', 'template-dir': None})
'\\nset -e\\numask 002\\nif [ -d base"dir" ]; then\\n echo "Repository at "basedir" already exists - giving up."\\n exit 1\\nfi\\nmkdir -p base"dir"\\ncd base"dir"\\ngit init --bare --shared\\necho "pkg packaging" > description\\n'
+ >>> build_remote_script({'base': 'base', 'dir': 'dir', 'pkg': 'pkg', 'template-dir': '/doesnot/exist'})
+ '\\nset -e\\numask 002\\nif [ -d base"dir" ]; then\\n echo "Repository at "basedir" already exists - giving up."\\n exit 1\\nfi\\nmkdir -p base"dir"\\ncd base"dir"\\ngit init --bare --shared --template=/doesnot/exist\\necho "pkg packaging" > description\\n'
+
"""
- remote_script_pattern = ['',
+ remote = remote
+ remote['git-init-args'] = '--bare --shared'
+ if remote['template-dir']:
+ remote['git-init-args'] += (' --template=%s'
+ % remote['template-dir'])
+ remote_script_pattern = ['',
'set -e',
'umask 002',
'if [ -d %(base)s"%(dir)s" ]; then',
@@ -158,9 +165,9 @@ def build_remote_script(remote):
'fi',
'mkdir -p %(base)s"%(dir)s"',
'cd %(base)s"%(dir)s"',
- 'git init --bare --shared',
+ 'git init %(git-init-args)s',
'echo "%(pkg)s packaging" > description',
- '' ]
+ '' ]
remote_script = '\n'.join(remote_script_pattern) % remote
return remote_script
@@ -237,6 +244,7 @@ def main(argv):
parser.add_config_file_option(option_name="color", dest="color", type='tristate')
parser.add_option("--remote-name", dest="name", default="origin",
help="The name of the remote, default is 'origin'")
+ parser.add_config_file_option(option_name="template-dir", dest="template_dir")
(options, args) = parser.parse_args(argv)
gbp.log.setup(options.color, options.verbose)
@@ -268,7 +276,10 @@ def main(argv):
pkg = os.path.basename(os.path.abspath(os.path.curdir))
pkg = os.path.splitext(pkg)[0]
- remote = parse_url(options.remote_url, options.name, pkg)
+ remote = parse_url(options.remote_url,
+ options.name,
+ pkg,
+ options.template_dir)
if repo.has_remote_repo(options.name):
raise GbpError("You already have a remote name '%s' defined for this repository." % options.name)