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 %}
<h3>Title: {{ pull_request.title }}</h3>
  {% if pull_request.status and repo_admin %}
  <div class="pr_actions">
    <form action="{{ url_for('merge_request_pull', username=username,
        repo=repo.name, requestid=requestid) }}" method="POST">
        {{ mergeform.csrf_token }}
        <input type="submit" value="Merge"/>
    </form>
    <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"/>
    </form>
  </div>
  {% elif pull_request and pull_request.status == False %}
  <span class="error">Merged</span>
  {% endif %}
{% 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 %}
        {{ commit.message.split('\n')[0] }}
      </a>
    </li>
    {% endfor %}
  </ul>
</section>

{% 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">
      <input type="button" value="Cancel" class="button" onclick="history.back();">
      {{ form.csrf_token }}
    </p>
  </form>
</section>
{% endif %}

<section class="request_diff">
  <h3>Diff:</h3>
  {% for html_diff in html_diffs %}
    <h3>Commit: {{ diff_commits[loop.index - 1].oid.hex }}</h3>

    <table>
      <tr>
        <td>Author</td>
        <td>
          {{ diff_commits[loop.index - 1].author.name }} {{ '<' + diff_commits[loop.index - 1].author.email + '>' }}
          - {{ diff_commits[loop.index - 1].commit_time | format_ts }}
        </td>
      </tr>
      <tr>
        <td>Committer</td>
        <td>
          {{ diff_commits[loop.index - 1].committer.name }} {{ '<' + diff_commits[loop.index - 1].committer.email + '>' }}
          - {{ diff_commits[loop.index - 1].commit_time | format_ts }}
        </td>
      </tr>
      <tr>
        <td>Parent</td>
        <td>
          {% for parent in diff_commits[loop.index - 1].parents %}
            <a href="{{ url_for('view_commit', username=username,
                      repo=repo.name, commitid=parent.oid.hex) }}">

            {{ parent.oid.hex }}
          </a> <br />
          {% endfor %}
        </td>
      </tr>
    </table>
    <p>
    {{ diff_commits[loop.index - 1].message }}
    </p>
    {% autoescape false %}
        {{ html_diff | format_loc(diff_commits[loop.index - 1], pull_request,
            index=loop.index) }}
    {% endautoescape %}
  {% 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 %}