diff options
author | Sebastian Pipping <sebastian@pipping.org> | 2009-11-07 19:27:46 +0100 |
---|---|---|
committer | Sebastian Pipping <sebastian@pipping.org> | 2009-11-07 19:27:46 +0100 |
commit | 8c459afefd64cdc2ab6e880c6e580946158f60b2 (patch) | |
tree | de80d274e42384e7c1871f902ff61566ae947074 | |
parent | Add --fixes-only option to gitosis.conf extractor (diff) | |
download | repositories-xml-format-8c459afefd64cdc2ab6e880c6e580946158f60b2.tar.gz repositories-xml-format-8c459afefd64cdc2ab6e880c6e580946158f60b2.tar.bz2 repositories-xml-format-8c459afefd64cdc2ab6e880c6e580946158f60b2.zip |
Take dirmode into account
-rwxr-xr-x | diff-gitosis-conf-against-repositories-xml.py | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/diff-gitosis-conf-against-repositories-xml.py b/diff-gitosis-conf-against-repositories-xml.py index 6666c41..c2c0d53 100755 --- a/diff-gitosis-conf-against-repositories-xml.py +++ b/diff-gitosis-conf-against-repositories-xml.py @@ -62,6 +62,32 @@ a = ET.parse(open(repositories_xml_location)) repositories = a.getroot() overlays_gentoo_org_dict = dict([[e.find('name').text, e] for e in repositories]) +def oct_string_to_int(os): + l = len(os) + res = 0 + for i, v in enumerate(os): + res = res + (8**(l-1-i)) * int(v) + return res + +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') + +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_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 + + for section_name in gitosis_conf.sections(): if section_name.startswith('repo '): _repo_base = section_name[len('repo '):].strip() @@ -84,10 +110,9 @@ for section_name in gitosis_conf.sections(): # TODO print NOT_AN_OVERLAY_MESSAGE % repo_name continue - if gitosis_conf.has_option(section_name, 'gitweb') and \ - not gitosis_conf.getboolean(section_name, 'gitweb'): - # TODO print 'Skipping %s (not public)' % repo_name - continue + if not is_public(section_name): + # TODO print 'Skipping %s (not public)' % repo_name + continue is_new = repo_name not in overlays_gentoo_org_dict if is_new: |