Пример #1
0
func updateIssue(client *octokit.Client, number int, level string) error {
	labels := []string{"bug", "duplicate"}
	if len(level) > 0 {
		labels = append(labels, level)
	}
	var params octokit.IssueParams
	params = octokit.IssueParams{
		Labels: labels}
	issueInfo := octokit.M{"owner": owner,
		"repo": repo, "number": number}
	pastIssue, pastIssueResult := client.Issues().One(nil, issueInfo)
	if !pastIssueResult.HasError() {
		now := time.Now()
		timestamp := now.Format(time.RFC850)
		bodyBuffer := new(bytes.Buffer)
		bodyBuffer.WriteString(pastIssue.Body)
		bodyBuffer.WriteString("\n")
		bodyBuffer.WriteString(timestamp)
		body := bodyBuffer.String()
		params = octokit.IssueParams{
			Body:   body,
			Labels: labels}
	}

	_, result := client.Issues().Update(nil, issueInfo, params)
	if result.HasError() {
		return result.Err
	}

	return nil
}
Пример #2
0
func createIssue(client *octokit.Client, title string, body string, level string) error {
	labels := []string{"bug"}
	if len(level) > 0 {
		labels = append(labels, level)
	}
	params := octokit.IssueParams{
		Title:  title,
		Body:   body,
		Labels: labels}
	time.Now()
	_, result := client.Issues().Create(nil, octokit.M{"owner": owner,
		"repo": repo}, params)
	if result.HasError() {
		return result.Err
	}
	return nil
}
Пример #3
0
func searchIssue(client *octokit.Client, query string, level string) (*octokit.IssueSearchResults, *octokit.Result) {
	queryBuffer := new(bytes.Buffer)
	queryBuffer.WriteString(query)
	queryBuffer.WriteString("+label:bug")
	if len(level) > 0 {
		queryBuffer.WriteString(" +label:")
		queryBuffer.WriteString(level)
	}
	queryBuffer.WriteString(" +state:open")
	queryBuffer.WriteString(" +repo:")
	queryBuffer.WriteString(owner)
	queryBuffer.WriteString("/")
	queryBuffer.WriteString(repo)
	search := client.Search()
	params := octokit.M{"query": queryBuffer.String()}
	searchResults, result := search.Issues(nil, params)
	return searchResults, result
}