INNER CODE UNIT · Go
SubScore
Bharath-code/git-scope · internal/attention/score.go:33
func SubScore(s model.RepoStatus, now time.Time) int {
score := weightAhead*capCount(s.Ahead) + weightBehd*capCount(s.Behind)
score += weightDirty * capCount(s.Staged+s.Unstaged+s.Untracked+s.Stashes+s.OtherBranchCommits)
if s.ScanError != "" {
score += weightErr
}
if Stale(s, now) {
score += weightStale
}
return score
}
// Less reports whether repo a should sort before repo b: higher tier first, then
// higher sub-score, then name ascending for a stable, deterministic order.
func Less(a, b model.Repo, now time.Time) bool {
ta, tb := Classify(a.Status, now), Classify(b.Status, now)
if ta != tb {
return ta > tb