summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorLukas Fleischer <archlinux@cryptocrack.de>2015-01-01 17:27:03 +0100
committerLukas Fleischer <archlinux@cryptocrack.de>2015-01-01 17:29:29 +0100
commit289ff0c7007f4a1d56651e7fe45940919069d26f (patch)
treeb056c3f7eff517fc0f3aebb2564cdb89ce892f8d /scripts
parent1b627a3f0b5a51b54f38d9f0f668668b29fc0022 (diff)
downloadaur-289ff0c7007f4a1d56651e7fe45940919069d26f.tar.gz
aur-289ff0c7007f4a1d56651e7fe45940919069d26f.tar.xz
git-serve.py: Add a command to list repositories
The list-repos command now lists all repositories you maintain. Empty repositories are prefixed with an asterisk. Implements FS#43288. Signed-off-by: Lukas Fleischer <archlinux@cryptocrack.de>
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/git-integration/git-serve.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/scripts/git-integration/git-serve.py b/scripts/git-integration/git-serve.py
index 64620a9d..3669a737 100755
--- a/scripts/git-integration/git-serve.py
+++ b/scripts/git-integration/git-serve.py
@@ -37,6 +37,23 @@ def repo_path_get_pkgbase(path):
pkgbase = pkgbase[:-4]
return pkgbase
+def list_repos(user):
+ db = mysql.connector.connect(host=aur_db_host, user=aur_db_user,
+ passwd=aur_db_pass, db=aur_db_name,
+ unix_socket=aur_db_socket)
+ cur = db.cursor()
+
+ cur.execute("SELECT ID FROM Users WHERE Username = %s ", [user])
+ userid = cur.fetchone()[0]
+ if userid == 0:
+ die('%s: unknown user: %s' % (action, user))
+
+ cur.execute("SELECT Name, PackagerUID FROM PackageBases " +
+ "WHERE MaintainerUID = %s ", [userid])
+ for row in cur:
+ print((' ' if row[1] else '*') + row[0])
+ db.close()
+
def setup_repo(repo, user):
if not re.match(repo_regex, repo):
die('%s: invalid repository name: %s' % (action, repo))
@@ -107,6 +124,10 @@ if action == 'git-upload-pack' or action == 'git-receive-pack':
os.environ["AUR_PKGBASE"] = pkgbase
cmd = action + " '" + path + "'"
os.execl(git_shell_cmd, git_shell_cmd, '-c', cmd)
+elif action == 'list-repos':
+ if len(cmdargv) > 1:
+ die_with_help("%s: too many arguments" % (action))
+ list_repos(user)
elif action == 'setup-repo':
if len(cmdargv) < 2:
die_with_help("%s: missing repository name" % (action))
@@ -116,6 +137,7 @@ elif action == 'setup-repo':
elif action == 'help':
die("Commands:\n" +
" help Show this help message and exit.\n" +
+ " list-repos List all your repositories.\n" +
" setup-repo <name> Create an empty repository.\n" +
" git-receive-pack Internal command used with Git.\n" +
" git-upload-pack Internal command used with Git.")