def create_test_repo(repo_name, empty=False, ensure_new=True): if repo_name in _test_repos: if not ensure_new: return remove_test_repo(repo_name) if not os.path.isdir(wds): os.mkdir(wds) manager = Gitolite(path=os.path.join(wds, 'gitolite-admin'), url=test_settings['gitolite_url']) manager.create_repo(repo_name) manager.add_rule(repo_name, 'RW+', ['@all']) manager.save() if not empty: r = repo(wds, repo_name, clone_url='ssh://git@localhost:2222/' + repo_name, branch=None) readme = open(os.path.join(r._workdir, test_file), 'w') readme.write(test_contents) readme.close() r.stage(test_file) r.commit("Initial commit") r.push() rm('-rf', wds) _test_repos.append(repo_name)
def create(name): g = Gitolite(os.path.join(os.getcwd(), conf.gitolite_path)) g.create_repo(name) g.save()