1
0
Fork 0
mirror of https://github.com/documize/community.git synced 2025-08-09 07:25:23 +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 class="input-control">
<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" }}
</div>
<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) {
pp := config.BranchLines
isRequired := make(map[int]bool)
for _, s := range strings.Split(config.IssuesText, ",") {
ret := []githubIssue{}
isRequired := make([]int, 0, 10)
for _, s := range strings.Split(strings.Replace(config.IssuesText, "#", "", -1), ",") {
i, err := strconv.Atoi(strings.TrimSpace(s))
if err == nil {
isRequired[i] = true
isRequired = append(isRequired, i)
}
}
if len(isRequired) > 0 {
pp = 100
}
opts := &gogithub.IssueListByRepoOptions{
Sort: "updated",
State: config.IssueState.ID,
ListOptions: gogithub.ListOptions{PerPage: pp}}
for _, i := range isRequired {
if config.SincePtr != nil {
opts.Since = *config.SincePtr
}
issue, _, err := client.Issues.Get(config.Owner, config.Repo, i)
for _, lab := range config.Lists {
if lab.Included {
opts.Labels = append(opts.Labels, lab.Name)
if err == nil {
n := ""
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 {
return ret, err
}
if config.SincePtr != nil {
opts.Since = *config.SincePtr
}
for _, v := range guff {
if len(isRequired) == 0 || isRequired[*v.Number] {
for _, lab := range config.Lists {
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 := ""
ptr := v.User
if ptr != nil {