summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukas Fleischer <lfleischer@archlinux.org>2015-06-11 13:58:43 +0200
committerLukas Fleischer <lfleischer@archlinux.org>2015-06-11 14:03:56 +0200
commit2164750f1e951c6985b3f9c29663bf94d16553e7 (patch)
treebb07b18cad23390248f5f0151e7a48578b025e64
parentbd9af5f8931c6ec2e282dda825c51bcdc7d4aa68 (diff)
downloadaurweb-2164750f1e951c6985b3f9c29663bf94d16553e7.tar.xz
Do not use symrefs for manually created Git refs
When creating the refs for the package base branch and the HEAD ref workaround, directly use commit IDs instead of symrefs. It looks like Git cannot pack symrefs, so this is expected to improve space efficiency. Also, since the refs are now only created (or updated) when new objects are actually received, this fixes a problem with dangling refs that were created when a user initialized a repository but did not push anything. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
-rwxr-xr-xgit-interface/git-serve.py17
-rwxr-xr-xgit-interface/git-update.py10
2 files changed, 10 insertions, 17 deletions
diff --git a/git-interface/git-serve.py b/git-interface/git-serve.py
index cfd3e34..9812acb 100755
--- a/git-interface/git-serve.py
+++ b/git-interface/git-serve.py
@@ -3,7 +3,6 @@
import configparser
import mysql.connector
import os
-import pygit2
import re
import shlex
import sys
@@ -78,21 +77,6 @@ def create_pkgbase(pkgbase, user):
db.commit()
db.close()
-def setup_repo(pkgbase):
- if not re.match(repo_regex, pkgbase):
- die('%s: invalid repository name: %s' % (action, pkgbase))
-
- repo = pygit2.Repository(repo_path)
- refs = repo.listall_references()
-
- if not 'refs/heads/' + pkgbase in refs:
- repo.create_reference('refs/heads/' + pkgbase, 'refs/namespaces/' +
- pkgbase + '/refs/heads/master')
- if not 'refs/namespaces/' + pkgbase + '/HEAD' in refs:
- repo.create_reference('refs/namespaces/' + pkgbase + '/HEAD',
- 'refs/namespaces/' + pkgbase +
- '/refs/heads/master')
-
def check_permissions(pkgbase, user):
db = mysql.connector.connect(host=aur_db_host, user=aur_db_user,
passwd=aur_db_pass, db=aur_db_name,
@@ -139,7 +123,6 @@ if action == 'git-upload-pack' or action == 'git-receive-pack':
if not pkgbase_exists(pkgbase):
create_pkgbase(pkgbase, user)
- setup_repo(pkgbase);
if action == 'git-receive-pack':
if not check_permissions(pkgbase, user):
diff --git a/git-interface/git-update.py b/git-interface/git-update.py
index 958fa7a..7898f39 100755
--- a/git-interface/git-update.py
+++ b/git-interface/git-update.py
@@ -285,3 +285,13 @@ for pkgname in srcinfo.GetPackageNames():
save_srcinfo(srcinfo, db, cur, user)
db.close()
+
+# Create (or update) a branch with the name of the package base for better
+# accessibility.
+repo.create_reference('refs/heads/' + pkgbase, sha1_new, True)
+
+# Work around a Git bug: The HEAD ref is not updated when using gitnamespaces.
+# This can be removed once the bug fix is included in Git mainline. See
+# http://git.661346.n2.nabble.com/PATCH-receive-pack-Create-a-HEAD-ref-for-ref-namespace-td7632149.html
+# for details.
+repo.create_reference('refs/namespaces/' + pkgbase + '/HEAD', sha1_new, True)