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

Golang octokat.NewClient函数代码示例

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

本文整理汇总了Golang中github.com/crosbymichael/octokat.NewClient函数的典型用法代码示例。如果您正苦于以下问题:Golang NewClient函数的具体用法?Golang NewClient怎么用?Golang NewClient使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了NewClient函数的17个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: setup

func setup() {
	mux = http.NewServeMux()
	server = httptest.NewServer(mux)

	client = octokat.NewClient()
	client.BaseURL = server.URL
}
开发者ID:pombredanne,项目名称:gh-patch-parser,代码行数:7,代码来源:format_test.go


示例2: main

func main() {

	app := cli.NewApp()

	app.Name = "pulls"
	app.Usage = "Manage github pull requests for project maintainers"
	app.Version = "0.0.1"

	client := gh.NewClient()

	org, name, err := gordon.GetOriginUrl()
	if err != nil {
		fmt.Fprintf(os.Stderr, "The current directory is not a valid git repository.\n")
		os.Exit(1)
	}
	t, err := gordon.NewMaintainerManager(client, org, name)
	if err != nil {
		gordon.WriteError("%s", err)
	}
	m = t

	loadCommands(app)

	app.Run(os.Args)
}
开发者ID:rogaha,项目名称:gordon,代码行数:25,代码来源:main.go


示例3: voteIssuesFilter

func voteIssuesFilter(issues []*gh.Issue, numVotes int, err error) ([]*gh.Issue, error) {
	if err != nil {
		return nil, err
	}

	out := []*gh.Issue{}
	for _, issue := range issues {
		fmt.Printf(".")
		client := gh.NewClient()
		org, name, err := gordon.GetOriginUrl()
		if err != nil {
			panic(err)
		}
		t, err := gordon.NewMaintainerManager(client, org, name)
		if err != nil {
			panic(err)
		}
		comments, err := t.GetComments(strconv.Itoa(issue.Number))
		if err != nil {
			return nil, err
		}
		issue.Comments = 0
		for _, comment := range comments {
			if strings.Contains(comment.Body, "+1") {
				issue.Comments += 1
			}
		}
		if issue.Comments >= numVotes {
			out = append(out, issue)
		}
	}
	return out, nil
}
开发者ID:rogaha,项目名称:gordon,代码行数:33,代码来源:filters.go


示例4: noMergePullRequestsFilter

func noMergePullRequestsFilter(prs []*gh.PullRequest, err error) ([]*gh.PullRequest, error) {
	if err != nil {
		return nil, err
	}

	out := []*gh.PullRequest{}
	for _, pr := range prs {
		fmt.Printf(".")
		// We have to fetch the single pr to get the merge state
		// it sucks but we have to do it
		client := gh.NewClient()
		org, name, err := gordon.GetOriginUrl()
		if err != nil {
			panic(err)
		}
		t, err := gordon.NewMaintainerManager(client, org, name)
		if err != nil {
			panic(err)
		}
		pr, _, err := t.GetPullRequest(strconv.Itoa(pr.Number), false)
		if err != nil {
			return nil, err
		}
		if !pr.Mergeable {
			out = append(out, pr)
		}
	}
	return out, nil
}
开发者ID:rogaha,项目名称:gordon,代码行数:29,代码来源:filters.go


示例5: updateGithubStatus

func (c Config) updateGithubStatus(repoName, context, sha, state, desc, buildURL string) error {
	// parse git repo for username
	// and repo name
	r := strings.SplitN(repoName, "/", 2)
	if len(r) < 2 {
		return fmt.Errorf("repo name could not be parsed: %s", repoName)
	}

	// initialize github client
	gh := octokat.NewClient()
	gh = gh.WithToken(c.GHToken)
	repo := octokat.Repo{
		Name:     r[1],
		UserName: r[0],
	}

	status := &octokat.StatusOptions{
		State:       state,
		Description: desc,
		URL:         buildURL,
		Context:     context,
	}
	if _, err := gh.SetStatus(repo, sha, status); err != nil {
		return fmt.Errorf("setting status for repo: %s, sha: %s failed: %v", repoName, sha, err)
	}

	logrus.Infof("Setting status on %s %s to %s for %s succeeded", repoName, sha, state, context)
	return nil
}
开发者ID:KrunoKnego,项目名称:leeroy,代码行数:29,代码来源:utils.go


示例6: lgtmPullRequestsFilter

func lgtmPullRequestsFilter(prs []*gh.PullRequest, err error) ([]*gh.PullRequest, error) {
	if err != nil {
		return nil, err
	}

	for _, pr := range prs {
		fmt.Printf(".")
		client := gh.NewClient()
		org, name, err := gordon.GetOriginUrl()
		if err != nil {
			panic(err)
		}
		t, err := gordon.NewMaintainerManager(client, org, name)
		if err != nil {
			panic(err)
		}
		comments, err := t.GetComments(strconv.Itoa(pr.Number))
		if err != nil {
			return nil, err
		}
		pr.ReviewComments = 0
		maintainersOccurrence := map[string]bool{}
		for _, comment := range comments {
			// We should check it this LGTM is by a user in
			// the maintainers file
			userName := comment.User.Login
			if strings.Contains(comment.Body, "LGTM") && t.IsMaintainer(userName) && !maintainersOccurrence[userName] {
				maintainersOccurrence[userName] = true
				pr.ReviewComments += 1
			}
		}
	}
	return prs, nil
}
开发者ID:rogaha,项目名称:gordon,代码行数:34,代码来源:filters.go


示例7: getFailedPRs

func (c Config) getFailedPRs(context, repoName string) (nums []int, err error) {
	// parse git repo for username
	// and repo name
	r := strings.SplitN(repoName, "/", 2)
	if len(r) < 2 {
		return nums, fmt.Errorf("repo name could not be parsed: %s", repoName)
	}

	// initialize github client
	gh := octokat.NewClient()
	gh = gh.WithToken(c.GHToken)
	repo := octokat.Repo{
		Name:     r[1],
		UserName: r[0],
	}

	// get pull requests
	prs, err := gh.PullRequests(repo, &octokat.Options{
		Params: map[string]string{
			"state":    "open",
			"per_page": "100",
		},
	})
	if err != nil {
		return nums, fmt.Errorf("requesting open repos for %s failed: %v", repoName, err)
	}

	for _, pr := range prs {
		if !hasStatus(gh, repo, pr.Head.Sha, context) {
			nums = append(nums, pr.Number)
		}
	}

	return nums, nil
}
开发者ID:KrunoKnego,项目名称:leeroy,代码行数:35,代码来源:utils.go


示例8: getShas

func (c Config) getShas(owner, name, context string, number int) (shas []string, pr *octokat.PullRequest, err error) {
	// initialize github client
	gh := octokat.NewClient()
	gh = gh.WithToken(c.GHToken)
	repo := octokat.Repo{
		Name:     name,
		UserName: owner,
	}

	// get the pull request so we can get the commits
	pr, err = gh.PullRequest(repo, strconv.Itoa(number), &octokat.Options{})
	if err != nil {
		return shas, pr, fmt.Errorf("getting pull request %d for %s/%s failed: %v", number, owner, name, err)
	}

	// check which commits we want to get
	// from the original flag --build-commits
	if c.BuildCommits == "all" || c.BuildCommits == "new" {

		// get the commits url
		req, err := http.Get(pr.CommitsURL)
		if err != nil {
			return shas, pr, err
		}
		defer req.Body.Close()

		// parse the response
		var commits []Commit
		decoder := json.NewDecoder(req.Body)
		if err := decoder.Decode(&commits); err != nil {
			return shas, pr, fmt.Errorf("parsing the response from %s failed: %v", pr.CommitsURL, err)
		}

		// append the commit shas
		for _, commit := range commits {
			// if we only want the new shas
			// check to make sure the status
			// has not been set before appending
			if c.BuildCommits == "new" {
				if hasStatus(gh, repo, commit.Sha, context) {
					continue
				}
			}

			shas = append(shas, commit.Sha)
		}
	} else {
		// this is the case where buildCommits == "last"
		// just get the sha of the pr
		shas = append(shas, pr.Head.Sha)
	}

	return shas, pr, nil
}
开发者ID:KrunoKnego,项目名称:leeroy,代码行数:54,代码来源:utils.go


示例9: FilterIssues

func FilterIssues(c *cli.Context, issues []*gh.Issue) ([]*gh.Issue, error) {
	var (
		yesterday      = time.Now().Add(-24 * time.Hour)
		out            = []*gh.Issue{}
		client         = gh.NewClient()
		org, name, err = gordon.GetRemoteUrl(c.String("remote"))
	)
	if err != nil {
		return nil, err
	}
	t, err := gordon.NewMaintainerManager(client, org, name)
	if err != nil {
		return nil, err
	}

	for _, issue := range issues {
		fmt.Printf(".")

		if c.Bool("new") && !issue.CreatedAt.After(yesterday) {
			continue
		}

		if milestone := c.String("milestone"); milestone != "" && issue.Milestone.Title != milestone {
			continue
		}

		if numVotes := c.Int("votes"); numVotes > 0 {
			comments, err := t.GetComments(strconv.Itoa(issue.Number))
			if err != nil {
				return nil, err
			}
			issue.Comments = 0
			for _, comment := range comments {
				if strings.Contains(comment.Body, "+1") {
					issue.Comments += 1
				}
			}
			if issue.Comments < numVotes {
				continue
			}
		}

		if c.Bool("proposals") && !strings.HasPrefix(issue.Title, "Proposal") {
			continue
		}

		out = append(out, issue)
	}
	return out, nil

}
开发者ID:askb,项目名称:gordon,代码行数:51,代码来源:filters.go


示例10: before

func before(c *cli.Context) error {
	client := gh.NewClient()

	org, name, err := gordon.GetRemoteUrl(c.String("remote"))
	if err != nil {
		return fmt.Errorf("The current directory is not a valid git repository (%s).\n", err)
	}
	t, err := gordon.NewMaintainerManager(client, org, name)
	if err != nil {
		return err
	}
	m = t
	return nil
}
开发者ID:pombredanne,项目名称:pulls,代码行数:14,代码来源:main.go


示例11: Client

// Client initializes the authorization with the GitHub API
func (g GitHub) Client() *octokat.Client {
	var cache httpcache.Cache
	if cachePath := os.Getenv("GITHUB_CACHE_PATH"); cachePath != "" {
		cache = diskcache.New(cachePath)
	} else {
		cache = httpcache.NewMemoryCache()
	}
	tr := httpcache.NewTransport(cache)

	c := &http.Client{Transport: tr}

	gh := octokat.NewClient()
	gh = gh.WithToken(g.AuthToken)
	gh = gh.WithHTTPClient(c)
	return gh
}
开发者ID:vdemeester,项目名称:leeroy,代码行数:17,代码来源:github.go


示例12: before

func before(c *cli.Context) error {
	client := gh.NewClient()

	// set up the git remote to be used
	org, name, err := gordon.GetRemoteUrl(c.String("remote"))
	if err != nil {
		return fmt.Errorf("The current directory is not a valid git repository (%s).\n", err)
	}
	t, err := gordon.NewMaintainerManager(client, org, name)
	if err != nil {
		return err
	}
	m = t

	// Set verbosity
	gordon.VerboseOutput = c.Bool("verbose")

	return nil
}
开发者ID:askb,项目名称:gordon,代码行数:19,代码来源:main.go


示例13: main

func main() {
	// set log level
	if debug {
		logrus.SetLevel(logrus.DebugLevel)
	}

	if version {
		fmt.Println(VERSION)
		return
	}

	// set up github token auth
	gh := octokat.NewClient()
	gh = gh.WithToken(ghtoken)

	// process the queue
	if err := ProcessQueue(&Handler{gh}, QueueOptsFromContext(topic, channel, lookupd)); err != nil {
		logrus.Fatal(err)
	}
}
开发者ID:pombredanne,项目名称:gh-patch-parser,代码行数:20,代码来源:main.go


示例14: main

func main() {
	app := cli.NewApp()

	app.Name = "issues"
	app.Usage = "Manage github issues"
	app.Version = "0.0.1"

	client := gh.NewClient()

	org, name, err := pulls.GetOriginUrl()
	if err != nil {
		panic(err)
	}
	t, err := pulls.NewMaintainer(client, org, name)
	if err != nil {
		panic(err)
	}
	m = t

	loadCommands(app)

	app.Run(os.Args)
}
开发者ID:jamtur01,项目名称:pulls,代码行数:23,代码来源:main.go


示例15: addGithubComment

func (c Config) addGithubComment(repoName, pr, comment string) error {
	// parse git repo for username
	// and repo name
	r := strings.SplitN(repoName, "/", 2)
	if len(r) < 2 {
		return fmt.Errorf("repo name could not be parsed: %s", repoName)
	}

	// initialize github client
	gh := octokat.NewClient()
	gh = gh.WithToken(c.GHToken)
	repo := octokat.Repo{
		Name:     r[1],
		UserName: r[0],
	}

	// add comment to the PR
	if _, err := gh.AddComment(repo, pr, comment); err != nil {
		return fmt.Errorf("adding comment to %s#%s failed: %v", repoName, pr, err)
	}

	return nil
}
开发者ID:vdemeester,项目名称:leeroy,代码行数:23,代码来源:utils.go


示例16: Client

// Client initializes the authorization with the GitHub API
func (g GitHub) Client() *octokat.Client {
	gh := octokat.NewClient()
	gh = gh.WithToken(g.AuthToken)
	return gh
}
开发者ID:KrunoKnego,项目名称:leeroy,代码行数:6,代码来源:github.go


示例17: newHandler

func newHandler(ghToken string) *Handler {
	gh := octokat.NewClient()
	gh = gh.WithToken(ghToken)

	return &Handler{gh}
}
开发者ID:mnowster,项目名称:gh-patch-parser,代码行数:6,代码来源:main.go



注:本文中的github.com/crosbymichael/octokat.NewClient函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang octokat.Client类代码示例发布时间:2022-05-23
下一篇:
Golang log.Logf函数代码示例发布时间: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