本文整理汇总了Golang中github.com/google/go-github/github.PullRequest类的典型用法代码示例。如果您正苦于以下问题:Golang PullRequest类的具体用法?Golang PullRequest怎么用?Golang PullRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了PullRequest类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: MungePullRequest
func (PingCIMunger) MungePullRequest(client *github.Client, pr *github.PullRequest, issue *github.Issue, commits []github.RepositoryCommit, events []github.IssueEvent, opts opts.MungeOptions) {
if !HasLabel(issue.Labels, "lgtm") {
return
}
if pr.Mergeable == nil || !*pr.Mergeable {
glog.Infof("skipping CI check for %d since mergeable is nil or false", *pr.Number)
return
}
status, err := github_util.GetStatus(client, opts.Org, opts.Project, *pr.Number, []string{"Shippable", "continuous-integration/travis-ci/pr"})
if err != nil {
glog.Errorf("unexpected error getting status: %v", err)
return
}
if status == "incomplete" {
if opts.Dryrun {
glog.Infof("would have pinged CI for %d", pr.Number)
return
}
glog.V(2).Infof("status is incomplete, closing and re-opening")
msg := "Continuous integration appears to have missed, closing and re-opening to trigger it"
if _, _, err := client.Issues.CreateComment(opts.Org, opts.Project, *pr.Number, &github.IssueComment{Body: &msg}); err != nil {
glog.Errorf("failed to create comment: %v", err)
}
state := "closed"
pr.State = &state
if _, _, err := client.PullRequests.Edit(opts.Org, opts.Project, *pr.Number, pr); err != nil {
glog.Errorf("Failed to close pr %d: %v", *pr.Number, err)
return
}
time.Sleep(5 * time.Second)
state = "open"
pr.State = &state
// Try pretty hard to re-open, since it's pretty bad if we accidentally leave a PR closed
for tries := 0; tries < 10; tries++ {
if _, _, err := client.PullRequests.Edit(opts.Org, opts.Project, *pr.Number, pr); err == nil {
break
} else {
glog.Errorf("failed to re-open pr %d: %v", *pr.Number, err)
}
time.Sleep(5 * time.Second)
}
}
}
开发者ID:tobad357,项目名称:contrib,代码行数:43,代码来源:ping_ci.go
示例2: ClosePR
func (config *GithubConfig) ClosePR(pr *github.PullRequest) error {
if config.DryRun {
glog.Infof("Would have closed PR# %d but --dry-run was set", *pr.Number)
return nil
}
state := "closed"
pr.State = &state
if _, _, err := config.client.PullRequests.Edit(config.Org, config.Project, *pr.Number, pr); err != nil {
glog.Errorf("Failed to close pr %d: %v", *pr.Number, err)
return err
}
return nil
}
开发者ID:sigma,项目名称:kubernetes-contrib,代码行数:13,代码来源:github.go
示例3: OpenPR
// OpenPR will attempt to open the given PR.
func (config *GithubConfig) OpenPR(pr *github.PullRequest, numTries int) error {
if config.DryRun {
glog.Infof("Would have openned PR# %d but --dry-run was set", *pr.Number)
return nil
}
var err error
state := "open"
pr.State = &state
// Try pretty hard to re-open, since it's pretty bad if we accidentally leave a PR closed
for tries := 0; tries < numTries; tries++ {
if _, _, err = config.client.PullRequests.Edit(config.Org, config.Project, *pr.Number, pr); err == nil {
return nil
}
glog.Warningf("failed to re-open pr %d: %v", *pr.Number, err)
time.Sleep(5 * time.Second)
}
if err != nil {
glog.Errorf("failed to re-open pr %d after %d tries, giving up: %v", *pr.Number, numTries, err)
}
return err
}
开发者ID:sigma,项目名称:kubernetes-contrib,代码行数:22,代码来源:github.go
示例4: closePullRequest
func (p *PullRequestCloser) closePullRequest(owner string, repo string, pull github.PullRequest, comment string, label string) error {
issueComment := &github.IssueComment{Body: github.String(comment)}
_, _, err := p.client.Issues.CreateComment(owner, repo, *pull.Number, issueComment)
if err != nil {
return err
}
if label != "" {
_, _, err = p.client.Issues.AddLabelsToIssue(owner, repo, *pull.Number, []string{label})
if err != nil {
return err
}
}
pull.State = github.String("closed")
_, _, err = p.client.PullRequests.Edit(owner, repo, *pull.Number, &pull)
if err != nil {
return err
}
return nil
}
开发者ID:fstehle,项目名称:pull-request-closer,代码行数:23,代码来源:main.go
注:本文中的github.com/google/go-github/github.PullRequest类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论