diff options
author | Tommi Virtanen <tv@eagain.net> | 2007-08-30 20:00:15 -0700 |
---|---|---|
committer | Tommi Virtanen <tv@eagain.net> | 2007-08-30 20:03:17 -0700 |
commit | 5655b7f517a46fc1177a3e9007ab56b36a6d8e0c (patch) | |
tree | 07305ea591f10edd80f4ccc9f5c85e1e9d22d24e /gitosis/repository.py | |
parent | Refactor unit test writeFile/readFile helpers. (diff) | |
download | gitosis-dakkar-5655b7f517a46fc1177a3e9007ab56b36a6d8e0c.tar.gz gitosis-dakkar-5655b7f517a46fc1177a3e9007ab56b36a6d8e0c.tar.bz2 gitosis-dakkar-5655b7f517a46fc1177a3e9007ab56b36a6d8e0c.zip |
Add helper to create (bare) repositories with custom templates.
Diffstat (limited to 'gitosis/repository.py')
-rw-r--r-- | gitosis/repository.py | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/gitosis/repository.py b/gitosis/repository.py new file mode 100644 index 0000000..ea8db54 --- /dev/null +++ b/gitosis/repository.py @@ -0,0 +1,39 @@ +import errno +import os +import subprocess + +def _mkdir(*a, **kw): + try: + os.mkdir(*a, **kw) + except OSError, e: + if e.errno == errno.EEXIST: + pass + else: + raise + +def init( + path, + template=None, + _git=None, + ): + if _git is None: + _git = 'git' + + _mkdir(path, 0750) + args = [_git, 'init'] + if template is not None: + args.append('--template=%s' % template) + env = {} + env.update(os.environ) + env['GIT_DIR'] = '.' + returncode = subprocess.call( + args=args, + cwd=path, + close_fds=True, + env=env, + ) + if returncode != 0: + raise RuntimeError( + ("Command '%r' returned non-zero exit status %d" + % (args, returncode)), + ) |