Example #1
0
func main() {
	kingpin.Version(VERSION)
	kingpin.Parse()

	logrus.SetOutput(os.Stderr)

	repo, err := git.OpenRepository(*path)
	if err != nil {
		logrus.Fatal("Not a git repository")
	}

	defer repo.Free()

	if err := checkRemotes(repo); err != nil {
		logrus.Error(err)
		return
	}

	line := liner.NewLiner()
	defer line.Close()
	line.SetCtrlCAborts(true)

	startRef, err := readRef(repo, line, "Start ref: ")
	if err == liner.ErrPromptAborted {
		return
	} else if err != nil {
		logrus.Error(err)
		return
	}

	endRef, err := readRef(repo, line, "End ref: ")
	if err == liner.ErrPromptAborted {
		return
	} else if err != nil {
		logrus.Error(err)
		return
	}

	issueNumbers, err := extractIssueNumbers(repo, startRef, endRef)

	logrus.Infof("Found %d issues...", len(issueNumbers))

	issues, err := getIssues(issueNumbers)
	if err != nil {
		logrus.Error(err)
		return
	}

	fmt.Println(formatIssues(issues))
}
Example #2
0
func getIssues(issueNumbers []int) ([]*github.Issue, error) {
	ts := oauth2.StaticTokenSource(&oauth2.Token{AccessToken: *token})
	tc := oauth2.NewClient(oauth2.NoContext, ts)
	ghClient := github.NewClient(tc)

	issues := []*github.Issue{}
	for _, issue := range issueNumbers {
		logrus.Infof("#%d", issue)
		issue, _, err := ghClient.Issues.Get(*owner, *repoName, issue)
		if err != nil {
			logrus.Errorf("Error fetching issue #%d: %v", issue, err)
			continue
		}

		issues = append(issues, issue)
	}

	return issues, nil
}