summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Franke <nobody@nowhere.ws>2015-08-29 16:21:06 +0200
committerChristian Franke <nobody@nowhere.ws>2015-08-29 16:21:06 +0200
commite700080ec2bbc3e65b470b2401b2aebead0af3cd (patch)
tree17503a3ccbf23fa2064f3a7a8eb4dd2cee9446ff
parentd499c58345edf473e2ef34b8135b9da22d1f8691 (diff)
Commit the cgitrc into the repo
-rw-r--r--backend/repo_service.py30
1 files changed, 22 insertions, 8 deletions
diff --git a/backend/repo_service.py b/backend/repo_service.py
index 037d324..dfdc112 100644
--- a/backend/repo_service.py
+++ b/backend/repo_service.py
@@ -60,13 +60,6 @@ def gitolite_append(repo_owner, repo_name, repo_desc):
syslog.syslog('could not append to repo_service.conf: %s' % repr(e))
raise GitException
- git_call(['git', 'add', filename], cwd=repo_dir)
- git_call(['git', 'commit',
- '--author=Repo Service <repo_service@localhost>',
- '--message=repo_service: create %s for %s' % (repo_name, repo_owner)],
- cwd=repo_dir)
- git_call(['git', 'push', repo_git, 'master:master'], cwd=repo_dir)
-
def cgit_append(repo_owner, repo_name, repo_desc):
repo_date = time.strftime('%a, %d %b %Y %T %z')
cgit_entry = '''
@@ -74,7 +67,7 @@ def cgit_append(repo_owner, repo_name, repo_desc):
# at %(repo_date)s
# for %(repo_owner)s
repo.url=%(repo_name)s
-repo.path=/var/lib/git/repositories/%(repo_name)s.git
+repo.path=/var/lib/gitolite/repositories/%(repo_name)s.git
repo.desc=%(repo_desc)s
repo.owner=repo-service
''' % locals()
@@ -82,6 +75,21 @@ repo.owner=repo-service
with open(cgit_conf, 'a') as cgit_config:
cgit_config.write(cgit_entry)
+def gitolite_commit(repo_owner, repo_name):
+ filename = os.path.join(repo_dir, 'conf', 'repo_service.conf')
+ cgit_copy = os.path.join(repo_dir, 'conf', 'cgitrc.repo_service')
+ with open(cgit_conf, 'r') as input_file:
+ with open(cgit_copy, 'w') as output_file:
+ output_file.write(input_file.read())
+
+ git_call(['git', 'add', filename, cgit_copy], cwd=repo_dir)
+ git_call(['git', 'commit',
+ '--author=Repo Service <repo_service@localhost>',
+ '--message=repo_service: create %s for %s' % (repo_name, repo_owner)],
+ cwd=repo_dir)
+ git_call(['git', 'push', repo_git, 'master:master'], cwd=repo_dir)
+
+
def create_repo(repo_owner, repo_name, repo_desc):
if repo_name_re.match(repo_name) is None:
syslog.syslog('Declined repo_name %s to %s' % (
@@ -110,6 +118,12 @@ def create_repo(repo_owner, repo_name, repo_desc):
syslog.syslog('cgit_append failed')
return 'ERROR_CGIT'
+ try:
+ gitolite_commit(repo_owner, repo_name)
+ except GitException:
+ syslog.syslog('git commit failed')
+ return 'ERROR_GITOLITE'
+
syslog.syslog('created repo %s' % repo_name)
return 'SUCCESS'