[sysadmin-bin] git.gnome.org is no more and has been replaced by gitlab, drop if statements



commit ee93aa31c03f131a0efc2c4f612fc42e47b71869
Author: Andrea Veri <averi redhat com>
Date:   Wed Sep 12 14:28:00 2018 +0200

    git.gnome.org is no more and has been replaced by gitlab, drop if statements

 create-auth                  |  2 +-
 git/gnome-post-receive-email | 58 +++++++++++++-------------------------------
 2 files changed, 18 insertions(+), 42 deletions(-)
---
diff --git a/create-auth b/create-auth
index 6fb88a7..332ec69 100755
--- a/create-auth
+++ b/create-auth
@@ -397,7 +397,7 @@ def create_directory_structure (user_data):
             os.chown (user_dir_name, 0, 0)
             shutil.copy2('/root/.ssh/authorized_keys', authorized_keys_file)
 
-        if socket.gethostname() in ('gitlab.gnome.org', 'gitlab-test.gnome.org'):
+        if socket.gethostname() == 'gitlab.gnome.org':
            user_dir_name = users_directory_name + "/git"
            authorized_keys_file = user_dir_name + "/authorized_keys"
            os.mkdir (user_dir_name, 0700)
diff --git a/git/gnome-post-receive-email b/git/gnome-post-receive-email
index 1e512a3..6daa61c 100755
--- a/git/gnome-post-receive-email
+++ b/git/gnome-post-receive-email
@@ -33,16 +33,14 @@ import re
 import os
 import pwd
 import sys
-import socket
 from email import Header
 
 
-if socket.gethostname() == 'gitlab.gnome.org':
-    import gitlab
+import gitlab
 
-    execfile('/home/admin/secret/gitlab_ro')
+execfile('/home/admin/secret/gitlab_ro')
 
-    gl = gitlab.Gitlab('https://gitlab.gnome.org', GITLAB_PRIVATE_RO_TOKEN, api_version=4)
+gl = gitlab.Gitlab('https://gitlab.gnome.org', GITLAB_PRIVATE_RO_TOKEN, api_version=4)
 
 script_path = os.path.realpath(os.path.abspath(sys.argv[0]))
 script_dir = os.path.dirname(script_path)
@@ -128,10 +126,7 @@ class RefChange(object):
         if user_fullname:
             from_address = "%s <%s src gnome org>" % (Header.Header(user_fullname.decode('utf-8')), 
user_entry)
         else:
-            if socket.gethostname() == 'gitlab.gnome.org':
-                from_address = "%s <%s>" % (Header.Header(gitlab_name), gitlab_email)
-            else:
-                from_address = "%s src gnome org" % (user_entry)
+            from_address = "%s <%s>" % (Header.Header(gitlab_name), gitlab_email)
 
         if cc is None:
             cc = self.cc
@@ -948,42 +943,23 @@ def main():
     if not recipients:
         sys.exit(1)
 
-    if socket.gethostname() == 'gitlab.gnome.org':
-       user = os.environ['GL_USERNAME']
-        user = gl.users.list(username='%s' % user)
-       user = user[0]
+    user = os.environ['GL_USERNAME']
+    user = gl.users.list(username='%s' % user)
+    user = user[0]
 
-        if len(user.attributes['identities']) > 0:
-           for index, _ in enumerate(user.attributes['identities']):
-               provider = user.attributes['identities'][index]['provider']
-               if provider == 'ldapmain':
-                   username = 
user.attributes['identities'][index]['extern_uid'].split(',')[0].replace('uid=', '')
+    if len(user.attributes['identities']) > 0:
+        for index, _ in enumerate(user.attributes['identities']):
+            provider = user.attributes['identities'][index]['provider']
+            if provider == 'ldapmain':
+                username = user.attributes['identities'][index]['extern_uid'].split(',')[0].replace('uid=', 
'')
 
-                   user_fullname = user.attributes['name']
-                   user_fullname = user_fullname.encode('utf-8')
+                user_fullname = user.attributes['name']
+                user_fullname = user_fullname.encode('utf-8')
 
-                   user_entry = username
+                user_entry = username
 
-        gitlab_name  = user.attributes['name']
-        gitlab_email = user.attributes['email']
-    else:
-        # Figure out a human-readable username
-        try:
-           entry = pwd.getpwuid(os.getuid())
-           gecos = entry.pw_gecos
-       except:
-           gecos = None
-
-       if gecos != None:
-           # Typical GNOME account have John Doe <john doe example com> for the GECOS.
-           # Comma-separated fields are also possible
-           m = re.match("([^,<]+)", gecos)
-           if m:
-               fullname = m.group(1).strip()
-               if fullname != "":
-                   user_fullname = fullname
-
-        user_entry = os.environ['USER']
+    gitlab_name  = user.attributes['name']
+    gitlab_email = user.attributes['email']
 
     changes = []
 


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