mirror of
https://github.com/samsonjs/retrogit.git
synced 2026-04-27 15:07:43 +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:
|
Notes:
|
||||||
- Will need to get/store timezone of user (use https://bitbucket.org/pellepim/jstimezonedetect, use it with time.Location.LoadLocation)
|
- 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:
|
- To make a raw HTTP request with the github package:
|
||||||
httpReq, _ := githubClient.NewRequest("GET", "user/teams", nil)
|
httpReq, _ := githubClient.NewRequest("GET", "user/teams", nil)
|
||||||
var jsonResp interface{}
|
var jsonResp interface{}
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httputil"
|
"net/http/httputil"
|
||||||
"net/url"
|
"net/url"
|
||||||
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
|
@ -31,6 +32,13 @@ type RepoDigest struct {
|
||||||
Commits []github.RepositoryCommit
|
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 {
|
type Digest struct {
|
||||||
User *github.User
|
User *github.User
|
||||||
StartTime time.Time
|
StartTime time.Time
|
||||||
|
|
@ -70,6 +78,7 @@ func (digest *Digest) Fetch(repos []github.Repository, githubClient *github.Clie
|
||||||
digest.RepoDigests = append(digest.RepoDigests, r.repoDigest)
|
digest.RepoDigests = append(digest.RepoDigests, r.repoDigest)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
sort.Sort(ByRepoFullName(digest.RepoDigests))
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -144,7 +153,7 @@ func indexHandler(w http.ResponseWriter, r *http.Request) {
|
||||||
http.Error(w, err.Error(), http.StatusInternalServerError)
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
newRepos := make([]github.Repository, len(repos) + len(orgRepos))
|
newRepos := make([]github.Repository, len(repos)+len(orgRepos))
|
||||||
copy(newRepos, repos)
|
copy(newRepos, repos)
|
||||||
copy(newRepos[len(repos):], orgRepos)
|
copy(newRepos[len(repos):], orgRepos)
|
||||||
repos = newRepos
|
repos = newRepos
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue