Browse Source

Implemented PR sorting

feature/embedded-resources-and-css
root 5 months ago
parent
commit
324044c383
  1. 14
      git.go

14
git.go

@ -13,6 +13,7 @@ import (
"path/filepath"
"regexp"
"sort"
"strconv"
"strings"
"text/template"
"time"
@ -158,7 +159,18 @@ func (r Repo) RefGroup() RefGroup {
sorter(strings.TrimPrefix(strings.SplitN(line, " ", 2)[1], "refs/"))
}
// TODO sort PRs by numerical tag ID
// Sorting PRs by their numerical ID
sort.Slice(refs[RefTypePR], func(i int, j int) bool {
si, sj := strings.SplitN(refs[RefTypePR][i], "/", 3)[1],
strings.SplitN(refs[RefTypePR][j], "/", 3)[1]
ires, ierr := strconv.Atoi(si)
jres, jerr := strconv.Atoi(sj)
if ierr != nil || jerr != nil {
return false
}
return ires < jres
})
return refs
}

Loading…
Cancel
Save