Esempio n. 1
0
def get_commits_unique_to_branch(repo_key, branch_name, sort):  # NOTE: This endpoint is a RestfulGit extension
    repo = get_repo(repo_key)
    branch = _get_branch(repo, branch_name)
    if sort == "chronological":
        sort = GIT_SORT_TIME | GIT_SORT_REVERSE
    else:
        sort = GIT_SORT_TOPOLOGICAL | GIT_SORT_REVERSE
    commits = list(_get_commits_unique_to_branch(repo, branch, sort))
    return {"commits": [convert_commit(repo_key, repo, commit) for commit in commits]}
Esempio n. 2
0
def get_commits_unique_to_branch(repo_key, branch_name, sort):  # NOTE: This endpoint is a RestfulGit extension
    repo = get_repo(repo_key)
    branch = _get_branch(repo, branch_name)
    if sort == 'chronological':
        sort = GIT_SORT_TIME | GIT_SORT_REVERSE
    else:
        sort = GIT_SORT_TOPOLOGICAL | GIT_SORT_REVERSE
    commits = list(_get_commits_unique_to_branch(repo, branch, sort))
    return {
        "commits": [convert_commit(repo_key, repo, commit) for commit in commits]
    }
Esempio n. 3
0
def get_tag(repo_key, tag_name):  # NOTE: This endpoint is a RestfulGit extension
    repo = get_repo(repo_key)
    tag = lookup_ref(repo, TAG_REF_PREFIX + tag_name)
    if tag is None:
        raise NotFound("tag not found")
    result = {
        "name": tag.shorthand,
        "commit": convert_commit(repo_key, repo, tag.get_object()),
        "url": url_for("porcelain.get_tag", _external=True, repo_key=repo_key, tag_name=tag.shorthand),
    }
    # simple tag
    if tag.target != tag.get_object().id:
        tag_obj = repo[tag.target]
        result["tag"] = convert_tag(repo_key, repo, tag_obj)
    return result
Esempio n. 4
0
def get_tag(repo_key, tag_name):  # NOTE: This endpoint is a RestfulGit extension
    repo = get_repo(repo_key)
    tag = lookup_ref(repo, TAG_REF_PREFIX + tag_name)
    if tag is None:
        raise NotFound("tag not found")
    result = {
        "name": tag.shorthand,
        "commit": convert_commit(repo_key, repo, tag.peel()),
        "url": url_for('porcelain.get_tag', _external=True,
                       repo_key=repo_key, tag_name=tag.shorthand),
    }
    # simple tag
    if tag.target != tag.peel().id:
        tag_obj = repo[tag.target]
        result['tag'] = convert_tag(repo_key, repo, tag_obj)
    return result
Esempio n. 5
0
def get_commit(repo_key, branch_or_tag_or_sha):
    repo = get_repo(repo_key)
    commit = get_commit_for_refspec(repo, branch_or_tag_or_sha)
    return convert_commit(repo_key, repo, commit, include_diff=True)
Esempio n. 6
0
def get_commit(repo_key, branch_or_tag_or_sha):
    repo = get_repo(repo_key)
    commit = get_commit_for_refspec(repo, branch_or_tag_or_sha)
    return convert_commit(repo_key, repo, commit, include_diff=True)