Template:KumaGithubChanges

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

Revision Content

<% var MAX_RECENT_PUSHES = 7; 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<="MAX_RECENT_PUSHES;" 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. Try comparing on GitHub itself.

<% } else { %>

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

    <% 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 MAX_RECENT_PUSHES = 7;

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++) {
for (var idx=1; idx<=MAX_RECENT_PUSHES; idx++) {
    var curr_push = pushes[idx];
    var prev_push = pushes[idx-1];
    
    var compare_url = GITHUB_API_BASE + '/repos/mozilla/kuma/compare/' +
                        curr_push.commit + '...' + prev_push.commit;
    var compare_data = mdn.fetchJSONResource(compare_url);
    %>
    <% if (!compare_data) { %>
        <h3>Changes for push by <%=curr_push.who%> on <%= curr_push.time %></h3>
        <p>Fetching data from GitHub failed. <a href="https://github.com/mozilla/kuma/compare/<%= curr_push.commit + '...' + prev_push.commit %>">Try comparing on GitHub itself.</a></p>
    <% } else { %>
        <h3>Changes for <a href="<%= compare_data.permalink_url %>">push by <%=curr_push.who%> on <%= curr_push.time %></a></h3>
        <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