NARKOZ/ginatra

View on GitHub
views/commit.erb

Summary

Maintainability
Test Coverage
<% title @repo.name, headline: "Commit #{@commit.oid[0..6]}" %>

<div class="info-box">
  <div class="row">
    <div class="col-md-5">
      <%= simple_format h(@commit.message) %>

      <div class="author-box">
        <%= gravatar_image_tag @commit.author[:email], class: 'img-rounded', alt: @commit.author[:name] %>
        <strong data-toggle="tooltip" data-placement="bottom" title="<%= @commit.author[:email] %>"><%= @commit.author[:name] %></strong>
        authored at <%= time_tag @commit.author[:time] %>

        <% unless @commit.committer[:name] == @commit.author[:name] %>
        <div class="author-box">
          <%= gravatar_image_tag @commit.committer[:email], class: 'img-rounded', alt: @commit.committer[:name] %>
          <strong data-toggle="tooltip" data-placement="bottom" title="<%= @commit.committer[:email] %>"><%= @commit.committer[:name] %></strong>
          committed at <%= time_tag @commit.committer[:time] %>
        </div>
        <% end %>
      </div>

      <br>
      <p>
        as seen in:
        <% @repo.branches_with(@commit.oid).each do |branch| %>
          <a href="<%= h prefix_url(@repo.param) %>/tree/<%= h branch.name %>">
            <%= h branch.name %>
          </a>
        <% end %>
      </p>
    </div>
    <div class="col-md-7">
      <div class="row">
        <div class="col-md-1">
          <p><strong>commit:</strong></p>
          <p><strong>tree:</strong></p>
          <% @commit.parents.size.times do %>
            <p><strong>parent:</strong></p>
          <% end %>
        </div>
        <div class="col-md-3">
          <p>
            <a href="<%= prefix_url(@repo.param) %>/commit/<%= @commit.oid %>">
              <%= @commit.oid %>
            </a>
          </p>

          <p>
            <a href="<%= prefix_url(@repo.param) %>/tree/<%= @commit.tree.oid %>">
              <%= @commit.tree.oid %>
            </a>
          </p>

          <% @commit.parents.each do |parent| %>
          <p>
            <a href="<%= prefix_url(@repo.param) %>/commit/<%= parent.oid %>">
              <%= parent.oid %>
            </a>
          </p>
          <% end %>

          <p><img src="/img/download.svg" alt="download" class="icon"> <%= patch_link @commit, @repo.param %></p>
        </div>
      </div>
    </div>
  </div>
</div>

<div id="diff">
  <% diff = @commit.parents.first.diff(@commit) %>

  <p>
    <button class="btn btn-primary"><%= diff.deltas.size %> changed files</button>
    <button class="btn btn-default" type="button" id="js-toggle-file-listing">Show file listing</button>
  </p>

  <div class="diff-files-list" id="js-file-listing">
    <%= file_listing diff %>
  </div>

  <% diff.patches.each_with_index do |patch, index| %>
    <div class="row">
      <div class="col-md-12">
        <p class="pull-left">
          <img src="/img/file.svg" alt="file" class="icon"> <a id='file-<%= index + 1 %>'><%= patch.delta.new_file[:path] %></a>
        </p>
        <p class="pull-right">
          <% unless patch.delta.deleted? %>
            <a href="<%= prefix_url(@repo.param) %>/blob/<%= @commit.tree.oid %>/<%= patch.delta.new_file[:path] %>">view file</a>
          <% end %>
        </p>
      </div>
    </div>

    <% patch.hunks.each do |hunk| %>
      <%= highlight_diff hunk %>
    <% end %>
  <% end %>
</div>