Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(228)

Unified Diff: milo/frontend/console/console.go

Issue 2977083002: Move gitiles module from milo to common/api. (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« common/api/gitiles/gitiles.go ('K') | « milo/common/gitiles/gitiles.go ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: milo/frontend/console/console.go
diff --git a/milo/frontend/console/console.go b/milo/frontend/console/console.go
index 74c1b6826a697a2834c9d58aafa1addc77425337..85731c0fe1cba1d5d0042a6a74a194c9e5ecee9f 100644
--- a/milo/frontend/console/console.go
+++ b/milo/frontend/console/console.go
@@ -21,12 +21,12 @@ import (
"golang.org/x/net/context"
+ "github.com/luci/luci-go/common/api/gitiles"
"github.com/luci/luci-go/common/clock"
"github.com/luci/luci-go/common/logging"
"github.com/luci/luci-go/milo/api/config"
"github.com/luci/luci-go/milo/api/resp"
"github.com/luci/luci-go/milo/common"
- "github.com/luci/luci-go/milo/common/gitiles"
"github.com/luci/luci-go/milo/common/model"
"github.com/luci/luci-go/server/router"
)
@@ -79,7 +79,7 @@ func console(c context.Context, project, name string) (*resp.Console, error) {
if err != nil {
return nil, err
}
- commits, err := gitiles.GetCommits(c, def.RepoURL, def.Branch, 25)
+ commits, err := getCommits(c, def.RepoURL, def.Branch, 25)
if err != nil {
return nil, err
}
@@ -120,3 +120,25 @@ func console(c context.Context, project, name string) (*resp.Console, error) {
return cs, nil
}
+
+func getCommits(c context.Context, repoURL, treeish string, limit int) ([]resp.Commit, error) {
+ commits, err := gitiles.Log(c, repoURL, treeish, limit)
+ if err != nil {
+ return nil, err
+ }
+ // Move things into our own datastructure.
+ result := make([]resp.Commit, len(commits))
+ for i, log := range commits {
+ result[i] = resp.Commit{
+ AuthorName: log.Author.Name,
+ AuthorEmail: log.Author.Email,
+ Repo: repoURL,
+ Revision: resp.NewLink(log.Commit, repoURL+"/+/"+log.Commit),
+ Description: log.Message,
+ Title: strings.SplitN(log.Message, "\n", 2)[0],
+ // TODO(hinoka): Fill in the rest of resp.Commit and add those details
+ // in the html.
+ }
+ }
+ return result, nil
+}
« common/api/gitiles/gitiles.go ('K') | « milo/common/gitiles/gitiles.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698