+
{{ template "user/fragments/profileCard" .Card }}
-
+
{{ block "ownRepos" . }}{{ end }}
diff --git a/appview/repo/index.go b/appview/repo/index.go
index 370c555..2661325 100644
--- a/appview/repo/index.go
+++ b/appview/repo/index.go
@@ -58,6 +58,8 @@ func (rp *Repo) RepoIndex(w http.ResponseWriter, r *http.Request) {
tagMap[hash] = append(tagMap[hash], branch.Name)
}
+ sortFiles(result.Files)
+
slices.SortFunc(result.Branches, func(a, b types.Branch) int {
if a.Name == result.Ref {
return -1
diff --git a/appview/repo/repo.go b/appview/repo/repo.go
index 31436b2..f6b6fd0 100644
--- a/appview/repo/repo.go
+++ b/appview/repo/repo.go
@@ -10,9 +10,7 @@ import (
"log"
"net/http"
"net/url"
- "path"
"slices"
- "sort"
"strconv"
"strings"
"time"
@@ -374,7 +372,8 @@ func (rp *Repo) RepoTree(w http.ResponseWriter, r *http.Request) {
// redirects tree paths trying to access a blob; in this case the result.Files is unpopulated,
// so we can safely redirect to the "parent" (which is the same file).
- if len(result.Files) == 0 && result.Parent == treePath {
+ unescapedTreePath, _ := url.PathUnescape(treePath)
+ if len(result.Files) == 0 && result.Parent == unescapedTreePath {
http.Redirect(w, r, fmt.Sprintf("/%s/blob/%s/%s", f.OwnerSlashRepo(), ref, result.Parent), http.StatusFound)
return
}
@@ -389,18 +388,15 @@ func (rp *Repo) RepoTree(w http.ResponseWriter, r *http.Request) {
}
}
- baseTreeLink := path.Join(f.OwnerSlashRepo(), "tree", ref, treePath)
- baseBlobLink := path.Join(f.OwnerSlashRepo(), "blob", ref, treePath)
+ sortFiles(result.Files)
rp.pages.RepoTree(w, pages.RepoTreeParams{
LoggedInUser: user,
BreadCrumbs: breadcrumbs,
- BaseTreeLink: baseTreeLink,
- BaseBlobLink: baseBlobLink,
+ TreePath: treePath,
RepoInfo: f.RepoInfo(user),
RepoTreeResponse: result,
})
- return
}
func (rp *Repo) RepoTags(w http.ResponseWriter, r *http.Request) {
@@ -480,22 +476,7 @@ func (rp *Repo) RepoBranches(w http.ResponseWriter, r *http.Request) {
return
}
- slices.SortFunc(result.Branches, func(a, b types.Branch) int {
- if a.IsDefault {
- return -1
- }
- if b.IsDefault {
- return 1
- }
- if a.Commit != nil && b.Commit != nil {
- if a.Commit.Committer.When.Before(b.Commit.Committer.When) {
- return 1
- } else {
- return -1
- }
- }
- return strings.Compare(a.Name, b.Name) * -1
- })
+ sortBranches(result.Branches)
user := rp.oauth.GetUser(r)
rp.pages.RepoBranches(w, pages.RepoBranchesParams{
@@ -503,7 +484,6 @@ func (rp *Repo) RepoBranches(w http.ResponseWriter, r *http.Request) {
RepoInfo: f.RepoInfo(user),
RepoBranchesResponse: *result,
})
- return
}
func (rp *Repo) RepoBlob(w http.ResponseWriter, r *http.Request) {
@@ -1233,9 +1213,8 @@ func (rp *Repo) RepoCompareNew(w http.ResponseWriter, r *http.Request) {
return
}
branches := result.Branches
- sort.Slice(branches, func(i int, j int) bool {
- return branches[i].Commit.Committer.When.After(branches[j].Commit.Committer.When)
- })
+
+ sortBranches(branches)
var defaultBranch string
for _, b := range branches {
diff --git a/appview/repo/repo_util.go b/appview/repo/repo_util.go
index 50c614b..f562f72 100644
--- a/appview/repo/repo_util.go
+++ b/appview/repo/repo_util.go
@@ -5,13 +5,47 @@ import (
"crypto/rand"
"fmt"
"math/big"
+ "slices"
+ "sort"
+ "strings"
"tangled.sh/tangled.sh/core/appview/db"
"tangled.sh/tangled.sh/core/appview/pages/repoinfo"
+ "tangled.sh/tangled.sh/core/types"
"github.com/go-git/go-git/v5/plumbing/object"
)
+func sortFiles(files []types.NiceTree) {
+ sort.Slice(files, func(i, j int) bool {
+ iIsFile := files[i].IsFile
+ jIsFile := files[j].IsFile
+ if iIsFile != jIsFile {
+ return !iIsFile
+ }
+ return files[i].Name < files[j].Name
+ })
+}
+
+func sortBranches(branches []types.Branch) {
+ slices.SortFunc(branches, func(a, b types.Branch) int {
+ if a.IsDefault {
+ return -1
+ }
+ if b.IsDefault {
+ return 1
+ }
+ if a.Commit != nil && b.Commit != nil {
+ if a.Commit.Committer.When.Before(b.Commit.Committer.When) {
+ return 1
+ } else {
+ return -1
+ }
+ }
+ return strings.Compare(a.Name, b.Name)
+ })
+}
+
func uniqueEmails(commits []*object.Commit) []string {
emails := make(map[string]struct{})
for _, commit := range commits {