Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Support multiple repos in bors.html #27

Merged
merged 2 commits into from

3 participants

@Vagabond

bors.html now allows you to choose a specific repository to view, based
on the query string. This is useful if you run bors for multiple repos,
but in the same directory. If there is only one repository, this change
is backward compatible, as it defaults to the singleton repository.
The main change is to wrap the json inside of a map, which is keyed off
of the repository name. The javascript that runs inside the html file
then looks up the queue, based on the query string. If no query-string
is provided (and there is more than one repository), then a list of
available repos is shown.

reiddraper and others added some commits
@reiddraper reiddraper Support multiple repositories in bors.html
Pair-programmed with @Vagabond.

bors.html now allows you to choose a specific repository to view, based
on the query string. This is useful if you run bors for multiple repos,
but in the same directory. If there is only one repository, this change
is backward compatible, as it defaults to the singleton repository.
The main change is to wrap the json inside of a map, which is keyed off
of the repository name. The javascript that runs inside the html file
then looks up the queue, based on the query string. If no query-string
is provided (and there is more than one repository), then a list of
available repos is shown.
8f38621
@Vagabond Vagabond Make sure the PR links point to the destination repo 2aa3072
@brson brson merged commit f3cbe12 into graydon:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 4, 2014
  1. @reiddraper @jaredmorrow

    Support multiple repositories in bors.html

    reiddraper authored jaredmorrow committed
    Pair-programmed with @Vagabond.
    
    bors.html now allows you to choose a specific repository to view, based
    on the query string. This is useful if you run bors for multiple repos,
    but in the same directory. If there is only one repository, this change
    is backward compatible, as it defaults to the singleton repository.
    The main change is to wrap the json inside of a map, which is keyed off
    of the repository name. The javascript that runs inside the html file
    then looks up the queue, based on the query string. If no query-string
    is provided (and there is more than one repository), then a list of
    available repos is shown.
  2. @Vagabond @jaredmorrow
This page is out of date. Refresh to see the latest.
Showing with 127 additions and 66 deletions.
  1. +113 −64 bors-render.js
  2. +1 −1  bors.css
  3. +13 −1 bors.py
View
177 bors-render.js
@@ -1,64 +1,113 @@
-
-function render_queue() {
- var q = document.getElementById("queue");
- var hdr = elt_txt_class("td", "Bors queue: " + bors.length, "header");
- hdr.setAttribute("colspan", "5");
- var row = elt("tr");
- row.appendChild(hdr);
- q.appendChild(row);
-
- hdr = elt_txt_class("td", "updated " + updated.toISOString(), "header");
- hdr.setAttribute("colspan", "5");
- row = elt("tr");
- row.appendChild(hdr);
- q.appendChild(row);
-
- for (var i = bors.length - 1; i >= 0; --i) {
- var e = bors[i];
- row = elt("tr");
-
- var num = e["num"].toString();
- var num_cell = elt("td");
- var repo = e["src_owner"] + "/" + e["src_repo"] + "/"
- num_cell.appendChild(a_txt_class_url(num, "pull", "https://github.com/" + repo + "pull/" + num));
- row.appendChild(num_cell);
-
- var state = e["state"];
- row.appendChild(elt_txt_class("td", state, e["state"]));
-
- row.appendChild(elt_txt_class("td", e["prio"].toString(), "priority"));
-
- var ref = repo + e["ref"];
- row.appendChild(elt_txt_class("td", ref, "ref"));
-
- var t = e["title"]
-
- if (e["num_comments"] == 0 ||
- e["last_comment"][2].indexOf("r+") == 0) {
- row.appendChild(elt_txt_class("td", t, "details"));
- } else {
- var last = e["last_comment"];
- var when = last[0];
- var who = last[1];
- var what = last[2];
-
- var td = elt_class("td", "details");
- td.appendChild(elt_txt_class("p", t, "title"));
-
- var c = elt_class("div", "comment");
- c.appendChild(elt_txt_class("div",
- who + " " + when + " #" + e["num_comments"],
- "commentheader"));
- c.appendChild(elt_txt_class("div", what, "commentbody"));
- td.appendChild(c);
-
- row.appendChild(td);
- }
-
-
- q.appendChild(row);
- }
-}
-
-
-window.onload = render_queue;
+
+function render_queue(queue) {
+ var q = document.getElementById("queue");
+ var hdr = elt_txt_class("td", "Bors queue: " + queue.length, "header");
+ hdr.setAttribute("colspan", "5");
+ var row = elt("tr");
+ row.appendChild(hdr);
+ q.appendChild(row);
+
+ hdr = elt_txt_class("td", "updated " + updated.toISOString(), "header");
+ hdr.setAttribute("colspan", "5");
+ row = elt("tr");
+ row.appendChild(hdr);
+ q.appendChild(row);
+
+ for (var i = queue.length - 1; i >= 0; --i) {
+ var e = queue[i];
+ row = elt("tr");
+
+ var num = e["num"].toString();
+ var num_cell = elt("td");
+ var repo = e["dst_owner"] + "/" + e["dst_repo"] + "/"
+ num_cell.appendChild(a_txt_class_url(num, "pull", "https://github.com/" + repo + "pull/" + num));
+ row.appendChild(num_cell);
+
+ var state = e["state"];
+ row.appendChild(elt_txt_class("td", state, e["state"]));
+
+ row.appendChild(elt_txt_class("td", e["prio"].toString(), "priority"));
+
+ var ref = repo + e["ref"];
+ row.appendChild(elt_txt_class("td", ref, "ref"));
+
+ var t = e["title"]
+
+ if (e["num_comments"] == 0 ||
+ e["last_comment"][2].indexOf("r+") == 0) {
+ row.appendChild(elt_txt_class("td", t, "details"));
+ } else {
+ var last = e["last_comment"];
+ var when = last[0];
+ var who = last[1];
+ var what = last[2];
+
+ var td = elt_class("td", "details");
+ td.appendChild(elt_txt_class("p", t, "title"));
+
+ var c = elt_class("div", "comment");
+ c.appendChild(elt_txt_class("div",
+ who + " " + when + " #" + e["num_comments"],
+ "commentheader"));
+ c.appendChild(elt_txt_class("div", what, "commentbody"));
+ td.appendChild(c);
+
+ row.appendChild(td);
+ }
+
+
+ q.appendChild(row);
+ }
+}
+
+var qs = (function(a) {
+ if (a == "") return {};
+ var b = {};
+ for (var i = 0; i < a.length; ++i) {
+ var p=a[i].split('=');
+ if (p.length != 2) continue;
+ b[p[0]] = decodeURIComponent(p[1].replace(/\+/g, " "));
+ }
+ return b;
+})(window.location.search.substr(1).split('&'));
+
+function render_status() {
+ var k = Object.keys(bors).sort();
+ console.log(qs);
+ if (k.length > 1) {
+ console.log(qs["repo"], bors[qs["repo"]]);
+ if (qs["repo"] && bors[qs["repo"]]) {
+ render_queue(bors[qs["repo"]]);
+ } else {
+ console.log("feh");
+ // render a list of repos
+ var q = document.getElementById("queue");
+ var hdr0 = elt_txt_class("td", "Repo", "header");
+ var hdr1 = elt_txt_class("td", "PRs", "header");
+ var row = elt("tr");
+ row.appendChild(hdr0);
+ row.appendChild(hdr1);
+ q.appendChild(row);
+ for (var i = 0; i < k.length; i++) {
+ // TODO
+ row = elt_class("tr", "summary");
+
+ var name = k[i];
+ var name_cell = elt("td");
+ name_cell.appendChild(a_txt_class_url(name, "pull", "?repo="+name));
+ row.appendChild(name_cell);
+
+ var count = bors[k[i]].length
+ row.appendChild(elt_txt_class("td", count, ""));
+
+ q.appendChild(row);
+ }
+ }
+ } else {
+ // render the first one
+ render_queue(bors[keys[0]]);
+ }
+}
+
+
+window.onload = render_status;
View
2  bors.css
@@ -11,7 +11,7 @@ body {
}
#queue {
- margin: em;
+ margin: 0em auto;
border: 1px black solid;
}
View
14 bors.py
@@ -769,6 +769,12 @@ def main():
logging.info("got %d open pull reqs", len(pulls))
# Dump state-of-world javascript fragment
+
+ try:
+ json_db = json.load(open('bors-status.json', 'r'))
+ except IOError:
+ json_db = {}
+
j = []
for pull in pulls:
j.append({ "num": pull.num,
@@ -777,6 +783,8 @@ def main():
"prio": pull.priority(),
"src_owner": pull.src_owner,
"src_repo": pull.src_repo,
+ "dst_owner": pull.dst_owner,
+ "dst_repo": pull.dst_repo,
"num_comments": len(pull.head_comments +
pull.pull_comments),
"last_comment": pull.last_comment(),
@@ -784,11 +792,15 @@ def main():
"ref": pull.ref,
"sha": pull.sha,
"state": state_name(pull.current_state()) })
+
+ json_db[repo] = j
+ json.dump(json_db, open('bors-status.json', 'w'))
+
f = open("bors-status.js", "w")
f.write(strftime('var updated = new Date("%Y-%m-%dT%H:%M:%SZ");\n',
gmtime()))
f.write("var bors = ")
- json.dump(j, f)
+ json.dump(json_db, f)
f.write(";\n")
f.close()
Something went wrong with that request. Please try again.