diff options
author | Jon Turney <jon.turney@dronecode.org.uk> | 2017-04-12 15:05:17 +0300 |
---|---|---|
committer | Jon Turney <jon.turney@dronecode.org.uk> | 2017-05-11 20:23:36 +0300 |
commit | ff4c1b9d1bb650d6b2120fe30fcdb216c9c233bf (patch) | |
tree | 0c39ce02cf67bb10740504da3a716c719c711d45 | |
parent | 1df741ca99b61726efabde01557f5a55be1da8e3 (diff) |
Add experimental tool to help write gitolite configuration
-rwxr-xr-x | calm/mkgitoliteconf.py | 104 | ||||
-rw-r--r-- | setup.py | 1 |
2 files changed, 105 insertions, 0 deletions
diff --git a/calm/mkgitoliteconf.py b/calm/mkgitoliteconf.py new file mode 100755 index 0000000..e32c69b --- /dev/null +++ b/calm/mkgitoliteconf.py @@ -0,0 +1,104 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2017 Jon Turney +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the "Software"), to deal +# in the Software without restriction, including without limitation the rights +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +# copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +# THE SOFTWARE. +# + +# +# mkgitoliteconf - creates a gitolite conf file fragment from cygwin-pkg-maint +# + +from collections import defaultdict +import argparse +import logging +import os +import sys + +from . import common_constants +from . import maintainers + + +# +# transform username to charset acceptable to gitolite +# + + +def transform_username(name): + name = name.replace('.', '') + name = name.replace(' ', '_') + name = name.encode('ascii', 'replace').decode() + return name + + +# +# +# + +def do_main(args): + # read maintainer list + mlist = {} + mlist = maintainers.Maintainer.add_packages(mlist, args.pkglist, getattr(args, 'orphanmaint', None)) + + # make the list of all packages + all_packages = maintainers.Maintainer.all_packages(mlist) + + # invert to a per-package list of maintainers + pkgs = defaultdict(list) + # for each maintainer + for m in mlist.values(): + # for each package + for p in m.pkgs: + # add the maintainer name + pkgs[p].append(m.name) + + # header + print("# automatically generated by mkgitoliteconf") + + # for each package + for p in sorted(pkgs): + users = ' '.join(map(transform_username, pkgs[p])) + if p.startswith('_'): + p = p[1:] + + print("repo cygwin-packages/%s" % (p)) + print("C = %s" % (users)) + print("RW = %s" % (users)) + print("") + +# +# +# + + +def main(): + pkglist_default = common_constants.PKGMAINT + + parser = argparse.ArgumentParser(description='gitolite rules config generator') + parser.add_argument('--pkglist', action='store', metavar='FILE', help="package maintainer list (default: " + pkglist_default + ")", default=pkglist_default) + (args) = parser.parse_args() + + do_main(args) + +# +# +# + +if __name__ == "__main__": + sys.exit(main()) @@ -13,6 +13,7 @@ setup( 'console_scripts': [ 'calm = calm.calm:main', 'mksetupini = calm.mksetupini:main', + 'calm-mkgitoliteconf = calm.mkgitoliteconf:main', ], }, url='https://cygwin.com/git/?p=cygwin-apps/calm.git', |