[neon-notifications] Changes in repo-metadata

Neon CI noreply at kde.org
Sat May 23 19:46:14 BST 2020


commit 7d348c9cb8bac66262e396dfdac35a69a7d98274
Author: Bhushan Shah <bhush94 at gmail.com>
Date:   Sat May 23 09:07:40 2020 +0530

    cleanup old helpers
    
    - we don't use gitolite anymore
    - we don't need migration script anymore

diff --git a/scripts/BuildGitolite.py b/scripts/BuildGitolite.py
deleted file mode 100755
index 47033d9d..00000000
--- a/scripts/BuildGitolite.py
+++ /dev/null
@@ -1,99 +0,0 @@
-#!/usr/bin/python3
-# Copyright 2016 Boudhayan Gupta <bgupta at kde.org>
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions
-# are met:
-#
-# 1. Redistributions of source code must retain the above copyright
-#    notice, this list of conditions and the following disclaimer.
-# 2. Redistributions in binary form must reproduce the above copyright
-#    notice, this list of conditions and the following disclaimer in the
-#    documentation and/or other materials provided with the distribution.
-# 3. Neither the name of KDE e.V. (or its successor approved by the
-#    membership of KDE e.V.) nor the names of its contributors may be used
-#    to endorse or promote products derived from this software without
-#    specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR
-# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
-# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
-# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
-# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
-# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
-# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-import os
-import sys
-import io
-import shutil
-import re
-import yaml
-
-def ProcessDirectory(buf, path):
-    # enter the directory and start processing
-    os.chdir(path)
-
-    # get the repo path and start working
-    if os.path.isfile("metadata.yaml"):
-        meta = None
-        with open("metadata.yaml") as f:
-            meta = yaml.load(f)
-
-        if meta["hasrepo"]:
-            repopath = meta["repopath"]
-            name = repopath.split("/")[-1]
-            desc = meta["description"]
-            desc = re.sub('\!.+\!', "", desc).strip()
-            if "\n" in desc:
-                desc = desc.split("\n")[0].strip()
-
-            buf.write("repo {0}\n".format(repopath))
-            buf.write("    desc = \"{1}\"\n".format(repopath, desc))
-
-            if repopath.endswith("-history"):
-                buf.write("    R    = @all\n")
-            elif not "/" in repopath:
-                buf.write("    RWCD = @all\n")
-            elif repopath.startswith("sysadmin"):
-                buf.write("    RWCD = @sysadmins\n")
-                buf.write("    R    = @all\n")
-            elif repopath.startswith("websites"):
-                buf.write("    RWCD = @www @sysadmins\n")
-                buf.write("    R    = @all\n")
-            elif repopath.startswith("other"):
-                buf.write("    RWCD = @sysadmins\n")
-                buf.write("    RWC  = @all\n")
-            else:
-                print("error: unrecognized repo path: {0}".format(repopath))
-                sys.exit(1)
-
-            buf.write("\n")
-
-    # recurse into subdirectories
-    for entry in sorted(os.listdir(".")):
-        if os.path.isdir(entry):
-            ProcessDirectory(buf, entry)
-
-    # done
-    os.chdir("..")
-
-if __name__ == "__main__":
-
-    # build the buffer
-    buf = io.StringIO()
-
-    # walk through the project hierarchy
-    os.chdir("projects")
-    for entry in sorted(os.listdir(".")):
-        ProcessDirectory(buf, entry)
-    os.chdir("..")
-
-    # write it to a file
-    fname = "output/gitolite.conf"
-    with open(fname, "w", encoding = "utf-8") as f:
-        buf.seek(0)
-        shutil.copyfileobj(buf, f)
diff --git a/scripts/MigrateToInventStructure.py b/scripts/MigrateToInventStructure.py
deleted file mode 100644
index 5a836230..00000000
--- a/scripts/MigrateToInventStructure.py
+++ /dev/null
@@ -1,58 +0,0 @@
-#!/usr/bin/python3
-import os
-import sys
-import yaml
-import argparse
-
-# Gather the command line arguments we need
-parser = argparse.ArgumentParser(description='Migration utility for KDE Repository Metadata')
-parser.add_argument('--metadata-path', help='Path to the metadata we are updating', required=True)
-args = parser.parse_args()
-
-# Make sure our configuration file exists
-if not os.path.exists( args.metadata_path ):
-    print("Unable to locate specified metadata location: %s".format(args.metadata_path))
-    sys.exit(1)
-
-# Start going over the location in question...
-for currentPath, subdirectories, filesInFolder in os.walk( args.metadata_path, topdown=False, followlinks=False ):
-    # Determine the location the repository will be at in Gitlab
-    gitlabLocation = currentPath[len(args.metadata_path):]
-    print("== Working on: " + currentPath)
-
-    # Do we have a metadata.yaml file?
-    if 'metadata.yaml' not in filesInFolder:
-        # We're not interested then....
-        continue
-
-    # Now that we know we have something to work with....
-    # Lets load the current metadata up
-    metadataPath = os.path.join( currentPath, 'metadata.yaml' )
-    metadataFile = open( metadataPath, 'r' )
-    metadata = yaml.load( metadataFile )
-
-    # Now we need to clean it up!
-    # 'icon' serves no purpose
-    del metadata['icon']
-    # 'members' doesn't have a purpose either
-    del metadata['members']
-    # 'type' is also redundant now
-    del metadata['type']
-
-    # With the cleanup done, add the new 'identifier' item
-    # As we have a handful of items in prefixes (like sysadmin/ and websites/) we replaces slashes with dashes for safety purposes
-    if metadata['repopath'] is not None:
-        metadata['identifier'] = metadata['repopath'].replace('/', '-')
-    else:
-        metadata['identifier'] = None
-
-    # Finally, we transform the 'repopath' to match what it will be on Gitlab
-    metadata['repopath'] = gitlabLocation
-
-    # Now we can write it out!
-    with open(metadataPath, 'w') as output:
-        yaml.dump( metadata, output, default_flow_style=False)
-
-# All done!
-sys.exit(0)
-

commit 65ca301cf09c02d2dc2d2f324a1ea18e6a4dd1bc
Author: Bhushan Shah <bhush94 at gmail.com>
Date:   Sat May 23 09:44:21 2020 +0530

    test that the name in metadata have valid characters
    
    Thanks Carson Black for help!

diff --git a/verify-repo-metadata.py b/verify-repo-metadata.py
index 0ffcb1ea..bd3e34e3 100755
--- a/verify-repo-metadata.py
+++ b/verify-repo-metadata.py
@@ -4,6 +4,7 @@ import sys
 import yaml
 import argparse
 import gitlab
+import re
 
 # Gather the command line arguments we need
 parser = argparse.ArgumentParser(description='Verifies the metadata files')
@@ -18,6 +19,9 @@ if not os.path.exists( args.metadata_path ):
 # Connect to invent.kde.org instance
 gl = gitlab.Gitlab("https://invent.kde.org")
 
+# Regular expresssion to match if name includes anything other than supported
+reg = re.compile('^[a-zA-Z0-9_]([a-z]|[A-Z]|[0-9]|_|-| |\.*)')
+
 # Start going over the location in question...
 for currentPath, subdirectories, filesInFolder in os.walk( args.metadata_path, topdown=False, followlinks=False ):
     # Do we have a metadata.yaml file?
@@ -41,6 +45,11 @@ for currentPath, subdirectories, filesInFolder in os.walk( args.metadata_path, t
     if metadata['description'] is not None and len(metadata['description']) == 0:
         print("Empty description in the " + currentPath)
 
+    # Check if name have supported characters only
+    if not reg.match(metadata['name']):
+        print("Metadata contains the invalid characters in name " + currentPath)
+        print(metadata['name'])
+
     # Make sure that identifier is not empty
     identifier = metadata.get('identifier')
     if identifier is None:



More information about the neon-notifications mailing list