diff --git a/appview/pages/pages.go b/appview/pages/pages.go index d41ceaa0..0557aa00 100644 --- a/appview/pages/pages.go +++ b/appview/pages/pages.go @@ -764,13 +764,15 @@ func (p *Pages) RepoCommit(w io.Writer, params RepoCommitParams) error { } type RepoTreeParams struct { - LoggedInUser *oauth.MultiAccountUser - RepoInfo repoinfo.RepoInfo - Active string - BreadCrumbs [][]string - TreePath string - Raw bool - HTMLReadme template.HTML + LoggedInUser *oauth.MultiAccountUser + RepoInfo repoinfo.RepoInfo + Active string + BreadCrumbs [][]string + TreePath string + Raw bool + HTMLReadme template.HTML + EmailToDid map[string]string + LastCommitInfo *types.LastCommitInfo types.RepoTreeResponse } diff --git a/appview/pages/templates/repo/tree.html b/appview/pages/templates/repo/tree.html index 587baa00..40c31cef 100644 --- a/appview/pages/templates/repo/tree.html +++ b/appview/pages/templates/repo/tree.html @@ -52,6 +52,10 @@ + {{ if .LastCommitInfo }} + {{ template "repo/fragments/lastCommitPanel" $ }} + {{ end }} + {{ range .Files }}
diff --git a/appview/repo/blob.go b/appview/repo/blob.go index b393dae4..b5f3f3b4 100644 --- a/appview/repo/blob.go +++ b/appview/repo/blob.go @@ -101,6 +101,11 @@ func (rp *Repo) Blob(w http.ResponseWriter, r *http.Request) { Message: resp.LastCommit.Message, When: when, } + if resp.LastCommit.Author != nil { + lastCommitInfo.Author.Name = resp.LastCommit.Author.Name + lastCommitInfo.Author.Email = resp.LastCommit.Author.Email + lastCommitInfo.Author.When, _ = time.Parse(time.RFC3339, resp.LastCommit.Author.When) + } } rp.pages.RepoBlob(w, pages.RepoBlobParams{ diff --git a/appview/repo/tree.go b/appview/repo/tree.go index 9161041b..8185537f 100644 --- a/appview/repo/tree.go +++ b/appview/repo/tree.go @@ -8,6 +8,7 @@ import ( "time" "tangled.org/core/api/tangled" + "tangled.org/core/appview/db" "tangled.org/core/appview/pages" "tangled.org/core/appview/reporesolver" xrpcclient "tangled.org/core/appview/xrpcclient" @@ -98,11 +99,39 @@ func (rp *Repo) Tree(w http.ResponseWriter, r *http.Request) { } sortFiles(result.Files) + // Get email to DID mapping for commit author + var emails []string + if xrpcResp.LastCommit != nil && xrpcResp.LastCommit.Author != nil { + emails = append(emails, xrpcResp.LastCommit.Author.Email) + } + emailToDidMap, err := db.GetEmailToDid(rp.db, emails, true) + if err != nil { + l.Error("failed to get email to did mapping", "err", err) + emailToDidMap = make(map[string]string) + } + + var lastCommitInfo *types.LastCommitInfo + if xrpcResp.LastCommit != nil { + when, _ := time.Parse(time.RFC3339, xrpcResp.LastCommit.When) + lastCommitInfo = &types.LastCommitInfo{ + Hash: plumbing.NewHash(xrpcResp.LastCommit.Hash), + Message: xrpcResp.LastCommit.Message, + When: when, + } + if xrpcResp.LastCommit.Author != nil { + lastCommitInfo.Author.Name = xrpcResp.LastCommit.Author.Name + lastCommitInfo.Author.Email = xrpcResp.LastCommit.Author.Email + lastCommitInfo.Author.When, _ = time.Parse(time.RFC3339, xrpcResp.LastCommit.Author.When) + } + } + rp.pages.RepoTree(w, pages.RepoTreeParams{ LoggedInUser: user, BreadCrumbs: breadcrumbs, TreePath: treePath, RepoInfo: rp.repoResolver.GetRepoInfo(r, user), + EmailToDid: emailToDidMap, + LastCommitInfo: lastCommitInfo, RepoTreeResponse: result, }) } diff --git a/types/repo.go b/types/repo.go index ebb20732..0d4dca3e 100644 --- a/types/repo.go +++ b/types/repo.go @@ -106,16 +106,6 @@ type RepoDefaultBranchResponse struct { Branch string `json:"branch,omitempty"` } -type RepoBlobResponse struct { - Contents string `json:"contents,omitempty"` - Ref string `json:"ref,omitempty"` - Path string `json:"path,omitempty"` - IsBinary bool `json:"is_binary,omitempty"` - - Lines int `json:"lines,omitempty"` - SizeHint uint64 `json:"size_hint,omitempty"` -} - type ForkStatus int const ( diff --git a/types/tree.go b/types/tree.go index fc366f00..830a9a28 100644 --- a/types/tree.go +++ b/types/tree.go @@ -105,4 +105,9 @@ type LastCommitInfo struct { Hash plumbing.Hash Message string When time.Time + Author struct { + Email string + Name string + When time.Time + } }