diff --git a/api.go b/api.go index 6d66bda..9cd36d1 100644 --- a/api.go +++ b/api.go @@ -19,7 +19,6 @@ type Repo struct { GiteaCreated time.Time `json:"created_at"` GiteaUpdated time.Time `json:"updated_at"` - oldestCommit time.Time newestCommit time.Time topics []string } @@ -46,16 +45,6 @@ func (this *Application) populateCommitInfo(ctx context.Context, rr *Repo) { } } - // The oldest commit needs us to page through the commit history to find it - - oldestCommit, err := this.oldestCommit(ctx, rr.Name, "") - if err != nil { - log.Printf("finding oldest commit for '%s': %s", rr.Name, err) - rr.oldestCommit = rr.GiteaCreated // best guess - - } else { - rr.oldestCommit = oldestCommit.Commit.Author.Date - } } type ContentsResponse struct { @@ -189,17 +178,6 @@ func (this *Application) commits(ctx context.Context, repo, ref string) ([]Commi return ret, nil } -func (this *Application) oldestCommit(ctx context.Context, repo, ref string) (CommitListEntry, error) { - cc, err := this.commits(ctx, repo, ref) - if err != nil { - return CommitListEntry{}, err - } - - // Take the last listed entry - // TODO maybe need to iterate/sort? - return cc[len(cc)-1], nil -} - // reposPage gets a single page of the list of Git repositories in this organisation. func (this *Application) reposPage(ctx context.Context, page, limit int) ([]Repo, error) { var repos []Repo diff --git a/pages.go b/pages.go index bf34cb7..7109ccd 100644 --- a/pages.go +++ b/pages.go @@ -114,8 +114,8 @@ func (this *Application) Homepage(w http.ResponseWriter, r *http.Request) { diff --git a/sync.go b/sync.go index c9cfc2a..f828d83 100644 --- a/sync.go +++ b/sync.go @@ -71,7 +71,7 @@ func (this *Application) sync(ctx context.Context) (bool, error) { // But then make sure the final sort is by most-recently-created sort.Slice(repos, func(i, j int) bool { - return repos[i].oldestCommit.After(repos[j].oldestCommit) + return repos[i].GiteaCreated.After(repos[j].GiteaCreated) }) // Commit our changes for the other threads to look at