diff options
author | Lukas Fleischer <lfleischer@archlinux.org> | 2015-11-10 20:18:13 +0100 |
---|---|---|
committer | Lukas Fleischer <lfleischer@archlinux.org> | 2016-02-07 10:54:20 +0100 |
commit | 64072461dfcc74857087b23c9ba7d9812b6afe40 (patch) | |
tree | 753980782ed91c694fe583495627a5dc8b8b7f4b /git-interface | |
parent | aa5e58db81b8a243e03d0f08925c2d1f34c82304 (diff) |
Add support for package update notifications
Introduce a new notification option to receive notifications when a new
commit is pushed to a package repository.
Implements FS#30109.
Signed-off-by: Lukas Fleischer <lfleischer@archlinux.org>
Diffstat (limited to 'git-interface')
-rwxr-xr-x | git-interface/git-update.py | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/git-interface/git-update.py b/git-interface/git-update.py index 3b587b3..e54e0e6 100755 --- a/git-interface/git-update.py +++ b/git-interface/git-update.py @@ -5,6 +5,7 @@ import mysql.connector import os import pygit2 import re +import subprocess import sys import srcinfo.parse @@ -19,6 +20,8 @@ aur_db_user = config.get('database', 'user') aur_db_pass = config.get('database', 'password') aur_db_socket = config.get('database', 'socket') +notify_cmd = config.get('notifications', 'notify-cmd') + repo_path = config.get('serve', 'repo-path') repo_regex = config.get('serve', 'repo-regex') @@ -169,6 +172,13 @@ def save_metadata(metadata, db, cur, user): db.commit() +def update_notify(db, cur, user, pkgbase_id): + # Obtain the user ID of the new maintainer. + cur.execute("SELECT ID FROM Users WHERE Username = %s", [user]) + user_id = int(cur.fetchone()[0]) + + # Execute the notification script. + subprocess.Popen((notify_cmd, 'update', str(user_id), str(pkgbase_id))) def die(msg): sys.stderr.write("error: {:s}\n".format(msg)) @@ -336,8 +346,6 @@ for pkgname in srcinfo.utils.get_package_names(metadata): # Store package base details in the database. save_metadata(metadata, 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) @@ -347,3 +355,9 @@ repo.create_reference('refs/heads/' + pkgbase, sha1_new, True) # 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) + +# Send package update notifications. +update_notify(db, cur, user, pkgbase_id) + +# Close the database. +db.close() |