+21
-20
appview/pages/pages.go
+21
-20
appview/pages/pages.go
···
660
660
TagsTrunc []*types.TagReference
661
661
BranchesTrunc []types.Branch
662
662
// ForkInfo *types.ForkInfo
663
-
HTMLReadme template.HTML
664
-
Raw bool
665
-
EmailToDidOrHandle map[string]string
666
-
VerifiedCommits commitverify.VerifiedCommits
667
-
Languages []types.RepoLanguageDetails
668
-
Pipelines map[string]models.Pipeline
669
-
NeedsKnotUpgrade bool
663
+
HTMLReadme template.HTML
664
+
Raw bool
665
+
EmailToDid map[string]string
666
+
VerifiedCommits commitverify.VerifiedCommits
667
+
Languages []types.RepoLanguageDetails
668
+
Pipelines map[string]models.Pipeline
669
+
NeedsKnotUpgrade bool
670
670
types.RepoIndexResponse
671
671
}
672
672
···
701
701
}
702
702
703
703
type RepoLogParams struct {
704
-
LoggedInUser *oauth.User
705
-
RepoInfo repoinfo.RepoInfo
706
-
TagMap map[string][]string
704
+
LoggedInUser *oauth.User
705
+
RepoInfo repoinfo.RepoInfo
706
+
TagMap map[string][]string
707
+
Active string
708
+
EmailToDid map[string]string
709
+
VerifiedCommits commitverify.VerifiedCommits
710
+
Pipelines map[string]models.Pipeline
711
+
707
712
types.RepoLogResponse
708
-
Active string
709
-
EmailToDidOrHandle map[string]string
710
-
VerifiedCommits commitverify.VerifiedCommits
711
-
Pipelines map[string]models.Pipeline
712
713
}
713
714
714
715
func (p *Pages) RepoLog(w io.Writer, params RepoLogParams) error {
···
717
718
}
718
719
719
720
type RepoCommitParams struct {
720
-
LoggedInUser *oauth.User
721
-
RepoInfo repoinfo.RepoInfo
722
-
Active string
723
-
EmailToDidOrHandle map[string]string
724
-
Pipeline *models.Pipeline
725
-
DiffOpts types.DiffOpts
721
+
LoggedInUser *oauth.User
722
+
RepoInfo repoinfo.RepoInfo
723
+
Active string
724
+
EmailToDid map[string]string
725
+
Pipeline *models.Pipeline
726
+
DiffOpts types.DiffOpts
726
727
727
728
// singular because it's always going to be just one
728
729
VerifiedCommit commitverify.VerifiedCommits
+11
-11
appview/pages/templates/repo/commit.html
+11
-11
appview/pages/templates/repo/commit.html
···
24
24
</div>
25
25
</div>
26
26
27
-
<div class="flex items-center space-x-2">
28
-
<p class="text-sm text-gray-500 dark:text-gray-300">
29
-
{{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }}
27
+
<div class="flex flex-wrap items-center space-x-2">
28
+
<p class="flex flex-wrap items-center gap-2 text-sm text-gray-500 dark:text-gray-300">
29
+
{{ $did := index $.EmailToDid $commit.Author.Email }}
30
30
31
-
{{ if $didOrHandle }}
32
-
<a href="/{{ $didOrHandle }}" class="no-underline hover:underline text-gray-500 dark:text-gray-300">{{ $didOrHandle }}</a>
31
+
{{ if $did }}
32
+
{{ template "user/fragments/picHandleLink" $did }}
33
33
{{ else }}
34
34
<a href="mailto:{{ $commit.Author.Email }}" class="no-underline hover:underline text-gray-500 dark:text-gray-300">{{ $commit.Author.Name }}</a>
35
35
{{ end }}
36
+
36
37
<span class="px-1 select-none before:content-['\00B7']"></span>
37
38
{{ template "repo/fragments/time" $commit.Author.When }}
38
39
<span class="px-1 select-none before:content-['\00B7']"></span>
39
-
</p>
40
40
41
-
<p class="flex items-center text-sm text-gray-500 dark:text-gray-300">
42
41
<a href="/{{ $repo }}/commit/{{ $commit.This }}" class="no-underline hover:underline text-gray-500 dark:text-gray-300">{{ slice $commit.This 0 8 }}</a>
42
+
43
43
{{ if $commit.Parent }}
44
-
{{ i "arrow-left" "w-3 h-3 mx-1" }}
45
-
<a href="/{{ $repo }}/commit/{{ $commit.Parent }}" class="no-underline hover:underline text-gray-500 dark:text-gray-300">{{ slice $commit.Parent 0 8 }}</a>
44
+
{{ i "arrow-left" "w-3 h-3 mx-1" }}
45
+
<a href="/{{ $repo }}/commit/{{ $commit.Parent }}" class="no-underline hover:underline text-gray-500 dark:text-gray-300">{{ slice $commit.Parent 0 8 }}</a>
46
46
{{ end }}
47
47
</p>
48
48
···
58
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
59
<div class="flex items-center gap-2 my-2">
60
60
{{ i "user" "w-4 h-4" }}
61
-
{{ $committerDidOrHandle := index $.EmailToDidOrHandle $commit.Committer.Email }}
62
-
<a href="/{{ $committerDidOrHandle }}">{{ template "user/fragments/picHandleLink" $committerDidOrHandle }}</a>
61
+
{{ $committerDid := index $.EmailToDid $commit.Committer.Email }}
62
+
{{ template "user/fragments/picHandleLink" $committerDid }}
63
63
</div>
64
64
<div class="my-1 pt-2 text-xs border-t border-gray-200 dark:border-gray-700">
65
65
<div class="text-gray-600 dark:text-gray-300">SSH Key Fingerprint:</div>
+3
-13
appview/pages/templates/repo/index.html
+3
-13
appview/pages/templates/repo/index.html
···
222
222
class="mx-1 before:content-['·'] before:select-none"
223
223
></span>
224
224
<span>
225
-
{{ $didOrHandle := index $.EmailToDidOrHandle .Author.Email }}
226
-
<a
227
-
href="{{ if $didOrHandle }}
228
-
/{{ $didOrHandle }}
229
-
{{ else }}
230
-
mailto:{{ .Author.Email }}
231
-
{{ end }}"
225
+
{{ $did := index $.EmailToDid .Author.Email }}
226
+
<a href="{{ if $did }}/{{ resolve $did }}{{ else }}mailto:{{ .Author.Email }}{{ end }}"
232
227
class="text-gray-500 dark:text-gray-400 no-underline hover:underline"
233
-
>{{ if $didOrHandle }}
234
-
{{ template "user/fragments/picHandleLink" $didOrHandle }}
235
-
{{ else }}
236
-
{{ .Author.Name }}
237
-
{{ end }}</a
238
-
>
228
+
>{{ if $did }}{{ template "user/fragments/picHandleLink" $did }}{{ else }}{{ .Author.Name }}{{ end }}</a>
239
229
</span>
240
230
<div class="inline-block px-1 select-none after:content-['·']"></div>
241
231
{{ template "repo/fragments/time" .Committer.When }}
+6
-6
appview/pages/templates/repo/log.html
+6
-6
appview/pages/templates/repo/log.html
···
27
27
{{ $messageParts := splitN $commit.Message "\n\n" 2 }}
28
28
<div class="{{ $grid }} py-3">
29
29
<div class="align-top truncate col-span-2">
30
-
{{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }}
31
-
{{ if $didOrHandle }}
32
-
{{ template "user/fragments/picHandleLink" $didOrHandle }}
30
+
{{ $did := index $.EmailToDid $commit.Author.Email }}
31
+
{{ if $did }}
32
+
{{ template "user/fragments/picHandleLink" $did }}
33
33
{{ else }}
34
34
<a href="mailto:{{ $commit.Author.Email }}" class="text-gray-700 dark:text-gray-300 no-underline hover:underline">{{ $commit.Author.Name }}</a>
35
35
{{ end }}
···
153
153
</span>
154
154
<span class="mx-2 before:content-['·'] before:select-none"></span>
155
155
<span>
156
-
{{ $didOrHandle := index $.EmailToDidOrHandle $commit.Author.Email }}
157
-
<a href="{{ if $didOrHandle }}/{{ $didOrHandle }}{{ else }}mailto:{{ $commit.Author.Email }}{{ end }}"
156
+
{{ $did := index $.EmailToDid $commit.Author.Email }}
157
+
<a href="{{ if $did }}/{{ $did }}{{ else }}mailto:{{ $commit.Author.Email }}{{ end }}"
158
158
class="text-gray-500 dark:text-gray-400 no-underline hover:underline">
159
-
{{ if $didOrHandle }}{{ template "user/fragments/picHandleLink" $didOrHandle }}{{ else }}{{ $commit.Author.Name }}{{ end }}
159
+
{{ if $did }}{{ template "user/fragments/picHandleLink" $did }}{{ else }}{{ $commit.Author.Name }}{{ end }}
160
160
</a>
161
161
</span>
162
162
<div class="inline-block px-1 select-none after:content-['·']"></div>
+5
-5
appview/repo/index.go
+5
-5
appview/repo/index.go
···
154
154
CommitsTrunc: commitsTrunc,
155
155
TagsTrunc: tagsTrunc,
156
156
// ForkInfo: forkInfo, // TODO: reinstate this after xrpc properly lands
157
-
BranchesTrunc: branchesTrunc,
158
-
EmailToDidOrHandle: emailToDidOrHandle(rp, emailToDidMap),
159
-
VerifiedCommits: vc,
160
-
Languages: languageInfo,
161
-
Pipelines: pipelines,
157
+
BranchesTrunc: branchesTrunc,
158
+
EmailToDid: emailToDidMap,
159
+
VerifiedCommits: vc,
160
+
Languages: languageInfo,
161
+
Pipelines: pipelines,
162
162
})
163
163
}
164
164
+8
-8
appview/repo/repo.go
+8
-8
appview/repo/repo.go
···
242
242
}
243
243
244
244
rp.pages.RepoLog(w, pages.RepoLogParams{
245
-
LoggedInUser: user,
246
-
TagMap: tagMap,
247
-
RepoInfo: repoInfo,
248
-
RepoLogResponse: xrpcResp,
249
-
EmailToDidOrHandle: emailToDidOrHandle(rp, emailToDidMap),
250
-
VerifiedCommits: vc,
251
-
Pipelines: pipelines,
245
+
LoggedInUser: user,
246
+
TagMap: tagMap,
247
+
RepoInfo: repoInfo,
248
+
RepoLogResponse: xrpcResp,
249
+
EmailToDid: emailToDidMap,
250
+
VerifiedCommits: vc,
251
+
Pipelines: pipelines,
252
252
})
253
253
}
254
254
···
422
422
LoggedInUser: user,
423
423
RepoInfo: f.RepoInfo(user),
424
424
RepoCommitResponse: result,
425
-
EmailToDidOrHandle: emailToDidOrHandle(rp, emailToDidMap),
425
+
EmailToDid: emailToDidMap,
426
426
VerifiedCommit: vc,
427
427
Pipeline: pipeline,
428
428
DiffOpts: diffOpts,
-35
appview/repo/repo_util.go
-35
appview/repo/repo_util.go
···
1
1
package repo
2
2
3
3
import (
4
-
"context"
5
4
"crypto/rand"
6
-
"fmt"
7
5
"math/big"
8
6
"slices"
9
7
"sort"
···
90
88
}
91
89
92
90
return
93
-
}
94
-
95
-
// emailToDidOrHandle takes an emailToDidMap from db.GetEmailToDid
96
-
// and resolves all dids to handles and returns a new map[string]string
97
-
func emailToDidOrHandle(r *Repo, emailToDidMap map[string]string) map[string]string {
98
-
if emailToDidMap == nil {
99
-
return nil
100
-
}
101
-
102
-
var dids []string
103
-
for _, v := range emailToDidMap {
104
-
dids = append(dids, v)
105
-
}
106
-
resolvedIdents := r.idResolver.ResolveIdents(context.Background(), dids)
107
-
108
-
didHandleMap := make(map[string]string)
109
-
for _, identity := range resolvedIdents {
110
-
if !identity.Handle.IsInvalidHandle() {
111
-
didHandleMap[identity.DID.String()] = fmt.Sprintf("@%s", identity.Handle.String())
112
-
} else {
113
-
didHandleMap[identity.DID.String()] = identity.DID.String()
114
-
}
115
-
}
116
-
117
-
// Create map of email to didOrHandle for commit display
118
-
emailToDidOrHandle := make(map[string]string)
119
-
for email, did := range emailToDidMap {
120
-
if didOrHandle, ok := didHandleMap[did]; ok {
121
-
emailToDidOrHandle[email] = didOrHandle
122
-
}
123
-
}
124
-
125
-
return emailToDidOrHandle
126
91
}
127
92
128
93
func randomString(n int) string {