Skip to content

Commit

Permalink
print issue, when available
Browse files Browse the repository at this point in the history
  • Loading branch information
mms-gianni committed Mar 3, 2021
1 parent 4c60e7d commit 0673b75
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
25 changes: 23 additions & 2 deletions common/githubcommands.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package common
import (
"context"
"fmt"
"regexp"
"strconv"
"strings"

Expand Down Expand Up @@ -160,9 +161,17 @@ func GetStatus(c *clif.Command, out clif.Output) []CardslistItem {
var cardslist []CardslistItem
for _, project := range projectslist {
cards := getCards(client, project)
out.Printf("\n<subline>List: " + project.GetName() + "<reset>\n")
out.Printf("\n<subline>Project: " + project.GetName() + "<reset>\n")
for _, card := range cards {
out.Printf(strconv.Itoa(item) + "| <" + card.GetColumnName() + "> " + card.GetNote() + "\n")
title := ""
if card.GetContentURL() != "" {
issue := getIssueDetails(c, card.GetContentURL())
title = "Issue #" + strconv.Itoa(issue.GetNumber()) + " : " + issue.GetTitle()
} else {
title = card.GetNote()
}

out.Printf("%3s| <%s> %s\n", strconv.Itoa(item), card.GetColumnName(), title)
cardslist = append(cardslist, CardslistItem{
id: item,
carddetails: card,
Expand All @@ -175,6 +184,18 @@ func GetStatus(c *clif.Command, out clif.Output) []CardslistItem {
return cardslist
}

func getIssueDetails(c *clif.Command, issueURL string) *github.Issue {
client := login(c)

re := regexp.MustCompile(`https://api.github.com/repos/(.*)/(.*)/issues/(.*)`)
findings := re.FindAllStringSubmatch(issueURL, -1)

issueNR, _ := strconv.Atoi(findings[0][3])
issue, _, _ := client.Issues.Get(ctx, findings[0][1], findings[0][2], issueNR)

return issue
}

func MoveCard(c *clif.Command, out clif.Output, in clif.Input) {
client := login(c)

Expand Down
2 changes: 1 addition & 1 deletion main/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ func main() {
"open": "\U00002B50",
"done": "\U00002705",
"closed": "\U0001F512",
"in progress": "\U0001F528",
"in progress": "\U0001F525",
"waiting": "\U0001F551",
"critical": "\U000026A0",
"idea": "\U0001F4A1",
Expand Down

0 comments on commit 0673b75

Please sign in to comment.