+3
-1
appview/pages/pages.go
+3
-1
appview/pages/pages.go
···
436
436
EmailToDidOrHandle map[string]string
437
437
VerifiedCommits commitverify.VerifiedCommits
438
438
Languages *types.RepoLanguageResponse
439
-
Pipelines map[plumbing.Hash]db.Pipeline
439
+
Pipelines map[string]db.Pipeline
440
440
types.RepoIndexResponse
441
441
}
442
442
···
475
475
Active string
476
476
EmailToDidOrHandle map[string]string
477
477
VerifiedCommits commitverify.VerifiedCommits
478
+
Pipelines map[string]db.Pipeline
478
479
}
479
480
480
481
func (p *Pages) RepoLog(w io.Writer, params RepoLogParams) error {
···
487
488
RepoInfo repoinfo.RepoInfo
488
489
Active string
489
490
EmailToDidOrHandle map[string]string
491
+
Pipeline *db.Pipeline
490
492
491
493
// singular because it's always going to be just one
492
494
VerifiedCommit commitverify.VerifiedCommits
+6
appview/pages/templates/repo/commit.html
+6
appview/pages/templates/repo/commit.html
+2
-1
appview/pages/templates/repo/fragments/pipelineStatusSymbol.html
+2
-1
appview/pages/templates/repo/fragments/pipelineStatusSymbol.html
···
15
15
16
16
{{ if $allPass }}
17
17
<div class="flex gap-1 items-center">
18
-
{{ i "check" "size-4 text-green-600 dark:text-green-400 " }} {{ $total }}/{{ $total }}
18
+
{{ i "check" "size-4 text-green-600 dark:text-green-400 " }}
19
+
<span>{{ $total }}/{{ $total }}</span>
19
20
</div>
20
21
{{ else }}
21
22
{{ $radius := f64 8 }}
+1
-1
appview/pages/templates/repo/index.html
+1
-1
appview/pages/templates/repo/index.html
···
272
272
{{ end }}
273
273
274
274
<!-- ci status -->
275
-
{{ $pipeline := index $.Pipelines .Hash }}
275
+
{{ $pipeline := index $.Pipelines .Hash.String }}
276
276
{{ if and $pipeline (gt (len $pipeline.Statuses) 0) }}
277
277
<div class="inline-block px-1 select-none after:content-['·']"></div>
278
278
{{ template "repo/fragments/pipelineStatusSymbol" $pipeline }}
+64
-51
appview/pages/templates/repo/log.html
+64
-51
appview/pages/templates/repo/log.html
···
20
20
<th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Author</th>
21
21
<th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Commit</th>
22
22
<th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Message</th>
23
+
<th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold"></th>
23
24
<th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Date</th>
24
25
</tr>
25
26
</thead>
···
57
58
{{ i "folder-code" "w-4 h-4" }}
58
59
</a>
59
60
</div>
61
+
60
62
</td>
61
63
<td class=" py-3 align-top">
62
-
<div>
63
-
<div class="flex items-center justify-start">
64
-
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" class="dark:text-white no-underline hover:underline">{{ index $messageParts 0 }}</a>
65
-
{{ if gt (len $messageParts) 1 }}
66
-
<button class="ml-2 py-1/2 px-1 bg-gray-200 hover:bg-gray-400 dark:bg-gray-700 dark:hover:bg-gray-600 rounded" hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">{{ i "ellipsis" "w-3 h-3" }}</button>
67
-
{{ end }}
68
-
69
-
70
-
{{ if index $.TagMap $commit.Hash.String }}
71
-
{{ range $tag := index $.TagMap $commit.Hash.String }}
72
-
<span class="ml-2 text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 inline-flex items-center">
73
-
{{ $tag }}
74
-
</span>
75
-
{{ end }}
76
-
{{ end }}
77
-
78
-
</div>
79
-
64
+
<div class="flex items-center justify-start gap-2">
65
+
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}" class="dark:text-white no-underline hover:underline">{{ index $messageParts 0 }}</a>
80
66
{{ if gt (len $messageParts) 1 }}
81
-
<p class="hidden mt-1 text-sm text-gray-600 dark:text-gray-400">{{ nl2br (index $messageParts 1) }}</p>
67
+
<button class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 dark:bg-gray-700 dark:hover:bg-gray-600 rounded" hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">{{ i "ellipsis" "w-3 h-3" }}</button>
82
68
{{ end }}
69
+
70
+
{{ if index $.TagMap $commit.Hash.String }}
71
+
{{ range $tag := index $.TagMap $commit.Hash.String }}
72
+
<span class="ml-2 text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 inline-flex items-center">
73
+
{{ $tag }}
74
+
</span>
75
+
{{ end }}
76
+
{{ end }}
77
+
</div>
78
+
79
+
{{ if gt (len $messageParts) 1 }}
80
+
<p class="hidden mt-1 text-sm text-gray-600 dark:text-gray-400">{{ nl2br (index $messageParts 1) }}</p>
81
+
{{ end }}
82
+
</td>
83
+
<td class="py-3 align-top">
84
+
<!-- ci status -->
85
+
{{ $pipeline := index $.Pipelines .Hash.String }}
86
+
{{ if and $pipeline (gt (len $pipeline.Statuses) 0) }}
87
+
{{ template "repo/fragments/pipelineStatusSymbol" $pipeline }}
88
+
{{ end }}
83
89
</td>
84
90
<td class=" py-3 align-top text-gray-500 dark:text-gray-400">{{ timeFmt $commit.Committer.When }}</td>
85
91
</tr>
···
94
100
<div id="commit-message">
95
101
{{ $messageParts := splitN $commit.Message "\n\n" 2 }}
96
102
<div class="text-base cursor-pointer">
97
-
<div>
98
-
<div class="flex items-center justify-between">
99
-
<div class="flex-1">
100
-
<div class="inline">
101
-
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}"
102
-
class="inline no-underline hover:underline dark:text-white">
103
-
{{ index $messageParts 0 }}
104
-
</a>
105
-
{{ if gt (len $messageParts) 1 }}
106
-
<button
107
-
class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600 ml-2"
108
-
hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">
109
-
{{ i "ellipsis" "w-3 h-3" }}
110
-
</button>
111
-
{{ end }}
103
+
<div class="flex items-center justify-between">
104
+
<div class="flex-1">
105
+
<div class="inline-flex items-end">
106
+
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}"
107
+
class="inline no-underline hover:underline dark:text-white">
108
+
{{ index $messageParts 0 }}
109
+
</a>
110
+
{{ if gt (len $messageParts) 1 }}
111
+
<button
112
+
class="py-1/2 px-1 bg-gray-200 hover:bg-gray-400 rounded dark:bg-gray-700 dark:hover:bg-gray-600 ml-2"
113
+
hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">
114
+
{{ i "ellipsis" "w-3 h-3" }}
115
+
</button>
116
+
{{ end }}
112
117
113
-
{{ if index $.TagMap $commit.Hash.String }}
114
-
{{ range $tag := index $.TagMap $commit.Hash.String }}
115
-
<span class="ml-2 text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 inline-flex items-center">
116
-
{{ $tag }}
117
-
</span>
118
-
{{ end }}
118
+
{{ if index $.TagMap $commit.Hash.String }}
119
+
{{ range $tag := index $.TagMap $commit.Hash.String }}
120
+
<span class="ml-2 text-xs rounded bg-gray-100 dark:bg-gray-700 text-black dark:text-white font-mono px-2 inline-flex items-center">
121
+
{{ $tag }}
122
+
</span>
119
123
{{ end }}
120
-
</div>
121
-
122
-
{{ if gt (len $messageParts) 1 }}
123
-
<p class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300">
124
-
{{ nl2br (index $messageParts 1) }}
125
-
</p>
126
124
{{ end }}
127
125
</div>
128
-
<a href="/{{ $.RepoInfo.FullName }}/tree/{{ $commit.Hash.String }}"
129
-
class="p-1 mr-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"
130
-
title="Browse repository at this commit">
131
-
{{ i "folder-code" "w-4 h-4" }}
132
-
</a>
126
+
127
+
{{ if gt (len $messageParts) 1 }}
128
+
<p class="hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300">
129
+
{{ nl2br (index $messageParts 1) }}
130
+
</p>
131
+
{{ end }}
133
132
</div>
133
+
<a href="/{{ $.RepoInfo.FullName }}/tree/{{ $commit.Hash.String }}"
134
+
class="p-1 mr-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"
135
+
title="Browse repository at this commit">
136
+
{{ i "folder-code" "w-4 h-4" }}
137
+
</a>
134
138
</div>
135
139
</div>
136
140
</div>
···
160
164
</span>
161
165
<div class="inline-block px-1 select-none after:content-['·']"></div>
162
166
<span>{{ shortTimeFmt $commit.Committer.When }}</span>
167
+
168
+
<!-- ci status -->
169
+
{{ $pipeline := index $.Pipelines .Hash.String }}
170
+
{{ if and $pipeline (gt (len $pipeline.Statuses) 0) }}
171
+
<div class="inline-block px-1 select-none after:content-['·']"></div>
172
+
<span class="text-sm">
173
+
{{ template "repo/fragments/pipelineStatusSymbol" $pipeline }}
174
+
</span>
175
+
{{ end }}
163
176
</div>
164
177
</div>
165
178
{{ end }}
+5
-1
appview/repo/index.go
+5
-1
appview/repo/index.go
···
127
127
// non-fatal
128
128
}
129
129
130
-
pipelines, err := rp.getPipelineStatuses(repoInfo, commitsTrunc)
130
+
var shas []string
131
+
for _, c := range commitsTrunc {
132
+
shas = append(shas, c.Hash.String())
133
+
}
134
+
pipelines, err := rp.getPipelineStatuses(repoInfo, shas)
131
135
if err != nil {
132
136
log.Printf("failed to fetch pipeline statuses: %s", err)
133
137
// non-fatal
+26
-1
appview/repo/repo.go
+26
-1
appview/repo/repo.go
···
133
133
log.Println(err)
134
134
}
135
135
136
+
repoInfo := f.RepoInfo(user)
137
+
138
+
var shas []string
139
+
for _, c := range repolog.Commits {
140
+
shas = append(shas, c.Hash.String())
141
+
}
142
+
pipelines, err := rp.getPipelineStatuses(repoInfo, shas)
143
+
if err != nil {
144
+
log.Println(err)
145
+
// non-fatal
146
+
}
147
+
136
148
rp.pages.RepoLog(w, pages.RepoLogParams{
137
149
LoggedInUser: user,
138
150
TagMap: tagMap,
139
-
RepoInfo: f.RepoInfo(user),
151
+
RepoInfo: repoInfo,
140
152
RepoLogResponse: *repolog,
141
153
EmailToDidOrHandle: emailToDidOrHandle(rp, emailToDidMap),
142
154
VerifiedCommits: vc,
155
+
Pipelines: pipelines,
143
156
})
144
157
return
145
158
}
···
289
302
}
290
303
291
304
user := rp.oauth.GetUser(r)
305
+
repoInfo := f.RepoInfo(user)
306
+
pipelines, err := rp.getPipelineStatuses(repoInfo, []string{result.Diff.Commit.This})
307
+
if err != nil {
308
+
log.Println(err)
309
+
// non-fatal
310
+
}
311
+
var pipeline *db.Pipeline
312
+
if p, ok := pipelines[result.Diff.Commit.This]; ok {
313
+
pipeline = &p
314
+
}
315
+
292
316
rp.pages.RepoCommit(w, pages.RepoCommitParams{
293
317
LoggedInUser: user,
294
318
RepoInfo: f.RepoInfo(user),
295
319
RepoCommitResponse: result,
296
320
EmailToDidOrHandle: emailToDidOrHandle(rp, emailToDidMap),
297
321
VerifiedCommit: vc,
322
+
Pipeline: pipeline,
298
323
})
299
324
return
300
325
}
+5
-12
appview/repo/repo_util.go
+5
-12
appview/repo/repo_util.go
···
9
9
"tangled.sh/tangled.sh/core/appview/db"
10
10
"tangled.sh/tangled.sh/core/appview/pages/repoinfo"
11
11
12
-
"github.com/go-git/go-git/v5/plumbing"
13
12
"github.com/go-git/go-git/v5/plumbing/object"
14
13
)
15
14
···
108
107
// golang is so blessed that it requires 35 lines of imperative code for this
109
108
func (rp *Repo) getPipelineStatuses(
110
109
repoInfo repoinfo.RepoInfo,
111
-
commits []*object.Commit,
112
-
) (map[plumbing.Hash]db.Pipeline, error) {
113
-
m := make(map[plumbing.Hash]db.Pipeline)
110
+
shas []string,
111
+
) (map[string]db.Pipeline, error) {
112
+
m := make(map[string]db.Pipeline)
114
113
115
-
if len(commits) == 0 {
114
+
if len(shas) == 0 {
116
115
return m, nil
117
-
}
118
-
119
-
shas := make([]string, len(commits))
120
-
for _, c := range commits {
121
-
shas = append(shas, c.Hash.String())
122
116
}
123
117
124
118
ps, err := db.GetPipelineStatuses(
···
133
127
}
134
128
135
129
for _, p := range ps {
136
-
hash := plumbing.NewHash(p.Sha)
137
-
m[hash] = p
130
+
m[p.Sha] = p
138
131
}
139
132
140
133
return m, nil