1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-09 15:35:27 +02:00

non-hack issue numbers

This commit is contained in:
Elliott Stoneham 2016-06-30 11:37:18 +01:00
parent 7e88297d06
commit be05b21c5f
2 changed files with 52 additions and 25 deletions

View file

@ -63,7 +63,7 @@
</div> </div>
<div class="input-control"> <div class="input-control">
<label>Issue numbers</label> <label>Issue numbers</label>
<div class="tip">A comma separated list of issue numbers e.g. 12, 17, 42 (TODO only those below 100 work currently)</div> <div class="tip">A comma separated list of issue numbers e.g. 42, 1066, 1966 (other selection criteria are ignored)</div>
{{input id="github-issues" value=config.issues type="text" }} {{input id="github-issues" value=config.issues type="text" }}
</div> </div>
<div class="input-control"> <div class="input-control">

View file

@ -401,43 +401,70 @@ func (*Provider) getIssueNum(client *gogithub.Client, config githubConfig) ([]gi
func (*Provider) getIssues(client *gogithub.Client, config githubConfig) ([]githubIssue, error) { func (*Provider) getIssues(client *gogithub.Client, config githubConfig) ([]githubIssue, error) {
pp := config.BranchLines ret := []githubIssue{}
isRequired := make(map[int]bool)
for _, s := range strings.Split(config.IssuesText, ",") { isRequired := make([]int, 0, 10)
for _, s := range strings.Split(strings.Replace(config.IssuesText, "#", "", -1), ",") {
i, err := strconv.Atoi(strings.TrimSpace(s)) i, err := strconv.Atoi(strings.TrimSpace(s))
if err == nil { if err == nil {
isRequired[i] = true isRequired = append(isRequired, i)
} }
} }
if len(isRequired) > 0 { if len(isRequired) > 0 {
pp = 100
}
opts := &gogithub.IssueListByRepoOptions{ for _, i := range isRequired {
Sort: "updated",
State: config.IssueState.ID,
ListOptions: gogithub.ListOptions{PerPage: pp}}
if config.SincePtr != nil { issue, _, err := client.Issues.Get(config.Owner, config.Repo, i)
opts.Since = *config.SincePtr
}
for _, lab := range config.Lists { if err == nil {
if lab.Included { n := ""
opts.Labels = append(opts.Labels, lab.Name) p := issue.User
if p != nil {
if p.Login != nil {
n = *p.Login
}
}
l := ""
for _, ll := range issue.Labels {
l += `<span class="github-issue-label" style="background-color:#` + *ll.Color + `">` + *ll.Name + `</span> `
}
ret = append(ret, githubIssue{
Name: n,
Message: *issue.Title,
Date: issue.CreatedAt.Format("January 2 2006, 15:04"),
Updated: issue.UpdatedAt.Format("January 2 2006, 15:04"),
URL: template.URL(*issue.HTMLURL),
Labels: template.HTML(l),
ID: *issue.Number,
IsOpen: *issue.State == "open",
})
}
} }
}
ret := []githubIssue{} } else {
guff, _, err := client.Issues.ListByRepo(config.Owner, config.Repo, opts) opts := &gogithub.IssueListByRepoOptions{
Sort: "updated",
State: config.IssueState.ID,
ListOptions: gogithub.ListOptions{PerPage: config.BranchLines}}
if err != nil { if config.SincePtr != nil {
return ret, err opts.Since = *config.SincePtr
} }
for _, v := range guff { for _, lab := range config.Lists {
if len(isRequired) == 0 || isRequired[*v.Number] { if lab.Included {
opts.Labels = append(opts.Labels, lab.Name)
}
}
guff, _, err := client.Issues.ListByRepo(config.Owner, config.Repo, opts)
if err != nil {
return ret, err
}
for _, v := range guff {
n := "" n := ""
ptr := v.User ptr := v.User
if ptr != nil { if ptr != nil {