Template:KumaGithubChanges

  • Revision slug: Template:KumaGithubChanges
  • Revision title: Template:KumaGithubChanges
  • Revision id: 353425
  • Created:
  • Creator: lmorchard
  • Is current revision? No
  • Comment

Revision Content

<% var GITHUB_API_BASE = 'https://api.github.com'; var GITHUB_COMMIT_BASE = 'https://github.com/mozilla/kuma/commit/'; var GITHUB_AUTHOR_BASE = 'https://github.com/'; // TODO: Fix this - for some reason, people throws ECONNREFUSED // var PUSH_LOG_URL = 'https://people.mozilla.com/~lorchard/mdn-deploy-history.txt'; var PUSH_LOG_URL = 'http://lmorchard.com/mdn-deploy-history.txt'; var push_log_txt = mdn.fetchHTTPResource(PUSH_LOG_URL); // Extract the push records from the text log var lines = push_log_txt.split(/\n/); var pushes = []; for (var idx=0; idx<lines.length; %="" '="" '...'="" (!lines[idx])="" (var="" +="" 0],="" 1],="" 2],="" 3],="" commit:="" compare="" compare_data="mdn.fetchJSONResource(compare_url);" compare_url="GITHUB_API_BASE" continue;="" curr_push="pushes[idx];" curr_push.commit;="" for="" idx="1;" idx+="5)" idx++)="" idx<pushes.length;="" if="" kuma="" lines[idx="" mozilla="" on="" prev_push="pushes[idx-1];" prev_push.commit="" pushes...="" pushes.push({="" report="" repos="" status:="" the="" time:="" var="" who:="" {="" }="" });=""> <% if (!compare_data) { %>

Changes for push by <%=curr_push.who%> on <%= curr_push.time %>

Fetching data from GitHub failed.

<% } else { %>

Changes for push by <%=curr_push.who%> on <%= curr_push.time %> (permalink / JSON)

    <% for (var i=0, c; c=compare_data.commits[i]; i++) { %>
  • <% if (c.author) { %> <%= c.author.login %> <% } else { %> <%= c.commit.author.name %> <% } %> <%= c.commit.message %>
  • <% } %>
<% } %> <% } %></lines.length;>

Revision Source

<%
var GITHUB_API_BASE    = 'https://api.github.com';
var GITHUB_COMMIT_BASE = 'https://github.com/mozilla/kuma/commit/';
var GITHUB_AUTHOR_BASE = 'https://github.com/';

// TODO: Fix this - for some reason, people throws ECONNREFUSED 
// var PUSH_LOG_URL = 'https://people.mozilla.com/~lorchard/mdn-deploy-history.txt';
var PUSH_LOG_URL = 'http://lmorchard.com/mdn-deploy-history.txt';
var push_log_txt = mdn.fetchHTTPResource(PUSH_LOG_URL);

// Extract the push records from the text log
var lines = push_log_txt.split(/\n/);
var pushes = [];
for (var idx=0; idx<lines.length; idx+=5) {
    if (!lines[idx]) { continue; }
    pushes.push({
        time: lines[idx + 0],
        who: lines[idx + 1],
        commit: lines[idx + 2],
        status: lines[idx + 3],
    });
}

// Report on the pushes...
for (var idx=1; idx<pushes.length; idx++) {
    var curr_push = pushes[idx];
    var prev_push = pushes[idx-1];
    
    var compare_url = GITHUB_API_BASE + '/repos/mozilla/kuma/compare/' +
                        prev_push.commit + '...' + curr_push.commit;
    var compare_data = mdn.fetchJSONResource(compare_url);
    %>
    <% if (!compare_data) { %>
        <h2>Changes for push by <%=curr_push.who%> on <%= curr_push.time %></h2>
        <p>Fetching data from GitHub failed.</p>
    <% } else { %>
        <h2>Changes for push by <%=curr_push.who%> on <%= curr_push.time %> (<a href="<%= compare_data.permalink_url %>">permalink</a> / <a href="<%=compare_url%>">JSON</a>)</h2>
        <ul>
            <% for (var i=0, c; c=compare_data.commits[i]; i++) { %>
                <li>
                    <% if (c.author) { %>
                        <a href="<%= GITHUB_AUTHOR_BASE + c.author.login %>"><img src="<%= c.author.avatar_url %>" style="width: 2em; height: 2em;" alt="<%= c.author.login %>"></a>
                    <% } else { %>
                        <a href="<%= GITHUB_AUTHOR_BASE + c.commit.author.name %>"><img src="https://www.gravatar.com/avatar/<%= md5(c.commit.author.email) %>" style="width: 2em; height: 2em;" alt="<%= c.commit.author.name %>"></a>
                    <% } %>
                    <a href="<%= GITHUB_COMMIT_BASE + c.sha %>" title="<%= c.sha %>"><%= c.commit.message %></a>
                </li>
            <% } %>
        </ul>
    <% } %>
<% } %>
Revert to this revision