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="Close" 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, branch_from=branch_from,
    branch_to=branch_to) }}" method="post">
    <table>
      {{ render_field_in_row(form.title) }}
      <tr>
        <td>To branch</td>
        <td>
          <select id="branch_select" name="branch_to">
              <option>{{ branch_to }}</option>
            {% for branch in branches |reverse %}
              {% if branch != branch_to %}
              <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">


{% if diff %}
{% 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>
        {% if pull_request %}
        <a class="button view" href="{{
            url_for(
                'view_file',
                username=pull_request.repo_from.user.username,
                repo=pull_request.repo_from.name,
                identifier=pull_request.branch_from,
                filename=patch.new_file_path) }}"
        {% else %}
        <a class="button view" href="{{
            url_for(
                'view_file',
                username=username,
                repo=repo.name,
                identifier=branch_from,
                filename=patch.new_file_path) }}"
        {% endif %}
        {% if patch |hasattr('new_id') %}
        title="View file as of {{ patch.new_id|short }}">View</a>
        {% else %}
        title="View file as of {{ patch.new_oid|short }}">View</a>
        {% endif %}
      </li>
    </ul>
</header>
{% autoescape false %}
    {{ patch | patch_to_diff | html_diff | format_loc(
            filename=patch.new_file_path,
            commit=patch.new_id,
            prequest=pull_request,
            index=loop.index)}}
{% endautoescape %}
{% endfor %}
{% endif %}

</section>


{% endblock %}

{% block jscripts %}
{{ super() }}
<script type="text/javascript">
 $(function(){
  $( "#branch_select" ).change(
    function() {
      var sel = $('#branch_select');
      var final_url = "{{ url_for('.new_request_pull', username=username,
        repo=repo.name, commitid=commitid, branch_from=branch_from,
        branch_to='--') }}";
      final_url = final_url.replace('--', sel.val());
      window.location.href = final_url;
    }
  );
{% if pull_request %}
{# These lines are only for existing pull-requests, not new ones #}
  $('#cancel_pr').click(function(){
    return window.confirm("Are you sure you want to close 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 filename = $( this ).attr('data-filename');
      var url = "{{ url_for(
        'pull_request_add_comment', username=username, repo=repo.name,
        requestid=requestid, commit='', filename='', row='') }}".slice(0, -2);
      url = url + commit + '/' + filename + '/' + 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();
      }
    }
  );
{% endif %}

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