From fa5aa361af0fd11e6fcf2148045166821f15477d Mon Sep 17 00:00:00 2001 From: Magnus Hagander Date: Wed, 18 Sep 2019 10:36:13 +0200 Subject: [PATCH] Delete users/ssh keys when removed upstream Existing code would only update changed users, but if the ssh key was actually removed upstream the old one would be kept around. --- keysync.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/keysync.py b/keysync.py index 62eb0e1..5717300 100644 --- a/keysync.py +++ b/keysync.py @@ -56,6 +56,10 @@ class KeySynchronizer(object): 'key': u['s'], }) + # Delete any keys that no longer exist upstream + curs.execute("DELETE FROM git_users WHERE NOT userid=ANY(%(userids)s)", { + 'userids': [u['u'] for u in j], + }) # Flag our last sync time curs.execute("UPDATE key_last_sync SET lastsync=%s", [synctime]) -- 2.39.5