mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-03-31 10:25:55 +00:00
Sort digest repos by name.
This commit is contained in:
parent
c0375fdb37
commit
eb1ba582e2
2 changed files with 10 additions and 2 deletions
1
TODO
1
TODO
|
|
@ -8,7 +8,6 @@ TODO
|
|||
|
||||
Notes:
|
||||
- Will need to get/store timezone of user (use https://bitbucket.org/pellepim/jstimezonedetect, use it with time.Location.LoadLocation)
|
||||
- To get digests for non-user owned organizations, will need to list the organizations and their repositories
|
||||
- To make a raw HTTP request with the github package:
|
||||
httpReq, _ := githubClient.NewRequest("GET", "user/teams", nil)
|
||||
var jsonResp interface{}
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ import (
|
|||
"net/http"
|
||||
"net/http/httputil"
|
||||
"net/url"
|
||||
"sort"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
|
|
@ -31,6 +32,13 @@ type RepoDigest struct {
|
|||
Commits []github.RepositoryCommit
|
||||
}
|
||||
|
||||
// sort.Interface implementation for sorting RepoDigests.
|
||||
type ByRepoFullName []*RepoDigest
|
||||
|
||||
func (a ByRepoFullName) Len() int { return len(a) }
|
||||
func (a ByRepoFullName) Swap(i, j int) { a[i], a[j] = a[j], a[i] }
|
||||
func (a ByRepoFullName) Less(i, j int) bool { return *a[i].Repo.FullName < *a[j].Repo.FullName }
|
||||
|
||||
type Digest struct {
|
||||
User *github.User
|
||||
StartTime time.Time
|
||||
|
|
@ -70,6 +78,7 @@ func (digest *Digest) Fetch(repos []github.Repository, githubClient *github.Clie
|
|||
digest.RepoDigests = append(digest.RepoDigests, r.repoDigest)
|
||||
}
|
||||
}
|
||||
sort.Sort(ByRepoFullName(digest.RepoDigests))
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
@ -144,7 +153,7 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
|
|||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
newRepos := make([]github.Repository, len(repos) + len(orgRepos))
|
||||
newRepos := make([]github.Repository, len(repos)+len(orgRepos))
|
||||
copy(newRepos, repos)
|
||||
copy(newRepos[len(repos):], orgRepos)
|
||||
repos = newRepos
|
||||
|
|
|
|||
Loading…
Reference in a new issue