Example #1
0
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)
Example #2
0
def remove(name):
    g = Gitolite(os.path.join(os.getcwd(), conf.gitolite_path))
    g.remove_repo(name)
    g.save()
    subprocess.check_call(
        ["sudo", "rm", "-rf", "data/repos/git/repositories/" + name + ".git"],
        cwd=os.getcwd())
Example #3
0
def remove_test_repo(repo_name):
    if not repo_name in _test_repos:
        return
    if not os.path.isdir(wds):
        os.mkdir(wds)
    manager = Gitolite(path=os.path.join(wds, 'gitolite-admin'),
                       url=test_settings['gitolite_url'])
    manager.remove_repo(repo_name)
    manager.save()
    rm('-rf', wds)
    _test_repos.remove(repo_name)
Example #4
0
def remove_test_repos():
    if len(_test_repos) == 0:
        return
    if not os.path.isdir(wds):
        os.mkdir(wds)
    manager = Gitolite(path=os.path.join(wds, 'gitolite-admin'),
                       url=test_settings['gitolite_url'])
    for repo in set(_test_repos):
        manager.remove_repo(repo)
    manager.save()
    rm('-rf', wds)
    _test_repos.clear()
Example #5
0
def list():
    g = Gitolite(os.path.join(os.getcwd(), conf.gitolite_path))
    print(' '.join(g.users()))
Example #6
0
def remove(name):
    g = Gitolite(os.path.join(os.getcwd(), conf.gitolite_path))
    g.remove_user(name)
    g.save()
Example #7
0
def info(name):
    g = Gitolite(os.path.join(os.getcwd(), conf.gitolite_path))
    groups = g.get_user_groups(name)
    key = g.get_user_key(name)
    print("Groups:", groups)
    print("Key:", key)
Example #8
0
def add(name, key):
    g = Gitolite(os.path.join(os.getcwd(), conf.gitolite_path))
    g.add_user(name, key)
    g.save()
Example #9
0
def add_rule(name, rule):
    g = Gitolite(os.path.join(os.getcwd(), conf.gitolite_path))
    g.add_rule_string(name, rule)
    g.save()
Example #10
0
def create(name):
    g = Gitolite(os.path.join(os.getcwd(), conf.gitolite_path))
    g.create_repo(name)
    g.save()
Example #11
0
def remove_user(group, name):
    g = Gitolite(os.path.join(os.getcwd(), conf.gitolite_path))
    g.remove_user_from_group(name, group)
    g.save()
Example #12
0
def add_user(group, name):
    g = Gitolite(os.path.join(os.getcwd(), conf.gitolite_path))
    g.add_user_to_group(name, group)
    g.save()
Example #13
0
def info(name):
    g = Gitolite(os.path.join(os.getcwd(), conf.gitolite_path))
    users = g.get_group(name)
    print("Users:", ' '.join(users))
Example #14
0
def add(name):
    g = Gitolite(os.path.join(os.getcwd(), conf.gitolite_path))
    g.add_group(name)
    g.save()