Sam Jeston
History
92 lines·
4.4 KB
·HTML
| 1 | {% extends "layout_repo.html" %} |
| 2 | {% block page_title %}Compare · {% endblock %} |
| 3 | {% block content %} |
| 4 | {% let base = r.base() %} |
| 5 | <div class="page-subheader page-subheader-stacked"> |
| 6 | <h2>Compare changes</h2> |
| 7 | <p class="text-muted">Choose two branches to see what has changed or to open a pull request.</p> |
| 8 | </div> |
| 9 | <form class="compare-bar box" method="get" action="{{ base }}/compare"> |
| 10 | <span class="compare-icon">{{ crate::web::fmt::icon("git-compare")|safe }}</span> |
| 11 | <label class="compare-select"><span>base:</span> |
| 12 | <select class="input input-sm" name="base" data-autosubmit> |
| 13 | {% for b in view.branches %}<option value="{{ b }}"{% if *b == view.base %} selected{% endif %}>{{ b }}</option>{% endfor %} |
| 14 | </select> |
| 15 | </label> |
| 16 | <span class="compare-arrow">←</span> |
| 17 | <label class="compare-select"><span>compare:</span> |
| 18 | <select class="input input-sm" name="head" data-autosubmit> |
| 19 | <option value="">choose a branch…</option> |
| 20 | {% for b in view.branches %}<option value="{{ b }}"{% if *b == view.head %} selected{% endif %}>{{ b }}</option>{% endfor %} |
| 21 | </select> |
| 22 | </label> |
| 23 | <noscript><button class="btn btn-sm" type="submit">Compare</button></noscript> |
| 24 | {% if let Some(m) = view.mergeability %} |
| 25 | {% match m %} |
| 26 | {% when crate::git::Mergeability::Clean %}<span class="merge-hint text-success">{{ crate::web::fmt::icon("check")|safe }} <strong>Able to merge.</strong> These branches can be automatically merged.</span> |
| 27 | {% when crate::git::Mergeability::Conflicts %}<span class="merge-hint text-danger">{{ crate::web::fmt::icon("x")|safe }} <strong>Can't automatically merge.</strong> You can still open the pull request.</span> |
| 28 | {% when crate::git::Mergeability::UpToDate %} |
| 29 | {% endmatch %} |
| 30 | {% endif %} |
| 31 | </form> |
| 32 | |
| 33 | {% if let Some(notice) = view.notice %} |
| 34 | <div class="blankslate box"> |
| 35 | {{ crate::web::fmt::icon("git-compare")|safe }} |
| 36 | <h3>{{ notice }}</h3> |
| 37 | </div> |
| 38 | {% else %} |
| 39 | {% if let Some(n) = view.existing %} |
| 40 | <div class="banner"> |
| 41 | <span>{{ crate::web::fmt::icon("git-pull-request")|safe }} There is already an open pull request for these branches.</span> |
| 42 | <a class="btn btn-sm" href="{{ base }}/pull/{{ n }}">View pull request #{{ n }}</a> |
| 43 | </div> |
| 44 | {% else if view.can_open() %} |
| 45 | {% if ctx.user.is_some() %} |
| 46 | <form method="post" action="{{ base }}/pulls" class="box new-pull"> |
| 47 | <div class="new-pull-body"> |
| 48 | {% if let Some(u) = ctx.user %}{{ crate::web::fmt::avatar(u.username, 40)|safe }}{% endif %} |
| 49 | <div class="new-pull-fields"> |
| 50 | <input type="hidden" name="base" value="{{ view.base }}"> |
| 51 | <input type="hidden" name="head" value="{{ view.head }}"> |
| 52 | <label class="field"> |
| 53 | <span class="field-label">Title</span> |
| 54 | <input class="input" type="text" name="title" value="{{ view.title }}" maxlength="256" required> |
| 55 | </label> |
| 56 | <label class="field"> |
| 57 | <span class="field-label">Description</span> |
| 58 | <textarea class="input" name="body" rows="8" placeholder="Describe your changes. Markdown is supported."></textarea> |
| 59 | </label> |
| 60 | <div class="form-actions"><button class="btn btn-success" type="submit">Create pull request</button></div> |
| 61 | </div> |
| 62 | </div> |
| 63 | </form> |
| 64 | {% else %} |
| 65 | <div class="banner"><span><a href="/login?next={{ crate::web::fmt::urlencode(ctx.path) }}">Sign in</a> to open a pull request.</span></div> |
| 66 | {% endif %} |
| 67 | {% endif %} |
| 68 | |
| 69 | <div class="compare-summary box"> |
| 70 | <span>{{ crate::web::fmt::icon("git-commit-horizontal")|safe }} <strong>{{ crate::web::fmt::plural(view.commits.len(), "commit") }}</strong></span> |
| 71 | {% if let Some(d) = view.diff %} |
| 72 | <span>{{ crate::web::fmt::icon("file-text")|safe }} <strong>{{ crate::web::fmt::plural(d.files.len(), "file") }} changed</strong></span> |
| 73 | {% endif %} |
| 74 | </div> |
| 75 | |
| 76 | <div class="box compare-commits"> |
| 77 | {% for c in view.commits %} |
| 78 | <div class="box-row commit-row commit-row-compact"> |
| 79 | {{ crate::web::fmt::avatar(c.author_name, 20)|safe }} |
| 80 | <span class="text-muted text-small commit-row-author">{{ c.author_name }}</span> |
| 81 | <a class="commit-title truncate" href="{{ base }}/commit/{{ c.id }}">{{ c.summary }}</a> |
| 82 | <a class="text-mono text-muted text-small" href="{{ base }}/commit/{{ c.id }}">{{ c.short_id }}</a> |
| 83 | </div> |
| 84 | {% endfor %} |
| 85 | </div> |
| 86 | |
| 87 | {% if let Some(diff) = view.diff %} |
| 88 | {% let file_ref = crate::web::fmt::urlpath(view.head) %} |
| 89 | {% include "partials/diff.html" %} |
| 90 | {% endif %} |
| 91 | {% endif %} |
| 92 | {% endblock %} |