Пример #1
0
def create_branch(repository, branch_name):
    ref = request.form['ref']
    force = request.form.get('force', 0, type = int)
    if repository.create_branch(branch_name, ref, force):
        return make_message_response("Branch create success.")
    else:
        raise JagareError("Branch create failed.")
Пример #2
0
def create_commit(repository):
    branch = request.form['branch']
    parent = request.form['parent']
    author_name = request.form['author_name']
    author_email = request.form['author_email']
    message = request.form['message']
    reflog = request.form['reflog']

    data = []
    form_data = request.form.to_dict()

    for filename, fp in request.files.iteritems():
        filename = filename.strip()
        path = request.form['%s_path' % filename]
        action = request.form.get('%s_action' % filename, 'insert')
        data.append((path, fp.stream, action))

        form_data.pop('%s_path' % filename)
        form_data.pop('%s_action' % filename)

    for key, value in form_data.iteritems():
        if key.endswith('_path') or key.endswith('_action'):
            name = key.split('_path')[0].split('_action')[0]

            path = form_data['%s_path' % name]
            action = form_data['%s_action' % name]

            data.append((path, "", action))

    repository.commit_file(branch = branch, parent = parent, 
                      author_name = author_name, author_email = author_email, 
                      message = message, reflog = reflog, data = data)

    return make_message_response("Commit success!")
Пример #3
0
def mirror(name, url):
    target_path = os.path.join(config.REPOS_PATH, name)
    target_path = endwith_git(target_path)

    repository_exist = is_repository(target_path)

    if repository_exist:
        raise JagareError("repository already exists", 409)

    Jagare.mirror(url, target_path)

    return make_message_response("Mirror success.")
Пример #4
0
def init(name):
    repository_path = os.path.join(config.REPOS_PATH, name)
    repository_path = endwith_git(repository_path)

    repository_exist = is_repository(repository_path)

    if repository_exist:
        raise JagareError("repository already exists.", 409)

    Jagare.init(repository_path)

    return make_message_response("initialize success")
Пример #5
0
def clone(name, clone_from):
    target_path = os.path.join(config.REPOS_PATH, name)
    target_path = endwith_git(target_path)

    clone_path = os.path.join(config.REPOS_PATH, clone_from)
    clone_path = endwith_git(clone_path)

    repository_exist = is_repository(target_path)

    if repository_exist:
        raise JagareError("repository already exists", 409)

    clone_repository_exist = is_repository(clone_path)

    if not clone_repository_exist:
        raise JagareError("clone repository does not exist", 400)

    jagare = Jagare(clone_path)
    jagare.clone(target_path, bare=True)

    return make_message_response("clone success")
Пример #6
0
def delete(repository):
    shutil.rmtree(repository.path)
    return make_message_response("delete success")
Пример #7
0
def add_remote(repository, remote_name):
    url = request.form['url']
    repository.add_remote(remote_name, url)
    return make_message_response("Remote created.")
Пример #8
0
def fetch_all(repository):
    repository.fetch_all()
    return make_message_response("All remotes fetched.")
Пример #9
0
def fetch(repository, remote_name):
    repository.fetch(remote_name)
    return make_message_response("Remote fetched successfully.")
Пример #10
0
def merge_base(repository, from_sha, to_sha):
    repository.merge_base(to_sha, from_sha)
    return make_message_response("Merged.")
Пример #11
0
def delete_branch(repository, branch_name):
    repository.delete_branch(branch_name)
    return make_message_response("Branch delete success")
Пример #12
0
def update_hooks(repository, path):
    repository.update_hooks(path)
    return make_message_response("success to update hooks")