mirror of
https://gitlab.archlinux.org/archlinux/aurweb.git
synced 2025-02-03 10:43:03 +01:00
Setup Git repositories even if package base exists
Sometimes, we need to initialize the Git repository even if the package base already exists (e.g. when using a non-empty package database with empty repositories during the AUR 4.0.0 migration period). Make sure that the package branch and the namespaced HEAD ref is always created. Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
This commit is contained in:
parent
124ad00997
commit
6fe8792508
1 changed files with 17 additions and 7 deletions
|
@ -52,7 +52,7 @@ def list_repos(user):
|
||||||
print((' ' if row[1] else '*') + row[0])
|
print((' ' if row[1] else '*') + row[0])
|
||||||
db.close()
|
db.close()
|
||||||
|
|
||||||
def setup_repo(pkgbase, user):
|
def create_pkgbase(pkgbase, user):
|
||||||
if not re.match(repo_regex, pkgbase):
|
if not re.match(repo_regex, pkgbase):
|
||||||
die('%s: invalid repository name: %s' % (action, pkgbase))
|
die('%s: invalid repository name: %s' % (action, pkgbase))
|
||||||
if pkgbase_exists(pkgbase):
|
if pkgbase_exists(pkgbase):
|
||||||
|
@ -79,11 +79,20 @@ def setup_repo(pkgbase, user):
|
||||||
db.commit()
|
db.commit()
|
||||||
db.close()
|
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)
|
repo = pygit2.Repository(repo_path)
|
||||||
repo.create_reference('refs/heads/' + pkgbase,
|
refs = repo.listall_references()
|
||||||
'refs/namespaces/' + pkgbase + '/refs/heads/master')
|
|
||||||
repo.create_reference('refs/namespaces/' + pkgbase + '/HEAD',
|
if not 'refs/heads/' + pkgbase in refs:
|
||||||
'refs/namespaces/' + pkgbase + '/refs/heads/master')
|
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):
|
def check_permissions(pkgbase, user):
|
||||||
db = mysql.connector.connect(host=aur_db_host, user=aur_db_user,
|
db = mysql.connector.connect(host=aur_db_host, user=aur_db_user,
|
||||||
|
@ -130,7 +139,8 @@ if action == 'git-upload-pack' or action == 'git-receive-pack':
|
||||||
die('%s: invalid repository name: %s' % (action, repo))
|
die('%s: invalid repository name: %s' % (action, repo))
|
||||||
|
|
||||||
if not pkgbase_exists(pkgbase):
|
if not pkgbase_exists(pkgbase):
|
||||||
setup_repo(pkgbase, user)
|
create_pkgbase(pkgbase, user)
|
||||||
|
setup_repo(pkgbase);
|
||||||
|
|
||||||
if action == 'git-receive-pack':
|
if action == 'git-receive-pack':
|
||||||
if not check_permissions(pkgbase, user):
|
if not check_permissions(pkgbase, user):
|
||||||
|
@ -150,7 +160,7 @@ elif action == 'setup-repo':
|
||||||
die_with_help("%s: missing repository name" % (action))
|
die_with_help("%s: missing repository name" % (action))
|
||||||
if len(cmdargv) > 2:
|
if len(cmdargv) > 2:
|
||||||
die_with_help("%s: too many arguments" % (action))
|
die_with_help("%s: too many arguments" % (action))
|
||||||
setup_repo(cmdargv[1], user)
|
create_pkgbase(cmdargv[1], user)
|
||||||
elif action == 'help':
|
elif action == 'help':
|
||||||
die("Commands:\n" +
|
die("Commands:\n" +
|
||||||
" help Show this help message and exit.\n" +
|
" help Show this help message and exit.\n" +
|
||||||
|
|
Loading…
Add table
Reference in a new issue