From 289ff0c7007f4a1d56651e7fe45940919069d26f Mon Sep 17 00:00:00 2001 From: Lukas Fleischer Date: Thu, 1 Jan 2015 17:27:03 +0100 Subject: 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 --- scripts/git-integration/git-serve.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'scripts') diff --git a/scripts/git-integration/git-serve.py b/scripts/git-integration/git-serve.py index 64620a9..3669a73 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 Create an empty repository.\n" + " git-receive-pack Internal command used with Git.\n" + " git-upload-pack Internal command used with Git.") -- cgit v1.2.3-54-g00ecf