@@ -39,11 +39,12 @@ type Change struct { Labels []issues.Label Author users.User CreatedAt time.Time Replies int // Number of replies to this change (not counting the mandatory change description comment). Commits int // Number of commits (not populated during list operation). Commits int // Number of commits (not populated during list operation). ChangedFiles int // Number of changed files (not populated during list operation). } type Commit struct { SHA string Message string // TODO: Consider splitting into Subject, Body.
@@ -30,19 +30,19 @@ var s = struct { Commits []change.Commit Diffs map[string][]byte }{ { Change: change.Change{ ID: 1, State: change.MergedState, Title: "Initial implementation of woff2.", Labels: nil, Author: shurcool, CreatedAt: time.Date(2018, 2, 12, 0, 9, 19, 621031866, time.UTC), Replies: 1, Commits: 3, ID: 1, State: change.MergedState, Title: "Initial implementation of woff2.", Labels: nil, Author: shurcool, CreatedAt: time.Date(2018, 2, 12, 0, 9, 19, 621031866, time.UTC), Replies: 1, Commits: 3, ChangedFiles: 5, }, Timeline: []interface{}{ change.Comment{ ID: "0", User: shurcool,
@@ -67,14 +67,13 @@ func (s service) List(ctx context.Context, rs string, opt change.ListOptions) ([ for _, chg := range *cs { if chg.Status == "DRAFT" { continue } is = append(is, change.Change{ ID: uint64(chg.Number), State: state(chg.Status), Title: chg.Subject, //Labels: labels, // TODO. ID: uint64(chg.Number), State: state(chg.Status), Title: chg.Subject, Author: s.gerritUser(chg.Owner), CreatedAt: time.Time(chg.Created), Replies: len(chg.Messages), }) } @@ -99,16 +98,18 @@ func (s service) Get(ctx context.Context, _ string, id uint64) (change.Change, e } if chg.Status == "DRAFT" { return change.Change{}, os.ErrNotExist } return change.Change{ ID: id, State: state(chg.Status), Title: chg.Subject, Author: s.gerritUser(chg.Owner), CreatedAt: time.Time(chg.Created), Commits: len(chg.Revisions), ID: id, State: state(chg.Status), Title: chg.Subject, Author: s.gerritUser(chg.Owner), CreatedAt: time.Time(chg.Created), Replies: len(chg.Messages), Commits: len(chg.Revisions), ChangedFiles: 0, // TODO. }, nil } func state(status string) change.State { switch status {
@@ -169,13 +169,17 @@ func (s service) Get(ctx context.Context, rs string, id uint64) (change.Change, Number uint64 State githubql.PullRequestState Title string Author *githubqlActor CreatedAt githubql.DateTime Commits struct { Comments struct { TotalCount int } Commits struct { TotalCount int } ChangedFiles int } `graphql:"pullRequest(number:$prNumber)"` } `graphql:"repository(owner:$repositoryOwner,name:$repositoryName)"` } variables := map[string]interface{}{ "repositoryOwner": githubql.String(repo.Owner), @@ -196,16 +200,18 @@ func (s service) Get(ctx context.Context, rs string, id uint64) (change.Change, } // TODO: Eliminate comment body properties from issues.Issue. It's missing increasingly more fields, like Edited, etc. pr := q.Repository.PullRequest return change.Change{ ID: pr.Number, State: ghPRState(pr.State), Title: pr.Title, Author: ghActor(pr.Author), CreatedAt: pr.CreatedAt.Time, Commits: pr.Commits.TotalCount, ID: pr.Number, State: ghPRState(pr.State), Title: pr.Title, Author: ghActor(pr.Author), CreatedAt: pr.CreatedAt.Time, Replies: pr.Comments.TotalCount, Commits: pr.Commits.TotalCount, ChangedFiles: pr.ChangedFiles, }, nil } func (s service) ListCommits(ctx context.Context, rs string, id uint64) ([]change.Commit, error) { repo, err := ghRepoSpec(rs)
@@ -47,14 +47,13 @@ func (s service) List(_ context.Context, repo string, opt change.ListOptions) ([ return nil case opt.Filter == change.FilterClosedMerged && !(state == change.ClosedState || state == change.MergedState): return nil } is = append(is, change.Change{ ID: uint64(cl.Number), State: state, Title: firstParagraph(cl.Commit.Msg), //Labels: labels, // TODO. ID: uint64(cl.Number), State: state, Title: firstParagraph(cl.Commit.Msg), Author: gerritUser(cl.Commit.Author), CreatedAt: cl.Created, Replies: len(cl.Messages), }) return nil @@ -104,18 +103,18 @@ func (s service) Get(_ context.Context, repo string, id uint64) (change.Change, cl := project.CL(int32(id)) if cl == nil || cl.Private { return change.Change{}, os.ErrNotExist } return change.Change{ ID: uint64(cl.Number), State: state(cl.Status), Title: firstParagraph(cl.Commit.Msg), //Labels: labels, // TODO. Author: gerritUser(cl.Commit.Author), CreatedAt: cl.Created, Replies: len(cl.Messages), Commits: int(cl.Version), ID: uint64(cl.Number), State: state(cl.Status), Title: firstParagraph(cl.Commit.Msg), Author: gerritUser(cl.Commit.Author), CreatedAt: cl.Created, Replies: len(cl.Messages), Commits: int(cl.Version), ChangedFiles: 0, // TODO. }, nil } func (s service) ListTimeline(_ context.Context, repo string, id uint64, opt *change.ListTimelineOptions) ([]interface{}, error) { s.c.RLock()