示例#1
0
func getRepoIssues(c *cli.Context) {
	owner, repo, err := util.SplitOrgRepoName(c.Args().Get(0))
	if err != nil {
		log.Fatal(err)
	}
	opts := &github.IssueListByRepoOptions{
		ListOptions: github.ListOptions{PerPage: 30},
	}
	issues, _, err := gh.Client.Issues.ListByRepo(owner, repo, opts)
	if err != nil {
		fmt.Println(err)
	}
	if len(issues) == 0 {
		fmt.Println("No issues found")
	}

	// PRs are considered issues. Remove all PRs from issue array.
	for index, issue := range issues {
		if issue.PullRequestLinks != nil {
			issues = append(issues[:index], issues[index+1:]...)
		}
	}

	util.PrintJson(issues)
}
示例#2
0
func getRepo(c *cli.Context) {
	o, r, err := util.SplitOrgRepoName(c.Args().Get(0))
	if err != nil {
		log.Fatal(err)
	}
	repo, _, err := gh.Client.Repositories.Get(o, r)
	if err != nil {
		log.Fatal(err)
	}

	util.PrintJson(*repo)
}
示例#3
0
func getIssue(c *cli.Context) {
	owner, repo, err := util.SplitOrgRepoName(c.Args().Get(0))
	if err != nil {
		log.Fatal(err)
	}

	number, _ := strconv.Atoi(c.Args().Get(1))

	issue, _, err := gh.Client.Issues.Get(owner, repo, number)
	if err != nil {
		fmt.Println(err)
	}

	util.PrintJson(issue)
}
示例#4
0
func getRepoPullRequests(c *cli.Context) {
	owner, repo, err := util.SplitOrgRepoName(c.Args().Get(0))
	if err != nil {
		log.Fatal(err)
	}
	opts := &github.PullRequestListOptions{
		ListOptions: github.ListOptions{PerPage: 30},
	}
	prs, _, err := gh.Client.PullRequests.List(owner, repo, opts)
	if err != nil {
		fmt.Println(err)
	}
	if len(prs) == 0 {
		fmt.Println("No PRs found")
	}

	util.PrintJson(prs)
}