Blob Blame Raw
{% extends "repo_master.html" %}
{% from "_formhelper.html" import render_field_in_row %}

{% block title %}Pull request #{{ requestid }} - {{ repo.name }}{% endblock %}
{%block tag %}home{% endblock %}


{% block repo %}

<h2>Request pull
  <a href="{{ url_for('view_repo', username=username, repo=repo.name)}}">
    {{ repo.name }}
  </a>

  (<a href="{{ url_for('view_tree', username=username,
               repo=repo.name, identifier=commitid) }}"
    >tree</a>)

</h2>

{% if pull_request %}
<div class="header">
    <h3>Title: {{ pull_request.title }}</h3>
    <ul class="buttons">
  {% if pull_request.status and repo_admin %}
      <li>
        <form action="{{ url_for('merge_request_pull', username=username,
            repo=repo.name, requestid=requestid) }}" method="POST">
          {{ mergeform.csrf_token }}
          <input class="button" type="submit" value="Merge"/>
        </form>
      </li>
      <li>
        <form action="{{ url_for('cancel_request_pull', username=username,
            repo=repo.name, requestid=requestid) }}" method="POST">
          {{ mergeform.csrf_token }}
          <input type="submit" value="Cancel" id="cancel_pr" class="button"/>
        </form>
      </li>
  {% elif pull_request and pull_request.status == False %}
    <li>
      <span class="error">Merged</span>
    </li>
  {% endif %}
      <li>
        <a class="button patch" href="{{ url_for('request_pull_patch', username=username,
            repo=repo.name, requestid=requestid) }}">Patch</a>
      </li>
    </ul>
</div>
{% endif %}

{% if form %}
<section class="new_project">
  <form action="{{ url_for('.new_request_pull', username=username,
    repo=repo.name, commitid=commitid) }}" method="post">
    <table>
      {{ render_field_in_row(form.title) }}
      <tr>
        <td>To branch</td>
        <td>
          <select id="branch_select">
              <option>{{ branchname }}</option>
            {% for branch in branches |reverse %}
              {% if branch != branchname %}
              <option>{{ branch }}</option>
              {% endif %}
            {% endfor %}
          </select>
        </td>
      </tr>
    </table>
    <p class="buttons indent">
      <input type="submit" class="submit positive button" value="Create">
      {{ form.csrf_token }}
      <a href="{{ url_for('view_repo', username=username, repo=repo.name)}}">
        <input type="button" value="Cancel" />
      </a>
    </p>
  </form>
</section>
{% endif %}

<section class="commit_list">
  <ul>
    {% for commit in diff_commits %}
    <li>
    {% if pull_request and pull_request.status and pull_request.repo_from.is_fork %}
      <a href="{{ url_for('view_commit', username=pull_request.repo_from.user.user,
                  repo=pull_request.repo_from.name, commitid=commit.oid.hex)}}">
    {% else %}
      <a href="{{ url_for('view_commit', username=username,
                  repo=repo.name, commitid=commit.oid.hex)}}">
    {% endif %}
        <span class="commitid">{{ commit.oid.hex|short }}</span>
        {{ commit.message.split('\n')[0] }}
      </a>
    </li>
    {% else %}
      <p class="error"> No commits found </p>
    {% endfor %}
  </ul>
</section>

<section class="request_diff">
  {% for commit in diff_commits %}
    {% set splitted_message = commit.message.split('\n') %}
    {% set diff = diffs[loop.index - 1] %}
    {% set commitid = commit.oid.hex %}

<div class="header">
<h3>
    {{ splitted_message[0] }}
    (<span class="commitid" title="{{ commitid }}">commit: {{ commitid|short }}
    </span> - <a href="{{ url_for('view_tree', username=username,
        repo=repo.name, identifier=commitid) }}">tree</a>)
    {% if splitted_message|length > 1 %}
    <span class="commit_message_body">
        {% for message in splitted_message %}
            {% if loop.index > 1 %}
                {{ message }}
            {% endif %}
        {% endfor %}
    </span>
    {% endif %}
</h3>

</div>
<table>
  <tr>
    <th>Author</th>
    <td>
      {{ commit.author.name }} {{ '<' + commit.author.email + '>' }}
      - {{ commit.commit_time | format_ts}}
    </td>
  </tr>
  <tr>
    <th>Committer</th>
    <td>
      {{ commit.committer.name }} {{ '<' + commit.committer.email + '>' }}
      - {{ commit.commit_time | format_ts }}
    </td>
  </tr>
  <tr>
    <th>Parent</th>
    <td>
      {% for parent in commit.parents %}
        <a href="{{ url_for('view_commit', username=username,
                  repo=repo.name, commitid=parent.oid.hex) }}">
          {{ parent.oid.hex }}
        </a> <br />
      {% endfor %}
    </td>
  </tr>
  <tr>
      <th>Changes</th>
      <td>
        <ul class="changes">
        {% for patch in diff %}
          <li>
            <span class="addrem_bar">
              {% if (patch.additions + patch.deletions) %}
                <span style="width: {{ (100.0 * patch.additions / (patch.additions + patch.deletions))|round|int }}%">
                    {% if patch.additions > 0 %}+{{ patch.additions }}{% endif %}
                    {% if patch.deletions > 0 %}-{{ patch.deletions }}{% endif %}
                </span>
              {% endif %}
            </span>
            {{ patch.new_file_path }}
          </li>
        {% endfor %}
        </ul>
      </td>
  </tr>
</table>

{% for patch in diff %}
<section class="commit_diff">
    <header>
        <h3>{{  patch.new_file_path }}</h3>
        <ul class="buttons">
            <li class="addrem_bar">
              {% if (patch.additions + patch.deletions) %}
                <span style="width: {{ (100.0 * patch.additions / (patch.additions + patch.deletions))|round|int }}%">
                    {% if patch.additions > 0 %}+{{ patch.additions }}{% endif %}
                    {% if patch.deletions > 0 %}-{{ patch.deletions }}{% endif %}
                </span>
              {% endif %}
            </li>
            <li>
                <a class="button view" href="{{ url_for('view_file', username=username,
                    repo=repo.name, identifier=commitid,
                    filename=patch.new_file_path) }}" title="View file as of {{ commitid|short }}">View</a>
            </li>
        </ul>
    </header>

    {% if patch.is_binary %}
        <p class="noresult">Binary diffs cannot be rendered.</p>
    {% else %}
        {% autoescape false %}
        {{ patch|patch_to_diff|html_diff|format_loc(diff_commits[loop.index - 1], pull_request,
            index=loop.index)}}
        {% endautoescape %}
    {% endif %}
</section>

{% endfor %}
  {% endfor %}
</section>


{% endblock %}

{% block jscripts %}
{{ super() }}
<script type="text/javascript">
 $(function(){
  $( "#branch_select" ).change(
    function() {
      var url = $(location).attr('href').split('?')[0];
      var params = $(location).attr('search').replace('?', '').split('&');
      var sel = $('#branch_select');
      /* Check all the current argument in the URL */
      var changed = false;
      for (i = 0; i < params.length; i++) {
        /* If we find branch=, updated it */
        if (params[i].match("^branch=")) {
          params[i] = 'branch=' + sel.val();
          changed = true;
        }
      }
      /* Otherwise add it */
      if (!changed) {
        params.push('branch=' + sel.val());
      }
      var final_url = url + '?' + params.join('&');
      window.location.href = final_url;
    }
  );

  $('#cancel_pr').click(function(){
        return window.confirm("Are you sure you want to cancel this requested pull?");
  });
 });

  function comment() {
    $( ".cancel" ).click(
      function() {
        $(this).parent().parent().parent().parent().remove();
      }
    );
  };

 $(function(){
  $( "tr" ).hover(
    function() {
      $( this ).find( "img" ).show().width(13);
    }, function() {
      $( this ).find( "img" ).hide();
    }
  );

  $( ".prc" ).click(
    function() {
      var row = $( this ).attr('data-row');
      var commit = $( this ).attr('data-commit');
      var url = "{{ url_for(
        'pull_request_add_comment', username=username, repo=repo.name,
        requestid=requestid, commit='', row='') }}".slice(0, -1);
      url = url + commit + '/' + row;
      var rowid = $(this).prev().find('a').attr('id');
      var table = $( this ).parent().parent();
      var nextid = rowid.replace('_' + row, '_' + (Number(row) + 1));
      var next_row = table.find('#' + nextid).parent().parent();
      if (next_row.prev().find('.pr_comment_form').length == 0){
        $.get( url , function( data ) {
          next_row.before(
            '<tr><td></td><td colspan="2" class="pr_comment_form">' + data + '</td></tr>' );
          comment();
        });
      } else {
          next_row.prev().find('.pr_comment_form').parent().remove();
      }
    }
  );

 });
</script>
{% endblock %}