@plumbing.route('/repos/<repo_key>/git/commits/')
@corsify
@jsonify
def get_commit_list(repo_key):
    ref_name = request.args.get('ref_name') or None
    start_sha = request.args.get('start_sha') or None
    limit = request.args.get('limit') or current_app.config['RESTFULGIT_DEFAULT_COMMIT_LIST_LIMIT']
    try:
        limit = int(limit)
    except ValueError:
        raise BadRequest("invalid limit")
    if limit < 0:
        raise BadRequest("invalid limit")

    repo = get_repo(repo_key)

    start_commit_id = None
    if start_sha is not None:
        start_commit_id = start_sha
    else:
        if ref_name is None:
            ref_name = "HEAD"
        ref = lookup_ref(repo, ref_name)
        if ref is None:
            raise NotFound("reference not found")
        start_ref = lookup_ref(repo, ref_name)
        try:
            start_commit_id = start_ref.resolve().target
        except KeyError:
            if ref_name == "HEAD":
                return []
            else:
                raise NotFound("reference not found")

    try:
        walker = repo.walk(start_commit_id, GIT_SORT_TIME)
    except ValueError:
        raise BadRequest("invalid start_sha")
    except KeyError:
        raise NotFound("commit not found")

    commits = [convert_commit(repo_key, commit) for commit in islice(walker, limit)]
    return commits
dataset/ETHPy150Open hulu/restfulgit/restfulgit/plumbing/routes.py/get_commit_list/original