• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang github.PullRequest类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang github.RepoStatus类代码示例发布时间:2022-05-23
下一篇:
Golang github.ListOptions类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap