當前位置: 首頁>>代碼示例>>Golang>>正文


Golang GitHub.IssueAddVersionLabel方法代碼示例

本文整理匯總了Golang中github.com/docker/leeroy/github.GitHub.IssueAddVersionLabel方法的典型用法代碼示例。如果您正苦於以下問題:Golang GitHub.IssueAddVersionLabel方法的具體用法?Golang GitHub.IssueAddVersionLabel怎麽用?Golang GitHub.IssueAddVersionLabel使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在github.com/docker/leeroy/github.GitHub的用法示例。


在下文中一共展示了GitHub.IssueAddVersionLabel方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1: handleIssue

func handleIssue(w http.ResponseWriter, r *http.Request) {
	logrus.Debugf("Got an issue hook")

	// parse the issue
	body, err := ioutil.ReadAll(r.Body)
	if err != nil {
		logrus.Errorf("Error reading github issue handler body: %v", err)
		w.WriteHeader(500)
		return
	}

	issueHook, err := octokat.ParseIssueHook(body)
	if err != nil {
		logrus.Errorf("Error parsing issue hook: %v", err)
		w.WriteHeader(500)
		return
	}

	// get the build
	baseRepo := fmt.Sprintf("%s/%s", issueHook.Repo.Owner.Login, issueHook.Repo.Name)
	logrus.Debugf("Issue is for repo: %s", baseRepo)
	build, err := config.getBuildByContextAndRepo("janky", baseRepo)
	if err != nil {
		logrus.Warnf("could not find build for repo %s for issue handler, skipping: %v", baseRepo, err)
		return
	}

	// if we do not handle issues for this build just return
	if !build.HandleIssues {
		logrus.Warnf("Not configured to handle issues for %s", baseRepo)
		return
	}

	g := github.GitHub{
		AuthToken: config.GHToken,
		User:      config.GHUser,
	}

	logrus.Infof("Received GitHub issue notification for %s %d (%s): %s", baseRepo, issueHook.Issue.Number, issueHook.Issue.URL, issueHook.Action)

	// if it is not a comment or an opened issue
	// return becuase we dont care
	if !issueHook.IsComment() && !issueHook.IsOpened() {
		logrus.Debugf("Ignoring issue hook action %q", issueHook.Action)
		return
	}

	if issueHook.Issue.State != "open" {
		return
	}

	if issueHook.Issue.PullRequest.HTMLURL != "" {
		if err := g.MoveTriageForward(issueHook.Repo, issueHook.Issue.Number, issueHook.Comment); err != nil {
			logrus.Error(err)
			w.WriteHeader(500)
			return
		}

		w.WriteHeader(204)
		return
	}

	// Try to label the issue with the version information it contains.
	if err := g.IssueAddVersionLabel(issueHook); err != nil {
		logrus.Errorf("Error applying version label to issue: %v", err)
		w.WriteHeader(500)
		return
	}

	// handle if it is an issue comment
	// apply approproate labels
	if err := g.LabelIssueComment(issueHook); err != nil {
		logrus.Errorf("Error applying labels to issue comment: %v", err)
		w.WriteHeader(500)
		return
	}

	return
}
開發者ID:vdemeester,項目名稱:leeroy,代碼行數:79,代碼來源:handlers.go


注:本文中的github.com/docker/leeroy/github.GitHub.IssueAddVersionLabel方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。