@@ -0,0 +1,71 @@ |
| 1 | +{{ define "page" -}} |
| 2 | +<section class="shithub-settings-branches"> |
| 3 | + <header class="shithub-code-head"> |
| 4 | + <h1> |
| 5 | + <a href="/{{ .Owner }}/{{ .Repo.Name }}/tree/{{ .Repo.DefaultBranch }}">{{ .Owner }}/{{ .Repo.Name }}</a> |
| 6 | + <span class="shithub-code-sep">/</span> |
| 7 | + Branch protection |
| 8 | + </h1> |
| 9 | + </header> |
| 10 | + |
| 11 | + <section class="shithub-danger-zone"> |
| 12 | + <h2>Default branch</h2> |
| 13 | + <p>Current: <code>{{ .Repo.DefaultBranch }}</code></p> |
| 14 | + <form method="POST" action="/{{ .Owner }}/{{ .Repo.Name }}/settings/default-branch"> |
| 15 | + <input type="hidden" name="csrf_token" value="{{ .CSRFToken }}"> |
| 16 | + <label>New default branch |
| 17 | + <select name="default_branch"> |
| 18 | + {{ range .Branches }}<option value="{{ .Name }}" {{ if eq .Name $.Repo.DefaultBranch }}selected{{ end }}>{{ .Name }}</option>{{ end }} |
| 19 | + </select> |
| 20 | + </label> |
| 21 | + <button type="submit" class="shithub-button">Update default</button> |
| 22 | + </form> |
| 23 | + </section> |
| 24 | + |
| 25 | + <section class="shithub-danger-zone"> |
| 26 | + <h2>Protection rules</h2> |
| 27 | + {{ if .Rules }} |
| 28 | + <table class="shithub-branches-table"> |
| 29 | + <thead> |
| 30 | + <tr><th>Pattern</th><th>Force-push</th><th>Deletion</th><th>Allowed pushers</th><th></th></tr> |
| 31 | + </thead> |
| 32 | + <tbody> |
| 33 | + {{ range .Rules }} |
| 34 | + <tr> |
| 35 | + <td><code>{{ .Pattern }}</code></td> |
| 36 | + <td>{{ if .PreventForcePush }}🚫{{ else }}allowed{{ end }}</td> |
| 37 | + <td>{{ if .PreventDeletion }}🚫{{ else }}allowed{{ end }}</td> |
| 38 | + <td>{{ len .AllowedPusherUserIds }} {{ if eq (len .AllowedPusherUserIds) 1 }}user{{ else }}users{{ end }}</td> |
| 39 | + <td> |
| 40 | + <form method="POST" action="/{{ $.Owner }}/{{ $.Repo.Name }}/settings/branches/{{ .ID }}/delete" style="display:inline"> |
| 41 | + <input type="hidden" name="csrf_token" value="{{ $.CSRFToken }}"> |
| 42 | + <button type="submit" class="shithub-button shithub-button-danger">Delete</button> |
| 43 | + </form> |
| 44 | + </td> |
| 45 | + </tr> |
| 46 | + {{ end }} |
| 47 | + </tbody> |
| 48 | + </table> |
| 49 | + {{ else }} |
| 50 | + <p>No rules configured. Add one below to protect a branch pattern.</p> |
| 51 | + {{ end }} |
| 52 | + </section> |
| 53 | + |
| 54 | + <section class="shithub-danger-zone"> |
| 55 | + <h2>New rule</h2> |
| 56 | + <form method="POST" action="/{{ .Owner }}/{{ .Repo.Name }}/settings/branches"> |
| 57 | + <input type="hidden" name="csrf_token" value="{{ .CSRFToken }}"> |
| 58 | + <label>Pattern (glob: <code>*</code>, <code>?</code>, <code>[abc]</code>; <code>*</code> doesn't cross <code>/</code>) |
| 59 | + <input type="text" name="pattern" required placeholder="e.g. trunk or release/*"> |
| 60 | + </label> |
| 61 | + <label><input type="checkbox" name="prevent_force_push" checked> Prevent force-push</label> |
| 62 | + <label><input type="checkbox" name="prevent_deletion" checked> Prevent deletion</label> |
| 63 | + <label><input type="checkbox" name="require_pr_for_push"> Require PR for push (placeholder; enforced post-MVP)</label> |
| 64 | + <label>Allowed pushers (comma-separated usernames; leave blank for "any collaborator") |
| 65 | + <input type="text" name="allowed_pushers" placeholder="alice, bob"> |
| 66 | + </label> |
| 67 | + <button type="submit" class="shithub-button shithub-button-primary">Create rule</button> |
| 68 | + </form> |
| 69 | + </section> |
| 70 | +</section> |
| 71 | +{{- end }} |