+3
-1
appview/pages/pages.go
+3
-1
appview/pages/pages.go
···
436
EmailToDidOrHandle map[string]string
437
VerifiedCommits commitverify.VerifiedCommits
438
Languages *types.RepoLanguageResponse
439
-
Pipelines map[plumbing.Hash]db.Pipeline
440
types.RepoIndexResponse
441
}
442
···
475
Active string
476
EmailToDidOrHandle map[string]string
477
VerifiedCommits commitverify.VerifiedCommits
478
}
479
480
func (p *Pages) RepoLog(w io.Writer, params RepoLogParams) error {
···
487
RepoInfo repoinfo.RepoInfo
488
Active string
489
EmailToDidOrHandle map[string]string
490
491
// singular because it's always going to be just one
492
VerifiedCommit commitverify.VerifiedCommits
···
436
EmailToDidOrHandle map[string]string
437
VerifiedCommits commitverify.VerifiedCommits
438
Languages *types.RepoLanguageResponse
439
+
Pipelines map[string]db.Pipeline
440
types.RepoIndexResponse
441
}
442
···
475
Active string
476
EmailToDidOrHandle map[string]string
477
VerifiedCommits commitverify.VerifiedCommits
478
+
Pipelines map[string]db.Pipeline
479
}
480
481
func (p *Pages) RepoLog(w io.Writer, params RepoLogParams) error {
···
488
RepoInfo repoinfo.RepoInfo
489
Active string
490
EmailToDidOrHandle map[string]string
491
+
Pipeline *db.Pipeline
492
493
// singular because it's always going to be just one
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
+1
-1
appview/pages/templates/repo/index.html
+1
-1
appview/pages/templates/repo/index.html
···
272
{{ end }}
273
274
<!-- ci status -->
275
+
{{ $pipeline := index $.Pipelines .Hash.String }}
276
{{ if and $pipeline (gt (len $pipeline.Statuses) 0) }}
277
<div class="inline-block px-1 select-none after:content-['·']"></div>
278
{{ template "repo/fragments/pipelineStatusSymbol" $pipeline }}
+64
-51
appview/pages/templates/repo/log.html
+64
-51
appview/pages/templates/repo/log.html
···
20
<th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Author</th>
21
<th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Commit</th>
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">Date</th>
24
</tr>
25
</thead>
···
57
{{ i "folder-code" "w-4 h-4" }}
58
</a>
59
</div>
60
</td>
61
<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
-
80
{{ 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>
82
{{ end }}
83
</td>
84
<td class=" py-3 align-top text-gray-500 dark:text-gray-400">{{ timeFmt $commit.Committer.When }}</td>
85
</tr>
···
94
<div id="commit-message">
95
{{ $messageParts := splitN $commit.Message "\n\n" 2 }}
96
<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 }}
112
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 }}
119
{{ 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
{{ end }}
127
</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>
133
</div>
134
</div>
135
</div>
136
</div>
···
160
</span>
161
<div class="inline-block px-1 select-none after:content-['·']"></div>
162
<span>{{ shortTimeFmt $commit.Committer.When }}</span>
163
</div>
164
</div>
165
{{ end }}
···
20
<th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Author</th>
21
<th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Commit</th>
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>
24
<th class="py-2 text-sm text-left text-gray-700 dark:text-gray-300 uppercase font-bold">Date</th>
25
</tr>
26
</thead>
···
58
{{ i "folder-code" "w-4 h-4" }}
59
</a>
60
</div>
61
+
62
</td>
63
<td class=" py-3 align-top">
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>
66
{{ if gt (len $messageParts) 1 }}
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>
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 }}
89
</td>
90
<td class=" py-3 align-top text-gray-500 dark:text-gray-400">{{ timeFmt $commit.Committer.When }}</td>
91
</tr>
···
100
<div id="commit-message">
101
{{ $messageParts := splitN $commit.Message "\n\n" 2 }}
102
<div class="text-base cursor-pointer">
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 }}
117
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>
123
{{ end }}
124
{{ end }}
125
</div>
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 }}
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>
138
</div>
139
</div>
140
</div>
···
164
</span>
165
<div class="inline-block px-1 select-none after:content-['·']"></div>
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 }}
176
</div>
177
</div>
178
{{ end }}
+5
-1
appview/repo/index.go
+5
-1
appview/repo/index.go
···
127
// non-fatal
128
}
129
130
+
var shas []string
131
+
for _, c := range commitsTrunc {
132
+
shas = append(shas, c.Hash.String())
133
+
}
134
+
pipelines, err := rp.getPipelineStatuses(repoInfo, shas)
135
if err != nil {
136
log.Printf("failed to fetch pipeline statuses: %s", err)
137
// non-fatal
+26
-1
appview/repo/repo.go
+26
-1
appview/repo/repo.go
···
133
log.Println(err)
134
}
135
136
rp.pages.RepoLog(w, pages.RepoLogParams{
137
LoggedInUser: user,
138
TagMap: tagMap,
139
-
RepoInfo: f.RepoInfo(user),
140
RepoLogResponse: *repolog,
141
EmailToDidOrHandle: emailToDidOrHandle(rp, emailToDidMap),
142
VerifiedCommits: vc,
143
})
144
return
145
}
···
289
}
290
291
user := rp.oauth.GetUser(r)
292
rp.pages.RepoCommit(w, pages.RepoCommitParams{
293
LoggedInUser: user,
294
RepoInfo: f.RepoInfo(user),
295
RepoCommitResponse: result,
296
EmailToDidOrHandle: emailToDidOrHandle(rp, emailToDidMap),
297
VerifiedCommit: vc,
298
})
299
return
300
}
···
133
log.Println(err)
134
}
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
+
148
rp.pages.RepoLog(w, pages.RepoLogParams{
149
LoggedInUser: user,
150
TagMap: tagMap,
151
+
RepoInfo: repoInfo,
152
RepoLogResponse: *repolog,
153
EmailToDidOrHandle: emailToDidOrHandle(rp, emailToDidMap),
154
VerifiedCommits: vc,
155
+
Pipelines: pipelines,
156
})
157
return
158
}
···
302
}
303
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
+
316
rp.pages.RepoCommit(w, pages.RepoCommitParams{
317
LoggedInUser: user,
318
RepoInfo: f.RepoInfo(user),
319
RepoCommitResponse: result,
320
EmailToDidOrHandle: emailToDidOrHandle(rp, emailToDidMap),
321
VerifiedCommit: vc,
322
+
Pipeline: pipeline,
323
})
324
return
325
}
+5
-12
appview/repo/repo_util.go
+5
-12
appview/repo/repo_util.go
···
9
"tangled.sh/tangled.sh/core/appview/db"
10
"tangled.sh/tangled.sh/core/appview/pages/repoinfo"
11
12
-
"github.com/go-git/go-git/v5/plumbing"
13
"github.com/go-git/go-git/v5/plumbing/object"
14
)
15
···
108
// golang is so blessed that it requires 35 lines of imperative code for this
109
func (rp *Repo) getPipelineStatuses(
110
repoInfo repoinfo.RepoInfo,
111
-
commits []*object.Commit,
112
-
) (map[plumbing.Hash]db.Pipeline, error) {
113
-
m := make(map[plumbing.Hash]db.Pipeline)
114
115
-
if len(commits) == 0 {
116
return m, nil
117
-
}
118
-
119
-
shas := make([]string, len(commits))
120
-
for _, c := range commits {
121
-
shas = append(shas, c.Hash.String())
122
}
123
124
ps, err := db.GetPipelineStatuses(
···
133
}
134
135
for _, p := range ps {
136
-
hash := plumbing.NewHash(p.Sha)
137
-
m[hash] = p
138
}
139
140
return m, nil
···
9
"tangled.sh/tangled.sh/core/appview/db"
10
"tangled.sh/tangled.sh/core/appview/pages/repoinfo"
11
12
"github.com/go-git/go-git/v5/plumbing/object"
13
)
14
···
107
// golang is so blessed that it requires 35 lines of imperative code for this
108
func (rp *Repo) getPipelineStatuses(
109
repoInfo repoinfo.RepoInfo,
110
+
shas []string,
111
+
) (map[string]db.Pipeline, error) {
112
+
m := make(map[string]db.Pipeline)
113
114
+
if len(shas) == 0 {
115
return m, nil
116
}
117
118
ps, err := db.GetPipelineStatuses(
···
127
}
128
129
for _, p := range ps {
130
+
m[p.Sha] = p
131
}
132
133
return m, nil