diff --git a/appview/pages/templates/repo/pulls/fragments/pullCompareBranches.html b/appview/pages/templates/repo/pulls/fragments/pullCompareBranches.html index 890f17c5..bd34590b 100644 --- a/appview/pages/templates/repo/pulls/fragments/pullCompareBranches.html +++ b/appview/pages/templates/repo/pulls/fragments/pullCompareBranches.html @@ -9,9 +9,19 @@ class="p-1 border border-gray-200 bg-white dark:bg-gray-700 dark:text-white dark:border-gray-600" > + + {{ $recent := index .Branches 0 }} {{ range .Branches }} - {{ end }} diff --git a/appview/pages/templates/repo/pulls/fragments/pullCompareForksBranches.html b/appview/pages/templates/repo/pulls/fragments/pullCompareForksBranches.html index d2dc3bb8..cc426f5f 100644 --- a/appview/pages/templates/repo/pulls/fragments/pullCompareForksBranches.html +++ b/appview/pages/templates/repo/pulls/fragments/pullCompareForksBranches.html @@ -5,9 +5,19 @@ class="p-1 border border-gray-200 bg-white dark:bg-gray-700 dark:text-white dark:border-gray-600" > + + {{ $recent := index .SourceBranches 0 }} {{ range .SourceBranches }} - {{ end }} diff --git a/appview/state/pull.go b/appview/state/pull.go index 6bb2ac27..bee6a774 100644 --- a/appview/state/pull.go +++ b/appview/state/pull.go @@ -8,6 +8,7 @@ import ( "io" "log" "net/http" + "sort" "strconv" "time" @@ -991,9 +992,22 @@ func (s *State) CompareBranchesFragment(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) + }) + + withoutDefault := []types.Branch{} + for _, b := range branches { + if b.IsDefault { + continue + } + withoutDefault = append(withoutDefault, b) + } + s.pages.PullCompareBranchesFragment(w, pages.PullCompareBranchesParams{ RepoInfo: f.RepoInfo(s, user), - Branches: result.Branches, + Branches: withoutDefault, }) } @@ -1089,6 +1103,11 @@ func (s *State) CompareForksBranchesFragment(w http.ResponseWriter, r *http.Requ return } + sourceBranches := sourceResult.Branches + sort.Slice(sourceBranches, func(i int, j int) bool { + return sourceBranches[i].Commit.Committer.When.After(sourceBranches[j].Commit.Committer.When) + }) + s.pages.PullCompareForkBranchesFragment(w, pages.PullCompareForkBranchesParams{ RepoInfo: f.RepoInfo(s, user), SourceBranches: sourceResult.Branches,