diff options
author | 2009-09-29 19:30:54 +0200 | |
---|---|---|
committer | 2009-09-29 19:31:23 +0200 | |
commit | e7a9a383e90aa58bb90a8d970d219622eff4d340 (patch) | |
tree | ffd0c19a57ff52392f93042fec28c6ffd9fee995 | |
parent | Add missing attribute "priority" (diff) | |
download | repositories-xml-format-e7a9a383e90aa58bb90a8d970d219622eff4d340.tar.gz repositories-xml-format-e7a9a383e90aa58bb90a8d970d219622eff4d340.tar.bz2 repositories-xml-format-e7a9a383e90aa58bb90a8d970d219622eff4d340.zip |
Add script to auto-merge gitosis config into repositories.xml (beta quality)
-rw-r--r-- | merge-gitosis-conf-into-repositories-xml.py | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/merge-gitosis-conf-into-repositories-xml.py b/merge-gitosis-conf-into-repositories-xml.py new file mode 100644 index 0000000..1decc60 --- /dev/null +++ b/merge-gitosis-conf-into-repositories-xml.py @@ -0,0 +1,85 @@ +import xml.etree.ElementTree as ET +from ConfigParser import ConfigParser +import re + +from sharedutils import * # local + +OWNER_REGEX = re.compile('^([^<]+) (?:\([^)]+\) )?<([^ ]+@[^ ]+)>$') + + +gitosis_conf = ConfigParser() +gitosis_conf.read('gitosis.conf') + +a = ET.parse(open('repositories.xml')) +repositories = a.getroot() +overlays_gentoo_org_dict = dict([[e.attrib['name'], e] for e in repositories]) + +for section_name in gitosis_conf.sections(): + if section_name.startswith('repo '): + _repo_base = section_name[len('repo '):].strip() + if _repo_base.startswith('dev/'): + repo_name = _repo_base[len('dev/'):].strip() + owner_type = "person" + elif _repo_base.startswith('proj/'): + repo_name = _repo_base[len('proj/'):].strip() + owner_type = "project" + else: + continue + + if repo_name in overlays_gentoo_org_dict: + print 'Updating %s' % repo_name + repo = overlays_gentoo_org_dict[repo_name] + # Keep due to poor descriptions in gitosis.conf atm + _description = repo.find('description').text + + # Clear + repo.attrib['status'] = 'official' + repo[:] = [] + else: + print 'Adding %s' % repo_name + _description = gitosis_conf.get(section_name, 'description') + repo = ET.Element('repo', name=repo_name, status='official') + repositories.append(repo) + + homepage = ET.Element('homepage') + homepage.text = 'http://git.overlays.gentoo.org/gitweb/?p=%s.git;a=summary' % _repo_base + + description = ET.Element('description') + description.text = _description + + _owner = gitosis_conf.get(section_name, 'owner') + _owner_match = OWNER_REGEX.match(_owner) + + owner = ET.Element('owner', type=owner_type) + owner_name = ET.Element('name') + owner_name.text = _owner_match.group(1) + owner_email = ET.Element('email') + owner_email.text = _owner_match.group(2) + owner[:] = [owner_email, owner_name] + + repo[:] = [description, homepage, owner] + + source_uris = ( + 'git://git.overlays.gentoo.org/%s.git' % _repo_base, + 'http://git.overlays.gentoo.org/gitroot/%s.git' % _repo_base, + 'git+ssh://git@git.overlays.gentoo.org/%s.git' % _repo_base, + ) + for uri in source_uris: + source = ET.Element('source', type='git') + source.text = uri + repo.append(source) + + feed_uris = ( + 'http://git.overlays.gentoo.org/gitweb/?p=%s.git;a=atom' % _repo_base, + 'http://git.overlays.gentoo.org/gitweb/?p=%s.git;a=rss' % _repo_base, + ) + for uri in feed_uris: + feed = ET.Element('feed') + feed.text = uri + repo.append(feed) + + owner = ET.Element('owner') + +recurse_print(repositories) +indent(repositories) +a.write('repositories.xml') |