-2
appview/commitverify/verify.go
-2
appview/commitverify/verify.go
···
1
1
package commitverify
2
2
3
3
import (
4
-
"fmt"
5
4
"log"
6
5
7
6
"github.com/go-git/go-git/v5/plumbing/object"
···
74
73
if err != nil {
75
74
log.Println("error computing ssh fingerprint:", err)
76
75
}
77
-
fmt.Println(fp)
78
76
79
77
vc := verifiedCommit{fingerprint: fp, hash: c.This}
80
78
vcs[vc] = struct{}{}
+6
-3
appview/pages/pages.go
+6
-3
appview/pages/pages.go
···
15
15
"path/filepath"
16
16
"strings"
17
17
18
+
"tangled.sh/tangled.sh/core/appview/commitverify"
18
19
"tangled.sh/tangled.sh/core/appview/config"
19
20
"tangled.sh/tangled.sh/core/appview/db"
20
21
"tangled.sh/tangled.sh/core/appview/oauth"
···
414
415
HTMLReadme template.HTML
415
416
Raw bool
416
417
EmailToDidOrHandle map[string]string
417
-
VerifiedCommits map[string]bool
418
+
VerifiedCommits commitverify.VerifiedCommits
418
419
Languages *types.RepoLanguageResponse
419
420
types.RepoIndexResponse
420
421
}
···
453
454
types.RepoLogResponse
454
455
Active string
455
456
EmailToDidOrHandle map[string]string
456
-
VerifiedCommits map[string]bool
457
+
VerifiedCommits commitverify.VerifiedCommits
457
458
}
458
459
459
460
func (p *Pages) RepoLog(w io.Writer, params RepoLogParams) error {
···
466
467
RepoInfo repoinfo.RepoInfo
467
468
Active string
468
469
EmailToDidOrHandle map[string]string
469
-
Verified bool
470
+
471
+
// singular because it's always going to be just one
472
+
VerifiedCommit commitverify.VerifiedCommits
470
473
471
474
types.RepoCommitResponse
472
475
}
+21
-6
appview/pages/templates/repo/commit.html
+21
-6
appview/pages/templates/repo/commit.html
···
46
46
{{ end }}
47
47
</p>
48
48
49
-
{{ if .Verified }}
50
-
<span class="text-sm bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 py-1 rounded">
51
-
<div class="flex items-center gap-2">
52
-
{{ i "shield-check" "w-4 h-4" }}
53
-
verified
49
+
{{ if .VerifiedCommit.IsVerified $commit.This }}
50
+
<div class="group relative inline-block text-sm">
51
+
<div class="bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 py-1 rounded cursor-pointer">
52
+
<div class="flex items-center gap-2">
53
+
{{ i "shield-check" "w-4 h-4" }}
54
+
verified
55
+
</div>
56
+
</div>
57
+
<div class="absolute z-[9999] hidden group-hover:block bg-white dark:bg-gray-900 text-sm text-black dark:text-white rounded-md shadow-md p-4 w-80 top-full mt-2">
58
+
<div class="mb-1">This commit was signed with the committer's <span class="text-green-600 font-semibold">known signature</span>.</div>
59
+
<div class="flex items-center gap-2 my-2">
60
+
{{ i "user" "w-4 h-4" }}
61
+
<a href="/{{ $didOrHandle }}">{{ $didOrHandle }}</a>
62
+
</div>
63
+
<div class="my-1 pt-2 text-xs border-t">
64
+
<div class="text-gray-600 dark:text-gray-300">SSH Key Fingerprint:</div>
65
+
<div class="break-all">{{ .VerifiedCommit.Fingerprint $commit.This }}</div>
66
+
</div>
54
67
</div>
55
-
</span>
68
+
</div>
56
69
{{ end }}
57
70
</div>
58
71
···
61
74
{{end}}
62
75
63
76
{{ define "repoAfter" }}
77
+
<div class="-z-[9999]">
64
78
{{ template "repo/fragments/diff" (list .RepoInfo.FullName .Diff) }}
79
+
</div>
65
80
{{end}}
+1
-2
appview/pages/templates/repo/index.html
+1
-2
appview/pages/templates/repo/index.html
···
223
223
</div>
224
224
225
225
<div class="text-xs mt-2 text-gray-500 dark:text-gray-400 flex items-center">
226
-
{{ $verified := false }}
227
-
{{ $verified = index $.VerifiedCommits .Hash.String }}
226
+
{{ $verified := $.VerifiedCommits.IsVerified .Hash.String }}
228
227
{{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }}
229
228
{{ if $verified }}
230
229
{{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }}
+13
-15
appview/pages/templates/repo/log.html
+13
-15
appview/pages/templates/repo/log.html
···
3
3
{{ define "extrameta" }}
4
4
{{ $title := printf "commits · %s" .RepoInfo.FullName }}
5
5
{{ $url := printf "https://tangled.sh/%s/commits" .RepoInfo.FullName }}
6
-
6
+
7
7
{{ template "repo/fragments/og" (dict "RepoInfo" .RepoInfo "Title" $title "Url" $url) }}
8
8
{{ end }}
9
9
10
10
{{ define "repoContent" }}
11
11
<section id="commit-table" class="overflow-x-auto">
12
12
<h2 class="font-bold text-sm mb-4 uppercase dark:text-white">
13
-
commits
13
+
commits
14
14
</h2>
15
15
16
16
<!-- desktop view (hidden on small screens) -->
···
36
36
{{ end }}
37
37
</td>
38
38
<td class="py-3 align-top font-mono flex items-center">
39
-
{{ $verified := false }}
40
-
{{ $verified = index $.VerifiedCommits $commit.Hash.String }}
39
+
{{ $verified := $.VerifiedCommits.IsVerified $commit.Hash.String }}
41
40
{{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }}
42
41
{{ if $verified }}
43
42
{{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }}
···
49
48
{{ end }}
50
49
</a>
51
50
<div class="{{ if not $verified }} ml-6 {{ end }}inline-flex">
52
-
<button class="p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"
51
+
<button class="p-1 mx-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"
53
52
title="Copy SHA"
54
53
onclick="navigator.clipboard.writeText('{{ $commit.Hash.String }}'); this.innerHTML=`{{ i "copy-check" "w-4 h-4" }}`; setTimeout(() => this.innerHTML=`{{ i "copy" "w-4 h-4" }}`, 1500)">
55
54
{{ i "copy" "w-4 h-4" }}
···
63
62
<div>
64
63
<div class="flex items-center justify-start">
65
64
<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 }}
65
+
{{ if gt (len $messageParts) 1 }}
67
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>
68
67
{{ end }}
69
68
70
-
69
+
71
70
{{ if index $.TagMap $commit.Hash.String }}
72
71
{{ range $tag := index $.TagMap $commit.Hash.String }}
73
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">
···
75
74
</span>
76
75
{{ end }}
77
76
{{ end }}
78
-
77
+
79
78
</div>
80
-
79
+
81
80
{{ if gt (len $messageParts) 1 }}
82
81
<p class="hidden mt-1 text-sm text-gray-600 dark:text-gray-400">{{ nl2br (index $messageParts 1) }}</p>
83
82
{{ end }}
···
99
98
<div class="flex items-center justify-between">
100
99
<div class="flex-1">
101
100
<div class="inline">
102
-
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}"
101
+
<a href="/{{ $.RepoInfo.FullName }}/commit/{{ $commit.Hash.String }}"
103
102
class="inline no-underline hover:underline dark:text-white">
104
103
{{ index $messageParts 0 }}
105
104
</a>
106
105
{{ if gt (len $messageParts) 1 }}
107
-
<button
106
+
<button
108
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"
109
108
hx-on:click="this.parentElement.nextElementSibling.classList.toggle('hidden')">
110
109
{{ i "ellipsis" "w-3 h-3" }}
···
126
125
</p>
127
126
{{ end }}
128
127
</div>
129
-
<a href="/{{ $.RepoInfo.FullName }}/tree/{{ $commit.Hash.String }}"
130
-
class="p-1 mr-1 hover:bg-gray-100 dark:hover:bg-gray-700 rounded"
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"
131
130
title="Browse repository at this commit">
132
131
{{ i "folder-code" "w-4 h-4" }}
133
132
</a>
···
137
136
</div>
138
137
139
138
<div class="text-xs mt-2 text-gray-500 dark:text-gray-400 flex items-center">
140
-
{{ $verified := false }}
141
-
{{ $verified = index $.VerifiedCommits $commit.Hash.String }}
139
+
{{ $verified := $.VerifiedCommits.IsVerified $commit.Hash.String }}
142
140
{{ $hashStyle := "text-gray-700 dark:text-gray-300 bg-gray-100 dark:bg-gray-900" }}
143
141
{{ if $verified }}
144
142
{{ $hashStyle = "bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200 px-2 rounded" }}
+5
-4
appview/repo/repo.go
+5
-4
appview/repo/repo.go
···
18
18
19
19
"tangled.sh/tangled.sh/core/api/tangled"
20
20
"tangled.sh/tangled.sh/core/appview"
21
+
"tangled.sh/tangled.sh/core/appview/commitverify"
21
22
"tangled.sh/tangled.sh/core/appview/config"
22
23
"tangled.sh/tangled.sh/core/appview/db"
23
24
"tangled.sh/tangled.sh/core/appview/idresolver"
···
144
145
log.Println("failed to get email to did map", err)
145
146
}
146
147
147
-
vc, err := verifiedObjectCommits(rp, emailToDidMap, commitsTrunc)
148
+
vc, err := commitverify.GetVerifiedObjectCommits(rp.db, emailToDidMap, commitsTrunc)
148
149
if err != nil {
149
150
log.Println(err)
150
151
}
···
310
311
log.Println("failed to fetch email to did mapping", err)
311
312
}
312
313
313
-
vc, err := verifiedObjectCommits(rp, emailToDidMap, repolog.Commits)
314
+
vc, err := commitverify.GetVerifiedObjectCommits(rp.db, emailToDidMap, repolog.Commits)
314
315
if err != nil {
315
316
log.Println(err)
316
317
}
···
466
467
log.Println("failed to get email to did mapping:", err)
467
468
}
468
469
469
-
vc, err := verifiedCommits(rp, emailToDidMap, []types.NiceDiff{*result.Diff})
470
+
vc, err := commitverify.GetVerifiedCommits(rp.db, emailToDidMap, []types.NiceDiff{*result.Diff})
470
471
if err != nil {
471
472
log.Println(err)
472
473
}
···
477
478
RepoInfo: f.RepoInfo(user),
478
479
RepoCommitResponse: result,
479
480
EmailToDidOrHandle: emailToDidOrHandle(rp, emailToDidMap),
480
-
Verified: vc[result.Diff.Commit.This],
481
+
VerifiedCommit: vc,
481
482
})
482
483
return
483
484
}