From 545b1cba71429d34feacdf25ae7ac8713020b6ba Mon Sep 17 00:00:00 2001 From: Elliott Stoneham Date: Sun, 11 Sep 2016 17:22:52 +0100 Subject: [PATCH] fix Github section milestone URL and blank commit messages --- core/section/github/commits.go | 7 ++--- core/section/github/commits_template.go | 4 +-- core/section/github/milestones.go | 37 +++++++++++++------------ 3 files changed, 23 insertions(+), 25 deletions(-) diff --git a/core/section/github/commits.go b/core/section/github/commits.go index 9b756961..9caaec4d 100644 --- a/core/section/github/commits.go +++ b/core/section/github/commits.go @@ -29,14 +29,13 @@ type githubCommit struct { Repo string `json:"repo"` ShowRepo bool `json:"showRepo"` Branch string `json:"branch"` - ShowBranch bool `json:"ShowBranch"` + ShowBranch bool `json:"showBranch"` Date string `json:"date"` BinDate time.Time `json:"-"` // only used for sorting - ShowDate bool `json:"ShowDate"` + ShowDate bool `json:"showDate"` Login string `json:"login"` Name string `json:"name"` Avatar string `json:"avatar"` - ShowUser bool `json:"ShowUser"` Message string `json:"message"` URL template.URL `json:"url"` } @@ -224,7 +223,6 @@ func getCommits(client *gogithub.Client, config *githubConfig) ([]githubCommit, overall[k].ShowRepo = true overall[k].ShowBranch = true overall[k].ShowDate = true - overall[k].ShowUser = true if k > 0 { if overall[k].Repo == overall[k-1].Repo { overall[k].ShowRepo = false @@ -232,7 +230,6 @@ func getCommits(client *gogithub.Client, config *githubConfig) ([]githubCommit, overall[k].ShowBranch = false if overall[k].Date == overall[k-1].Date { overall[k].ShowDate = false - overall[k].ShowUser = overall[k].Name != overall[k-1].Name } } } diff --git a/core/section/github/commits_template.go b/core/section/github/commits_template.go index ae3118ea..107fc792 100644 --- a/core/section/github/commits_template.go +++ b/core/section/github/commits_template.go @@ -73,9 +73,7 @@ const commitsTemplate = ` @{{$commit.Name}} - {{if $commit.ShowUser}} -
{{$commit.Message}}
- {{end}} +
{{$commit.Message}}
{{$commit.Name}} {{if $commit.ShowDate}} · {{$commit.Date}} {{end}} diff --git a/core/section/github/milestones.go b/core/section/github/milestones.go index 7572211e..2e6fd6c0 100644 --- a/core/section/github/milestones.go +++ b/core/section/github/milestones.go @@ -13,6 +13,7 @@ package github import ( "fmt" + "html/template" "sort" "github.com/documize/community/core/log" @@ -21,18 +22,18 @@ import ( ) type githubMilestone struct { - Repo string `json:"repo"` - Private bool `json:"private"` - Name string `json:"name"` - URL string `json:"url"` - IsOpen bool `json:"isopen"` - OpenIssues int `json:"openIssues"` - ClosedIssues int `json:"closedIssues"` - CompleteMsg string `json:"completeMsg"` - DueDate string `json:"dueDate"` - UpdatedAt string `json:"updatedAt"` - Progress uint `json:"progress"` - IsMilestone bool `json:"isMilestone"` + Repo string `json:"repo"` + Private bool `json:"private"` + Name string `json:"name"` + URL template.URL `json:"url"` + IsOpen bool `json:"isopen"` + OpenIssues int `json:"openIssues"` + ClosedIssues int `json:"closedIssues"` + CompleteMsg string `json:"completeMsg"` + DueDate string `json:"dueDate"` + UpdatedAt string `json:"updatedAt"` + Progress uint `json:"progress"` + IsMilestone bool `json:"isMilestone"` } // sort milestones in order that that should be presented. @@ -124,10 +125,12 @@ func getMilestones(client *gogithub.Client, config *githubConfig) ([]githubMiles progress := float64(*v.ClosedIssues*100) / float64(*v.OpenIssues+*v.ClosedIssues) ret = append(ret, githubMilestone{ - Repo: repoName(rName), - Private: orb.Private, - Name: *v.Title, - URL: *v.HTMLURL, + Repo: repoName(rName), + Private: orb.Private, + Name: *v.Title, + URL: template.URL(fmt.Sprintf( + "https://github.com/%s/%s/milestone/%d", + orb.Owner, orb.Repo, *v.Number)), // *v.HTMLURL does not give the correct value IsOpen: *v.State == "open", OpenIssues: *v.OpenIssues, ClosedIssues: *v.ClosedIssues, @@ -196,7 +199,7 @@ func renderMilestones(payload *githubRender, c *githubConfig) error { if issuesClosed+issuesOpen > 0 { payload.Milestones = append(payload.Milestones, githubMilestone{ Repo: orb.Repo, Private: orb.Private, Name: noMilestone, IsOpen: true, - OpenIssues: issuesOpen, ClosedIssues: issuesClosed, URL: orb.URL, + OpenIssues: issuesOpen, ClosedIssues: issuesClosed, URL: template.URL(orb.URL), }) }