| 1 | {{ define "page" -}} |
| 2 | <div class="shithub-settings-page"> |
| 3 | {{ template "repo-settings-nav" . }} |
| 4 | <div class="shithub-settings-content"> |
| 5 | <h1>Branches</h1> |
| 6 | {{ with .Notice }}<p class="shithub-flash shithub-flash-notice" role="status">{{ . }}</p>{{ end }} |
| 7 | |
| 8 | <section class="shithub-settings-section"> |
| 9 | <h2>Default branch</h2> |
| 10 | <p>Current: <code>{{ .Repo.DefaultBranch }}</code></p> |
| 11 | <form method="POST" action="/{{ .Owner }}/{{ .Repo.Name }}/settings/default-branch"> |
| 12 | <input type="hidden" name="csrf_token" value="{{ .CSRFToken }}"> |
| 13 | <label>New default branch |
| 14 | <select name="default_branch"> |
| 15 | {{ range .Branches }}<option value="{{ .Name }}" {{ if eq .Name $.Repo.DefaultBranch }}selected{{ end }}>{{ .Name }}</option>{{ end }} |
| 16 | </select> |
| 17 | </label> |
| 18 | <button type="submit" class="shithub-button">Update default</button> |
| 19 | </form> |
| 20 | </section> |
| 21 | |
| 22 | <section class="shithub-settings-section"> |
| 23 | <h2>Protection rules</h2> |
| 24 | {{ if .Rules }} |
| 25 | <table class="shithub-branches-table"> |
| 26 | <thead> |
| 27 | <tr><th>Pattern</th><th>Force-push</th><th>Deletion</th><th>Allowed pushers</th><th>Required reviews</th><th></th></tr> |
| 28 | </thead> |
| 29 | <tbody> |
| 30 | {{ range .Rules }} |
| 31 | <tr> |
| 32 | <td><code>{{ .Pattern }}</code></td> |
| 33 | <td>{{ if .PreventForcePush }}🚫{{ else }}allowed{{ end }}</td> |
| 34 | <td>{{ if .PreventDeletion }}🚫{{ else }}allowed{{ end }}</td> |
| 35 | <td>{{ len .AllowedPusherUserIds }} {{ if eq (len .AllowedPusherUserIds) 1 }}user{{ else }}users{{ end }}</td> |
| 36 | <td>{{ .RequiredReviewCount }}{{ if .DismissStaleReviewsOnPush }} · dismiss-stale{{ end }}{{ if .StatusChecksRequired }} · checks: {{ range $i, $n := .StatusChecksRequired }}{{ if $i }}, {{ end }}<code>{{ $n }}</code>{{ end }}{{ end }}</td> |
| 37 | <td> |
| 38 | <form method="POST" action="/{{ $.Owner }}/{{ $.Repo.Name }}/settings/branches/{{ .ID }}/delete" style="display:inline"> |
| 39 | <input type="hidden" name="csrf_token" value="{{ $.CSRFToken }}"> |
| 40 | <button type="submit" class="shithub-button shithub-button-danger">Delete</button> |
| 41 | </form> |
| 42 | </td> |
| 43 | </tr> |
| 44 | {{ end }} |
| 45 | </tbody> |
| 46 | </table> |
| 47 | {{ else }} |
| 48 | <p>No rules configured. Add one below to protect a branch pattern.</p> |
| 49 | {{ end }} |
| 50 | </section> |
| 51 | |
| 52 | <section class="shithub-settings-section"> |
| 53 | <h2>New rule</h2> |
| 54 | <form method="POST" action="/{{ .Owner }}/{{ .Repo.Name }}/settings/branches"> |
| 55 | <input type="hidden" name="csrf_token" value="{{ .CSRFToken }}"> |
| 56 | <label>Pattern (glob: <code>*</code>, <code>?</code>, <code>[abc]</code>; <code>*</code> doesn't cross <code>/</code>) |
| 57 | <input type="text" name="pattern" required placeholder="e.g. trunk or release/*"> |
| 58 | </label> |
| 59 | <label><input type="checkbox" name="prevent_force_push" checked> Prevent force-push</label> |
| 60 | <label><input type="checkbox" name="prevent_deletion" checked> Prevent deletion</label> |
| 61 | <label><input type="checkbox" name="require_pr_for_push"> Require PR for push (placeholder; enforced post-MVP)</label> |
| 62 | <label><input type="checkbox" name="require_signed_commits"> Require signed commits (visible toggle; underlying enforcement ships with commit signing)</label> |
| 63 | <label>Allowed pushers (comma-separated usernames; leave blank for "any collaborator") |
| 64 | <input type="text" name="allowed_pushers" placeholder="alice, bob"> |
| 65 | </label> |
| 66 | <label>Required reviews (S23) — number of approving reviews required before merge |
| 67 | <input type="number" name="required_review_count" min="0" value="0"> |
| 68 | </label> |
| 69 | <label><input type="checkbox" name="dismiss_stale_reviews_on_push"> Dismiss stale reviews on new push (S23)</label> |
| 70 | <label>Required status checks (S24) — comma-separated check-run names that must succeed on the head SHA |
| 71 | <input type="text" name="required_status_check_names" placeholder="lint, unit-tests"> |
| 72 | </label> |
| 73 | <label><input type="checkbox" name="dismiss_stale_status_checks_on_push"> Mark in-flight checks stale on new push (S24)</label> |
| 74 | <button type="submit" class="shithub-button shithub-button-primary">Create rule</button> |
| 75 | </form> |
| 76 | </section> |
| 77 | </div> |
| 78 | </div> |
| 79 | {{- end }} |