all repos

mugit @ 3d3163cbe3c536974f0bf4f6d2be3a6efa8b25b2

🐮 git server that your cow will love

mugit/web/templates/repo_commit.html (view raw)

Oleksandr Smirnov Oleksandr Smirnov
olexsmir@gmail.com
fix(ui): show filename of modified files, 3 months ago
1
{{ define "repo_commit" }}
2
{{ $commit := .P.Diff.Commit }}
3
{{ $diff := .P.Diff.Diff }}
4
{{ $stat := .P.Diff.Stat }}
5
{{ $parents := .P.Diff.Parents }}
6
<html>
7
  <head>
8
    {{ template "head" . }}
9
    <title>{{ .RepoName }}: {{ $commit.HashShort }}</title>
10
  </head>
11
  <body>
12
    {{ template "repo_header" . }}
13
    <main>
14
      <section class="commit">
15
        <div class="commit-refs">
16
          <span class="diff-mod">{{ $stat.FilesChanged }} files changed</span>,
17
          <span class="diff-add">{{ $stat.Insertions }} insertions(+)</span>,
18
          <span class="diff-del">{{ $stat.Deletions }} deletions(-)</span>
19
        </div>
20
21
        <div class="box">
22
          <pre class="commit-message">
23
            {{- if $commit.Message }}{{- $commit.Message -}}
24
            {{- else -}}<span class="muted">Empty message</span>{{- end -}}
25
          </pre>
26
          <div>
27
            <strong>Author:</strong>
28
            {{ $commit.AuthorName }}
29
            <a href="mailto:{{ $commit.AuthorEmail }}" class="commit-email">{{ $commit.AuthorEmail }}</a>
30
          </div>
31
          {{ if ne $commit.AuthorEmail $commit.CommitterEmail }}
32
          <div>
33
            <strong>Committed by:</strong>
34
            {{ $commit.CommitterName }}
35
            <a href="mailto:{{ $commit.CommitterEmail }}" class="commit-email">{{ $commit.CommitterEmail }}</a>
36
          </div>
37
          {{ end }}
38
          <div>
39
            <strong>Committed at:</strong>
40
            {{ humanizeTime $commit.Committed }}
41
          </div>
42
          {{ if $commit.ChangeID -}}
43
          <div>
44
            <strong>Change ID:</strong>
45
            {{ $commit.ChangeID }}
46
          </div>
47
          {{- end }}
48
          {{ if $parents }}
49
          <div>
50
            <strong>Parent:</strong>
51
            {{ range $i, $p := $parents -}}
52
            {{ if $i }}, {{ end -}}
53
            <a class="link" href="/{{ $.RepoName }}/commit/{{ $p }}">{{ $p }}</a>
54
            {{- end }}
55
          </div>
56
          {{ end }}
57
        </div>
58
59
        {{ if gt (len $diff) 1 -}}
60
        <div class="jump">
61
          <strong>jump to</strong>
62
          <table class="table jump-table">
63
            <tbody>
64
              {{ range $diff }}
65
              {{ $path := .Name.New }}
66
              {{ if not $path }}{{ $path = .Name.Old }}{{ end }}
67
              <tr>
68
                <td class="diff-type">
69
                  {{ if .IsNew }}<span class="diff-type diff-add">A</span>
70
                  {{ else if .IsDelete }}<span class="diff-type diff-del">D</span>
71
                  {{ else }}<span class="diff-type diff-mod">M</span>{{ end }}
72
                </td>
73
                <td class="fill">
74
                  <a href="#{{ $path }}">
75
                    {{ if .IsRename }}{{ .Name.Old }} &#8594; {{ .Name.New }}
76
                    {{ else }}{{ $path }}{{ end }}
77
                  </a>
78
                </td>
79
              </tr>
80
              {{ end }}
81
            </tbody>
82
          </table>
83
        </div>
84
        {{ end }}
85
      </section>
86
87
      <section>
88
        {{ $this := $commit.Hash }}
89
        {{ $parent := "" }}
90
        {{ if $parents }}{{ $parent = index $parents 0 }}{{ end }}
91
        {{ range $diff }}
92
        {{ $path := .Name.New }}
93
        {{ if not $path }}{{ $path = .Name.Old }}{{ end }}
94
        <div id="{{ $path }}">
95
          <div class="diff">
96
            {{ if .IsNew }}<span class="diff-type diff-add">A</span>
97
            {{ else if .IsDelete }}<span class="diff-type diff-del">D</span>
98
            {{ else }}<span class="diff-type diff-mod">M</span>{{ end }}
99
100
            {{ if .IsNew }}<a href="/{{ $.RepoName }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>{{ else }}
101
            {{ if $parent }}<a href="/{{ $.RepoName }}/blob/{{ $parent }}/{{ .Name.New }}">{{ .Name.New }}</a>
102
            {{ else }}{{ .Name.Old }}{{ end }}
103
            {{ if .IsRename }}&#8594;<a href="/{{ $.RepoName }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>{{ end }}
104
            {{ end }}
105
106
            {{ if .IsBinary }}
107
            <p>Not showing binary file.</p>
108
            {{ else }}
109
            <pre>
110
              {{- range .TextFragments -}}
111
              <p>{{- .Header -}}</p>
112
              {{- range .Lines -}}
113
              {{- if eq .Op.String "+" -}}<span class="diff-add">{{ .String }}</span>
114
              {{- else if eq .Op.String "-" -}}<span class="diff-del">{{ .String }}</span>
115
              {{- else -}}<span class="diff-noop">{{ .String }}</span>
116
              {{- end -}}
117
              {{- end -}}
118
              {{- end -}}
119
            </pre>
120
            {{ end }}
121
          </div>
122
        </div>
123
        {{ end }}
124
      </section>
125
    </main>
126
  </body>
127
</html>
128
{{ end }}