mozilla
Your Search Results

    Template:KumaGithubChanges

    <%
    var MAX_RECENT_PUSHES = 15;
    
    var GITHUB_API_BASE    = 'https://api.github.com';
    var GITHUB_COMPARE_BASE = GITHUB_API_BASE + '/repos/mozilla/kuma/compare/';
    var GITHUB_COMMIT_BASE = 'https://github.com/mozilla/kuma/commit/';
    var GITHUB_AUTHOR_BASE = 'https://github.com/';
    var GITHUB_PERMALINK_BASE = 'https://github.com/mozilla/kuma/compare/';
    
    /* For reference, this push log .txt is generated via cronjob on the 
       cm-vpn01 jumphost with the following shell command:
       http://pastebin.mozilla.org/2134395
    */
    
    /*
    // 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],
        });
    }
    */
    
    var PUSH_LOG_URL = "https://developer.mozilla.org/en-US/docs/User:lmorchard/ChiefHistory?raw";
    var pushes = mdn.fetchJSONResource(PUSH_LOG_URL);
    
    function gen_report(mdn, compare_range) {
        var compare_url = GITHUB_COMPARE_BASE + compare_range;
        var compare_permalink = GITHUB_PERMALINK_BASE + compare_range;
        var compare_data = mdn.fetchJSONResource(compare_url);
        if (!compare_data) { %>
            <p>Fetching data from GitHub failed. <a target="_blank" href="<%= compare_permalink %>">Try comparing on GitHub itself.</a></p>
        <% } else { %>
            <ul>
                <% if (0 === compare_data.commits.length) { %>
                    <li>No changes.</li>
                <% } else { %>
                    <% 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>
        <% }
    }
    
    // Report on the next pending push
    var prev_push = pushes[0];
    var compare_range = prev_push.commit + '...HEAD';
    %><h3>Pending changes for the next push</h3><%
    gen_report(mdn, compare_range);
    
    // Report on pushes so far...
    // TODO: Maybe eventually show all pushes, but limit for now
    for (var idx=0; idx<=MAX_RECENT_PUSHES; idx++) {
        var curr_push = pushes[idx];
        var prev_push = pushes[idx+1];
        
        if (!prev_push) { continue; }
        
        var compare_range = prev_push.commit + '...' + curr_push.commit;
        var compare_permalink = GITHUB_PERMALINK_BASE + compare_range;
        %><h3>Changes for <a target="_blank" href="<%= compare_permalink %>">push by <%=curr_push.who %> at <%= curr_push.time %></a></h3><%
        gen_report(mdn, compare_range);
    }
    %>
    Search for pages that use Template:KumaGithubChanges to see example use cases and how many pages use this macro.

    Document Tags and Contributors

    Contributors to this page: Sheppy, lmorchard
    Last updated by: lmorchard,