all repos

mugit @ f421981

🐮 git server that your cow will love

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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
{{ define "repo_commit" }}
{{ $commit := .P.Diff.Commit }}
{{ $diff := .P.Diff.Diff }}
{{ $stat := .P.Diff.Stat }}
{{ $parents := .P.Diff.Parents }}
<html>
  <head>
    {{ template "head" . }}
    <title>{{ .RepoName }}: {{ $commit.HashShort }}</title>
  </head>
  <body>
    {{ template "repo_header" . }}
    <main>
      <section class="commit">
        <div class="commit-refs">
          <span class="diff-mod">{{ $stat.FilesChanged }} files changed</span>,
          <span class="diff-add">{{ $stat.Insertions }} insertions(+)</span>,
          <span class="diff-del">{{ $stat.Deletions }} deletions(-)</span>
        </div>

        <div class="box">
          <pre class="commit-message">
            {{- if $commit.Message }}{{- $commit.Message -}}
            {{- else -}}<span class="muted">Empty message</span>{{- end -}}
          </pre>
          <div>
            <strong>Author:</strong>
            {{ $commit.AuthorName }}
            <a href="mailto:{{ $commit.AuthorEmail }}" class="commit-email">{{ $commit.AuthorEmail }}</a>
          </div>
          {{ if ne $commit.AuthorEmail $commit.CommitterEmail }}
          <div>
            <strong>Committed by:</strong>
            {{ $commit.CommitterName }}
            <a href="mailto:{{ $commit.CommitterEmail }}" class="commit-email">{{ $commit.CommitterEmail }}</a>
          </div>
          {{ end }}
          <div>
            <strong>Committed at:</strong>
            {{ humanizeTime $commit.Committed }}
          </div>
          {{ if $commit.ChangeID -}}
          <div>
            <strong>Change ID:</strong>
            {{ $commit.ChangeID }}
          </div>
          {{- end }}
          {{ if $parents }}
          <div>
            <strong>Parent:</strong>
            {{ range $i, $p := $parents -}}
            {{ if $i }}, {{ end -}}
            <a class="link" href="/{{ $.RepoName }}/commit/{{ $p }}">{{ $p }}</a>
            {{- end }}
          </div>
          {{ end }}
        </div>

        {{ if gt (len $diff) 1 -}}
        <div class="jump">
          <strong>jump to</strong>
          <table class="table jump-table">
            <tbody>
              {{ range $diff }}
              {{ $path := .Name.New }}
              {{ if not $path }}{{ $path = .Name.Old }}{{ end }}
              <tr>
                <td class="diff-type">
                  {{ if .IsNew }}<span class="diff-type diff-add">A</span>
                  {{ else if .IsDelete }}<span class="diff-type diff-del">D</span>
                  {{ else }}<span class="diff-type diff-mod">M</span>{{ end }}
                </td>
                <td class="fill">
                  <a href="#{{ $path }}">
                    {{ if .IsRename }}{{ .Name.Old }} &#8594; {{ .Name.New }}
                    {{ else }}{{ $path }}{{ end }}
                  </a>
                </td>
              </tr>
              {{ end }}
            </tbody>
          </table>
        </div>
        {{ end }}
      </section>

      <section>
        {{ $this := $commit.Hash }}
        {{ $parent := "" }}
        {{ if $parents }}{{ $parent = index $parents 0 }}{{ end }}
        {{ range $diff }}
        {{ $path := .Name.New }}
        {{ if not $path }}{{ $path = .Name.Old }}{{ end }}
        <div id="{{ $path }}">
          <div class="diff">
            {{ if .IsNew }}<span class="diff-type diff-add">A</span>
            {{ else if .IsDelete }}<span class="diff-type diff-del">D</span>
            {{ else }}<span class="diff-type diff-mod">M</span>{{ end }}

            {{ if .IsNew }}<a href="/{{ $.RepoName }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>{{ else }}
            {{ if $parent }}<a href="/{{ $.RepoName }}/blob/{{ $parent }}/{{ .Name.New }}">{{ .Name.New }}</a>
            {{ else }}{{ .Name.Old }}{{ end }}
            {{ if .IsRename }}&#8594;<a href="/{{ $.RepoName }}/blob/{{ $this }}/{{ .Name.New }}">{{ .Name.New }}</a>{{ end }}
            {{ end }}

            {{ if .IsBinary }}
            <p>Not showing binary file.</p>
            {{ else }}
            <pre>
              {{- range .TextFragments -}}
              <p>{{- .Header -}}</p>
              {{- range .Lines -}}
              {{- if eq .Op.String "+" -}}<span class="diff-add">{{ .String }}</span>
              {{- else if eq .Op.String "-" -}}<span class="diff-del">{{ .String }}</span>
              {{- else -}}<span class="diff-noop">{{ .String }}</span>
              {{- end -}}
              {{- end -}}
              {{- end -}}
            </pre>
            {{ end }}
          </div>
        </div>
        {{ end }}
      </section>
    </main>
  </body>
</html>
{{ end }}