Skip to content

Commit

Permalink
Include owner/repo in table & PR status
Browse files Browse the repository at this point in the history
  • Loading branch information
gillchristian committed Oct 17, 2018
1 parent a1ceb98 commit 68b7c44
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 9 deletions.
15 changes: 13 additions & 2 deletions castor.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ func printPRsList(count int, prs []SearchPR) {
}
w := new(tabwriter.Writer)
w.Init(os.Stdout, 5, 2, 1, ' ', tabwriter.Debug)
fmt.Fprintln(w, " PR\t TITLE\t BRANCH\t AUTHOR\t REVIEWS\t LABELS")
fmt.Fprintln(w, " PR\t REPO\t TITLE\t BRANCH\t AUTHOR\t STATUS\t REVIEWS\t LABELS")

for _, pr := range prs {
var reviews string
Expand All @@ -95,13 +95,24 @@ func printPRsList(count int, prs []SearchPR) {
reviews = fmt.Sprintf("Missing %v %s (%s)", pr.ReviewRequests.TotalCount, rev, reviewers)
}

// TODO: fix string len when using colors (breaks column width)
status := "Open" // rgbterm.FgString("Open", 0, 255, 0)
if pr.Closed {
status = "Closed" // rgbterm.FgString("Closed", 255, 0, 0)
}
if pr.Merged {
status = "Merged" // rgbterm.FgString("Merged", 111, 66, 193)
}

fmt.Fprintf(
w,
" %v\t %s\t %s\t %s\t %s\t %s\n",
" %v\t %s\t %s\t %s\t %s\t %s\t %s\t %s\n",
pr.Number,
pr.HeadRepositoryOwner.Login+"/"+pr.HeadRepository.Name,
truncate(pr.Title, 30),
truncate(pr.HeadRefName, 30),
pr.Author.Login,
status,
reviews,
labels(pr.Labels),
)
Expand Down
9 changes: 9 additions & 0 deletions fetch.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ func fetchPRs(conf PRsConfig, user, token string) (PRsSearch, error) {
if !conf.All {
search = append(search, "repo:"+owner+"/"+repo)
}
// TODO: closed vs merged
if conf.Closed && !conf.Open {
search = append(search, "is:closed")
}
Expand Down Expand Up @@ -78,6 +79,14 @@ nodes {
author {
login
}
headRepository {
name
}
headRepositoryOwner {
login
}
closed
merged
headRefName
labels(first: 20) {
totalCount
Expand Down
26 changes: 19 additions & 7 deletions types.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,25 @@ type PRsSearch struct {
}

type SearchPR struct {
URL string `json:"url"`
Number int `json:"number"`
Title string `json:"title"`
Author WithLogin `json:"author"`
HeadRefName string `json:"headRefName"`
Labels Labels `json:"Labels"`
ReviewRequests ReviewRequests `json:"reviewRequests"`
URL string `json:"url"`
Number int `json:"number"`
Title string `json:"title"`
Author WithLogin `json:"author"`
HeadRefName string `json:"headRefName"`
HeadRepository Name `json:"headRepository"`
HeadRepositoryOwner Login `json:"headRepositoryOwner"`
Closed bool `json:"closed"`
Merged bool `json:"Merged"`
Labels Labels `json:"Labels"`
ReviewRequests ReviewRequests `json:"reviewRequests"`
}

type Name struct {
Name string `json:"name"`
}

type Login struct {
Login string `json:"login"`
}

type LoginAndName struct {
Expand Down

0 comments on commit 68b7c44

Please sign in to comment.