Пример #1
0
def html_page(title, *content, **arguments):
    head = html.head(
        html.link(rel="shortcut icon", href=config["favicon"]),
        html.title("{} - {}".format(title, config["title"])),
        html.style(style),
    )
    nav = html.nav(
        html.ul(
            html.li(html.a("⚗", href=html.absolute())),
            html.li(html.a("Reviews", href=html.absolute("reviews"))),
            html.li(html.a("Commits", href=html.absolute("commits", repo.head.ref.name))),
            html.li(html.a("Tree", href=html.absolute("tree", repo.head.ref.name))),
            html.li(html.a("Refs", href=html.absolute("refs"))),
        )
    )
    return http.Html(html.html(head, html.body(*((nav,) + content + (html.script(script),)), **arguments)))
Пример #2
0
def get_commit(request, args):
    [commit_id] = args
    commit = repo.commit(commit_id)
    parent = commit.parents[0]
    diff = parent.diff(commit, None, True)
    header = html.div(html.a(commit.hexsha[0:12], href=html.absolute("commit", commit.hexsha)), " ", commit.summary)
    diffs = map(diff_to_html, diff)
    return html_page("Commit {}".format(commit.hexsha[0:12]), header, *diffs)
Пример #3
0
def post_comment_create(request, args, form):
    review_id = form["review_id"].value
    left_id = form["left_id"].value if form.has_key("left_id") else None
    right_id = form["right_id"].value if form.has_key("right_id") else None
    if not form.has_key("message"):
        return http.Error(400, "Missing comment message")
    db.add("comments_" + review_id, {"message": form["message"].value, "left_id": left_id, "right_id": right_id})
    return http.Created(html.absolute("comments", review_id))
Пример #4
0
def get_review(request, args):
    [hexsha] = args
    review = db.get("open_reviews", hexsha)
    patch = html.a("patch", href=html.absolute("patch", hexsha))
    buttons = html.div(patch)
    header = html.div(review_to_html_summary((hexsha, review)), html.hr(), buttons)
    diff = review_to_diff(review)
    return html_page(
        "Review {}".format(hexsha[0:12]), header, *map(diff_to_html, diff), onload="initComments('{}');".format(hexsha)
    )
Пример #5
0
def post_review_create(request, args, form):
    commits = map(lambda x: repo.commit(x.name), form.list)
    included = sorted(commits, cmp=compare_commits)
    first = included[-1]
    last = included[0]
    diffs = first.parents[0].diff(last)
    paths = set()
    for c in included:
        paths.update(diffs_to_affected_paths(c.diff(c.parents[0])))

    review = {
        "baseCommit": first.parents[0].hexsha,
        "lastCommit": last.hexsha,
        "affectedPaths": list(paths),
        "includedCommits": list(map(lambda c: c.hexsha, included)),
    }
    return http.Created(html.absolute("review", db.add("open_reviews", review)))
Пример #6
0
def get_commits(request, args):
    ref_name = "/".join(args)
    rows = []
    for commit in repo.iter_commits(ref_name, max_count=config["displayed_commits"]):
        check = html.input(type="checkbox", name=commit.hexsha)
        rows.append(html.tr(html.td(check, " ", *commit_to_html(commit))))
    create_review = html.input(value="Create Review", type="submit")
    reset = html.input(value="Reset", type="reset")
    body = html.form(
        create_review,
        reset,
        html.hr(),
        html.table(*rows, **{"class": "list"}),
        method="post",
        action=html.absolute("review", "create"),
    )
    return html_page("Commits {}".format(ref_name), html.div(body))
Пример #7
0
 def get_ref(ref):
     commits = html.a("commits", href=html.absolute("commits", ref.name))
     tree = html.a("tree", href=html.absolute("tree", ref.name))
     return html.tr(html.td(ref.name), html.td(commits), html.td(tree))
Пример #8
0
def review_to_html_summary(r):
    hexsha, review = r
    commits = html.ul(*map(lambda c: html.li(*commit_to_html(repo.commit(c))), review["includedCommits"]))
    return html.div(html.h1(html.a(hexsha[0:12], href=html.absolute("review", hexsha))), commits, **{"class": "review"})
Пример #9
0
def commit_to_html(commit):
    link = html.a(commit.hexsha[0:12], href=html.absolute("commit", commit.hexsha))
    return link, " ", commit.summary