Skip to content

Commit b0b07a1

Browse files
author
Christian Richter
committed
Add support for closed issues & issue grouping
Signed-off-by: Christian Richter <crichter@suse.com>
1 parent c719d68 commit b0b07a1

File tree

1 file changed

+41
-12
lines changed

1 file changed

+41
-12
lines changed

cmd/github2orgmode/github2orgmode.go

Lines changed: 41 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,37 +34,66 @@ func main() {
3434
}
3535
// list all repositories for the authenticated user for the selected repos
3636
for _, r := range reposlist {
37-
o = append(o, fmt.Sprintf("* %s", r))
37+
project := fmt.Sprintf("* %s", r)
38+
todo := []string{}
39+
prog := []string{}
40+
done := []string{}
3841
data := strings.Split(r, "/")
3942
opts := github.IssueListByRepoOptions{
40-
State: "open",
43+
State: "all",
44+
ListOptions: github.ListOptions{
45+
PerPage: 100000,
46+
},
4147
}
4248
issues, _, err := client.Issues.ListByRepo(ctx, data[0], data[1], &opts)
4349
if err != nil {
4450
fmt.Println(err)
4551
os.Exit(1)
4652
}
4753
for _, i := range issues {
48-
54+
issue := []string{}
4955
// add org- and repo-name to tags
5056
labels := fmt.Sprintf(":%s:%s:", reg.ReplaceAllString(data[0], ""), reg.ReplaceAllLiteralString(data[1], ""))
5157
for _, l := range i.Labels {
5258
labels = labels + reg.ReplaceAllString(l.GetName(), "") + ":"
5359
}
54-
o = append(o, fmt.Sprintf("** TODO %s \t\t %s", i.GetTitle(), labels))
60+
status := "TODO"
61+
for _, a := range i.Assignees {
62+
for _, handle := range handlelist {
63+
if a.GetLogin() == handle {
64+
status = "IN PROGRESS"
65+
}
66+
}
67+
}
68+
if i.GetState() == "closed" {
69+
status = "DONE"
70+
}
71+
issue = append(issue, fmt.Sprintf("** %s %s \t\t %s", status, i.GetTitle(), labels))
72+
issue = append(issue, fmt.Sprintf("\tState : %s", i.GetState()))
73+
issue = append(issue, fmt.Sprintf("\tCreator : %s", i.GetUser().GetLogin()))
5574
// the timestamps have been created without < & > intentionally
5675
// I do not want them to show up in the daily agenda
57-
o = append(o, fmt.Sprintf("\tCreated : %s", i.GetCreatedAt()))
58-
o = append(o, fmt.Sprintf("\tUpdated : %s", i.GetUpdatedAt()))
59-
o = append(o, fmt.Sprintf("\tCreator : %s", i.GetUser().GetLogin()))
76+
issue = append(issue, fmt.Sprintf("\tCreated : %s", i.GetCreatedAt()))
77+
issue = append(issue, fmt.Sprintf("\tUpdated : %s", i.GetUpdatedAt()))
6078
for _, a := range i.Assignees {
61-
o = append(o, fmt.Sprintf("\tAssignee : %s", a.GetLogin()))
79+
issue = append(issue, fmt.Sprintf("\tAssignee : %s", a.GetLogin()))
80+
}
81+
if i.GetState() == "closed" {
82+
issue = append(issue, fmt.Sprintf("\tClosed at : %s", i.GetClosedAt()))
83+
}
84+
issue = append(issue, fmt.Sprintf("\t[%s]", i.GetURL()))
85+
issue = append(issue, "\n")
86+
issue = append(issue, formatBody(i.GetBody()))
87+
issue = append(issue, "\n")
88+
if status == "TODO" {
89+
todo = append(todo, strings.Join(issue, "\n"))
90+
} else if status == "DONE" {
91+
done = append(done, strings.Join(issue, "\n"))
92+
} else {
93+
prog = append(prog, strings.Join(issue, "\n"))
6294
}
63-
o = append(o, fmt.Sprintf("\t[%s]", i.GetURL()))
64-
o = append(o, "\n")
65-
o = append(o, formatBody(i.GetBody()))
66-
o = append(o, "\n")
6795
}
96+
o = append(o, project, strings.Join(prog, "\n"), strings.Join(todo, "\n"), strings.Join(done, "\n"))
6897
}
6998
fmt.Printf(strings.Join(o, "\n") + "\n")
7099
}

0 commit comments

Comments
 (0)