@@ -9,10 +9,11 @@ import ( "sort" "strings" "unicode" "dmitri.shuralyov.com/service/change" "github.com/shurcooL/issues" "github.com/shurcooL/users" "golang.org/x/build/maintner" "sourcegraph.com/sourcegraph/go-diff/diff" ) @@ -44,24 +45,31 @@ func (s service) List(_ context.Context, repo string, opt change.ListOptions) ([ case opt.Filter == change.FilterOpen && state != change.OpenState: return nil case opt.Filter == change.FilterClosedMerged && !(state == change.ClosedState || state == change.MergedState): return nil } var labels []issues.Label cl.Meta.Hashtags().Foreach(func(hashtag string) { labels = append(labels, issues.Label{ Name: hashtag, Color: issues.RGB{R: 0xed, G: 0xed, B: 0xed}, // A default light gray. }) }) is = append(is, change.Change{ ID: uint64(cl.Number), State: state, Title: firstParagraph(cl.Commit.Msg), Labels: labels, Author: gerritUser(cl.Commit.Author), CreatedAt: cl.Created, Replies: len(cl.Messages), }) return nil }) if err != nil { return nil, err } //sort.Sort(sort.Reverse(byID(is))) // For some reason, IDs don't completely line up with created times. sort.Slice(is, func(i, j int) bool { return is[i].CreatedAt.After(is[j].CreatedAt) }) return is, nil } @@ -100,14 +108,22 @@ 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 } var labels []issues.Label cl.Meta.Hashtags().Foreach(func(hashtag string) { labels = append(labels, issues.Label{ Name: hashtag, Color: issues.RGB{R: 0xed, G: 0xed, B: 0xed}, // A default light gray. }) }) return change.Change{ ID: uint64(cl.Number), State: state(cl.Status), Title: firstParagraph(cl.Commit.Msg), Labels: labels, Author: gerritUser(cl.Commit.Author), CreatedAt: cl.Created, Replies: len(cl.Messages), Commits: int(cl.Version), ChangedFiles: 0, // TODO.