diff options
author | Sebastian Pipping <sebastian@pipping.org> | 2010-11-07 05:01:24 +0100 |
---|---|---|
committer | Sebastian Pipping <sebastian@pipping.org> | 2010-11-07 05:01:47 +0100 |
commit | 53cb1cc0ff1170a5180e30e7c202644063b9ce7b (patch) | |
tree | b173cadfab9fa1a5f853e71b02abb9ac38502b6c | |
parent | Move gitosis code into place of future gitolite code (diff) | |
download | repositories-xml-format-53cb1cc0ff1170a5180e30e7c202644063b9ce7b.tar.gz repositories-xml-format-53cb1cc0ff1170a5180e30e7c202644063b9ce7b.tar.bz2 repositories-xml-format-53cb1cc0ff1170a5180e30e7c202644063b9ce7b.zip |
Migrate overlay differ from gitosis to gitolite
-rwxr-xr-x | diff-gitolite-conf-against-repositories-xml | 4 | ||||
-rwxr-xr-x | modules/laymandbtools/gitoliteextractor.py | 76 |
2 files changed, 40 insertions, 40 deletions
diff --git a/diff-gitolite-conf-against-repositories-xml b/diff-gitolite-conf-against-repositories-xml index 73bf925..ac1f494 100755 --- a/diff-gitolite-conf-against-repositories-xml +++ b/diff-gitolite-conf-against-repositories-xml @@ -14,6 +14,4 @@ def add_module_path(): sys.path.insert(0, os.path.join(self_dir, 'modules')) add_module_path() -from laymandbtools.gitoliteextractor import main - -main() +import laymandbtools.gitoliteextractor
\ No newline at end of file diff --git a/modules/laymandbtools/gitoliteextractor.py b/modules/laymandbtools/gitoliteextractor.py index 2546089..a952bfc 100755 --- a/modules/laymandbtools/gitoliteextractor.py +++ b/modules/laymandbtools/gitoliteextractor.py @@ -5,7 +5,7 @@ import sys from optparse import OptionParser -USAGE = 'Usage: %prog [--fixes-only] foo/gitosis.conf bar/repositories.xml [baz/extended.xml]' +USAGE = 'Usage: %prog [--fixes-only] conf/user.conf conf/proj.conf bar/repositories.xml [baz/extended.xml]' parser = OptionParser(usage=USAGE) parser.add_option('--fixes-only', dest = 'fixes_only', @@ -13,21 +13,22 @@ parser.add_option('--fixes-only', action = 'store_true', help = 'do not add entries that are missing completely') (opts, args) = parser.parse_args() -if len(args) not in (3, 2): +if len(args) not in (3, 4): parser.print_help() sys.exit(1) -gitosis_conf_location = args[0] -repositories_xml_location = args[1] -extended_xml_location = (len(args) == 3) and args[2] or None +gitolite_conf_locations = args[0:2] +repositories_xml_location = args[2] +extended_xml_location = (len(args) == 4) and args[3] or None import xml.etree.ElementTree as ET from ConfigParser import ConfigParser import re from layman.dbtools.sharedutils import * # local +from laymandbtools.gitoliteparser import RepoDatabase -# From gitosis.conf +# From gitolite config # ..to repositories.xml repo_name_mapping = { 'ruby-overlay':'ruby', @@ -46,17 +47,17 @@ def sort_as_in(elements, tag_order): return list(v for _, v in deco_sorted) class ChangeLog: - def __init__(self, gitosis_repo_name, is_new): + def __init__(self, gitolite_repo_name, is_new): self.empty = True - self.gitosis_repo_name = gitosis_repo_name + self.gitolite_repo_name = gitolite_repo_name self.is_new = is_new def log(self, kind, details): if self.empty: if self.is_new: - print 'Repo "%s" missing completely' % self.gitosis_repo_name + print 'Repo "%s" missing completely' % self.gitolite_repo_name else: - print 'Analyzing repo "%s":' % self.gitosis_repo_name + print 'Analyzing repo "%s":' % self.gitolite_repo_name self.empty = False if not self.is_new: @@ -67,8 +68,10 @@ OWNER_REGEX = re.compile('^([^<]+) (?:\([^)]+\) )?<([^ ]+@[^ ]+)>$') NOT_AN_OVERLAY_MESSAGE = 'Skipping %s (not an overlay)' -gitosis_conf = ConfigParser() -gitosis_conf.read(gitosis_conf_location) +gitolite_conf = RepoDatabase() +for filename in gitolite_conf_locations: + gitolite_conf.feed(filename) + a = ET.parse(open(repositories_xml_location)) repositories = a.getroot() @@ -85,29 +88,29 @@ assert oct_string_to_int('0713') == 0713 assert oct_string_to_int('103') == 0103 -GLOBAL_DIRMODE = oct_string_to_int(gitosis_conf.get('gitosis', 'dirmode')) -GLOBAL_GITWEB = gitosis_conf.getboolean('gitosis', 'gitweb') +# GLOBAL_DIRMODE = oct_string_to_int(gitosis_conf.get('gitosis', 'dirmode')) +# GLOBAL_GITWEB = gitosis_conf.getboolean('gitosis', 'gitweb') def is_public(section_name): - local_dirmode = GLOBAL_DIRMODE - if gitosis_conf.has_option(section_name, 'dirmode'): - local_dirmode = oct_string_to_int(gitosis_conf.get(section_name, 'dirmode')) + #local_dirmode = GLOBAL_DIRMODE + #if gitosis_conf.has_option(section_name, 'dirmode'): + # local_dirmode = oct_string_to_int(gitosis_conf.get(section_name, 'dirmode')) - local_gitweb = GLOBAL_GITWEB - if gitosis_conf.has_option(section_name, 'gitweb'): - local_gitweb = gitosis_conf.getboolean(section_name, 'gitweb') + #local_gitweb = GLOBAL_GITWEB + #if gitosis_conf.has_option(section_name, 'gitweb'): + # local_gitweb = gitosis_conf.getboolean(section_name, 'gitweb') - return ((local_dirmode & 0005) == 0005) and local_gitweb + return True # ((local_dirmode & 0005) == 0005) and local_gitweb -for section_name in gitosis_conf.sections(): - if section_name.startswith('repo '): - _repo_base = section_name[len('repo '):].strip() +for section_name in gitolite_conf.names(): + if True: + _repo_base = section_name try: - owner_part, gitosis_repo_name = _repo_base.split('/') + owner_part, gitolite_repo_name = _repo_base.split('/') except (ValueError) as e: - # TODO print NOT_AN_OVERLAY_MESSAGE % gitosis_repo_name + # TODO print NOT_AN_OVERLAY_MESSAGE % gitolite_repo_name continue if owner_part == 'proj': @@ -115,31 +118,30 @@ for section_name in gitosis_conf.sections(): elif owner_part in ('dev', 'user'): owner_type = "person" else: - # TODO print NOT_AN_OVERLAY_MESSAGE % gitosis_repo_name + # TODO print NOT_AN_OVERLAY_MESSAGE % gitolite_repo_name continue - _description = gitosis_conf.get(section_name, 'description') + terms_status, is_overlay, dont_add_to_layman, owner_contact, _description = gitolite_conf.data(section_name) - if gitosis_conf.has_option(section_name, 'gentoo-dont-add-to-layman'): + if dont_add_to_layman: continue overlay_status_clear = False - if gitosis_conf.has_option(section_name, 'gentoo-is-overlay'): - is_overlay = gitosis_conf.getboolean(section_name, 'gentoo-is-overlay') + if not is_overlay is None: if not is_overlay: continue overlay_status_clear = True if not overlay_status_clear \ - and not gitosis_repo_name.endswith('overlay') \ + and not gitolite_repo_name.endswith('overlay') \ and not _description.lower().endswith('overlay'): continue if not is_public(section_name): - # TODO print 'Skipping %s (not public)' % gitosis_repo_name + # TODO print 'Skipping %s (not public)' % gitolite_repo_name continue - repositores_xml_repo_name = repo_name_mapping.get(gitosis_repo_name, gitosis_repo_name) + repositores_xml_repo_name = repo_name_mapping.get(gitolite_repo_name, gitolite_repo_name) is_new = repositores_xml_repo_name not in overlays_gentoo_org_dict if is_new: if opts.fixes_only: @@ -147,11 +149,11 @@ for section_name in gitosis_conf.sections(): repo = ET.Element('repo') repositories.append(repo) name = ET.Element('name') - name.text = gitosis_repo_name + name.text = gitolite_repo_name repo.append(name) else: repo = overlays_gentoo_org_dict[repositores_xml_repo_name] - log = ChangeLog(gitosis_repo_name, is_new) + log = ChangeLog(gitolite_repo_name, is_new) if 'status' not in repo.attrib: if owner_part == 'user': @@ -179,7 +181,7 @@ for section_name in gitosis_conf.sections(): log.log('description', _description) - _owner = gitosis_conf.get(section_name, 'owner') + _owner = owner_contact _owner_match = OWNER_REGEX.match(_owner) owner = repo.find('owner') |