[sysadmin-bin] Land post-receive-notify-l10n to notify l10n API endpoint it should rebuild stats for a specific mod



commit de9f9f5199804b9f147e892d45a1ff38d66ae815
Author: Andrea Veri <averi redhat com>
Date:   Fri Sep 13 14:39:08 2019 +0200

    Land post-receive-notify-l10n to notify l10n API endpoint it should rebuild stats for a specific module

 git/post-receive-notify-l10n | 34 ++++++++++++++++++++++++++++++++++
 1 file changed, 34 insertions(+)
---
diff --git a/git/post-receive-notify-l10n b/git/post-receive-notify-l10n
new file mode 100755
index 0000000..c4f07b9
--- /dev/null
+++ b/git/post-receive-notify-l10n
@@ -0,0 +1,34 @@
+#!/usr/bin/python
+
+import re
+import os
+import sys
+import requests
+
+script_path = os.path.realpath(os.path.abspath(sys.argv[0]))
+script_dir = os.path.dirname(script_path)
+
+sys.path.insert(0, script_dir)
+
+from git import get_module_name 
+
+BRANCH_RE = re.compile(r'^refs/heads/(.*)$')
+def get_branch_name(refname):
+    m = BRANCH_RE.match(refname)
+    if m:
+        return m.group(1)
+
+def main():
+    API_URL = 'https://l10n.gnome.org/api/v1/modules'
+
+    module_name = get_module_name()
+    branch_name = get_branch_name(sys.argv[3])
+
+    headers = {'User-Agent': 'post-receive-notify-l10n'}
+    try:
+        r = requests.post('%s/%s/branches/%s/ping' % (BASE_URL, module_name, branch_name), headers=headers)
+    except requests.exceptions.RequestException:    
+        pass
+
+if __name__ == '__main__':
+    main()


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]