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

Golang gordon.Fatalf函数代码示例

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

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



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

示例1: authCmd

func authCmd(c *cli.Context) {
	config, err := gordon.LoadConfig()
	if err != nil {
		config = &gordon.Config{}
	}
	token := c.String("add")
	userName := c.String("user")
	if userName != "" {
		config.UserName = userName
		if err := gordon.SaveConfig(*config); err != nil {
			gordon.Fatalf("%s", err)
		}
	}
	if token != "" {
		config.Token = token
		if err := gordon.SaveConfig(*config); err != nil {
			gordon.Fatalf("%s", err)
		}
	}
	// Display token and user information
	if config, err := gordon.LoadConfig(); err == nil {
		if config.UserName != "" {
			fmt.Printf("Token: %s, UserName: %s\n", config.Token, config.UserName)
		} else {

			fmt.Printf("Token: %s\n", config.Token)
		}
	} else {
		fmt.Fprintf(os.Stderr, "No token registered\n")
		os.Exit(1)
	}
}
开发者ID:rm3l,项目名称:gordon,代码行数:32,代码来源:main.go


示例2: displayAllPullRequests

func displayAllPullRequests(c *cli.Context) {
	prs, err := m.GetPullRequests(c.String("state"), c.String("sort"))
	if err != nil {
		gordon.Fatalf("Error getting pull requests %s", err)
	}

	var needFullPr, needComments bool

	if c.Bool("no-merge") {
		needFullPr = true
	}
	if c.Bool("lgtm") {
		needComments = true
	}

	if needFullPr || needComments {
		prs = m.GetFullPullRequests(prs, needFullPr, needComments)
	}

	prs, err = filters.FilterPullRequests(c, prs)
	if err != nil {
		gordon.Fatalf("Error filtering pull requests %s", err)
	}

	fmt.Printf("%c[2K\r", 27)
	gordon.DisplayPullRequests(c, prs, c.Bool("no-trunc"))
}
开发者ID:rm3l,项目名称:gordon,代码行数:27,代码来源:main.go


示例3: takeCmd

//Assign a pull request to the current user.
// If it's taken, show a message with the "--steal" optional flag.
//If the user doesn't have permissions, add a comment #volunteer
func takeCmd(c *cli.Context) {
	if !c.Args().Present() {
		gordon.Fatalf("usage: take ID")
	}
	number := c.Args()[0]
	pr, err := m.GetPullRequest(number)
	if err != nil {
		gordon.Fatalf("%s", err)
	}
	user, err := m.GetGithubUser()
	if err != nil {
		gordon.Fatalf("%s", err)
	}
	if pr.Assignee != nil && !c.Bool("steal") {
		gordon.Fatalf("Use --steal to steal the PR from %s", pr.Assignee.Login)
	}
	pr.Assignee = user
	patchedPR, err := m.PatchPullRequest(number, pr)
	if err != nil {
		gordon.Fatalf("%s", err)
	}
	if patchedPR.Assignee.Login != user.Login {
		m.AddComment(number, "#volunteer")
		fmt.Printf("No permission to assign. You '%s' was added as #volunteer.\n", user.Login)
	} else {
		m.AddComment(number, fmt.Sprintf("#assignee=%s", patchedPR.Assignee.Login))
		fmt.Printf("Assigned PR %s to %s\n", brush.Green(number), patchedPR.Assignee.Login)
	}
}
开发者ID:rm3l,项目名称:gordon,代码行数:32,代码来源:main.go


示例4: takeCmd

//Take a specific issue. If it's taken, show a message with the overwrite optional flag
//If the user doesn't have permissions, add a comment #volunteer
func takeCmd(c *cli.Context) {
	if c.Args().Present() {
		number := c.Args()[0]
		issue, _, err := m.GetIssue(number, false)
		if err != nil {
			gordon.Fatalf("%s", err)
		}
		user, err := m.GetGithubUser()
		if err != nil {
			gordon.Fatalf("%s", err)
		}
		if user == nil {
			gordon.Fatalf("%v", gordon.ErrNoUsernameKnown)
		}
		if issue.Assignee.Login != "" && !c.Bool("overwrite") {
			fmt.Printf("Use the flag --overwrite to take the issue from %s\n", issue.Assignee.Login)
			return
		}
		issue.Assignee = *user
		patchedIssue, err := m.PatchIssue(number, issue)
		if err != nil {
			gordon.Fatalf("%s", err)
		}
		if patchedIssue.Assignee.Login != user.Login {
			m.AddComment(number, "#volunteer")
			fmt.Printf("No permission to assign. You '%s' was added as #volunteer.\n", user.Login)
		} else {
			fmt.Printf("The issue %s was assigned to %s\n", number, patchedIssue.Assignee.Login)
		}
	} else {
		fmt.Printf("Please enter the issue's number\n")
	}

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


示例5: commentCmd

func commentCmd(c *cli.Context) {
	if !c.Args().Present() {
		gordon.Fatalf("Please enter the issue's number")
	}
	number := c.Args()[0]
	editor := os.Getenv("EDITOR")
	if editor == "" {
		editor = "nano"
	}
	tmp, err := ioutil.TempFile("", "pulls-comment-")
	if err != nil {
		gordon.Fatalf("%s", err)
	}
	defer os.Remove(tmp.Name())
	cmd := exec.Command(editor, tmp.Name())
	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	if err := cmd.Run(); err != nil {
		gordon.Fatalf("%v", err)
	}
	comment, err := ioutil.ReadAll(tmp)
	if err != nil {
		gordon.Fatalf("%v", err)
	}
	if _, err := m.AddComment(number, string(comment)); err != nil {
		gordon.Fatalf("%v", err)
	}
}
开发者ID:rm3l,项目名称:gordon,代码行数:29,代码来源:main.go


示例6: compareCmd

// compareCmd searches to find Merge commits that are in master that are not in the branch
func compareCmd(c *cli.Context) {

	// TODO: don't repase all history to the begining of time (--after?)

	if nArgs := len(c.Args()); nArgs == 2 {
		// git log --format=oneline upstream/master > master.log
		masterLog, err := git("log", "--format=format:%H %s %b", c.Args()[0])
		if err != nil {
			gordon.Fatalf("%v", err)
		}

		// git log --format=oneline upstream/docs > docs.log
		branchLog, err := git("log", "--format=format:%H %s %b", c.Args()[1])
		if err != nil {
			gordon.Fatalf("%v", err)
		}

		// diff -U 0 master.log docs.log  | grep "Merge pull" | sed "s/^-/- /g"
		// Parse both logs looking for 'Merge pull request #`
		reMergeLine := regexp.MustCompile(`^([0-9a-f]{40}) Merge pull request #([0-9]*) from (.*)$`)
		branchPRs := make(map[string]string)
		s := bufio.NewScanner(strings.NewReader(branchLog))
		for s.Scan() {
			res := reMergeLine.FindStringSubmatch(s.Text())
			if res == nil {
				continue
			}
			hash := res[1]
			pr := res[2]
			//desc := res[3]
			branchPRs[pr] = hash
		}

		firstMerged := ""
		s = bufio.NewScanner(strings.NewReader(masterLog))
		for s.Scan() {
			res := reMergeLine.FindStringSubmatch(s.Text())
			if res == nil {
				continue
			}
			hash := res[1]
			pr := res[2]
			desc := res[3]

			if branchPRs[pr] == "" {
				// TODO: consider reversing the order of this list to match the commit list in the GH PR
				fmt.Printf("- %s #%s : %s\n", hash, pr, desc)
			} else if firstMerged == "" {
				firstMerged = pr
				fmt.Println("------- ^^^^ un-considered candidates")
			}
		}
	} else {
		gordon.Fatalf("Usage: compare [branch] [branch]")
	}
}
开发者ID:askb,项目名称:gordon,代码行数:57,代码来源:main.go


示例7: approveCmd

// Approve a pr by adding a LGTM to the comments
func approveCmd(c *cli.Context) {
	if !c.Args().Present() {
		gordon.Fatalf("usage: approve ID")
	}
	number := c.Args().First()
	if _, err := m.AddComment(number, "LGTM"); err != nil {
		gordon.Fatalf("%s", err)
	}
	fmt.Printf("Pull request %s approved\n", brush.Green(number))
}
开发者ID:rm3l,项目名称:gordon,代码行数:11,代码来源:main.go


示例8: closeCmd

func closeCmd(c *cli.Context) {
	if !c.Args().Present() {
		gordon.Fatalf("Please enter the issue's number")
	}
	number := c.Args()[0]
	if err := m.Close(number); err != nil {
		gordon.Fatalf("%v", err)
	}
	fmt.Printf("Closed PR %s\n", number)
}
开发者ID:rm3l,项目名称:gordon,代码行数:10,代码来源:main.go


示例9: commentsCmd

func commentsCmd(c *cli.Context) {
	if !c.Args().Present() {
		gordon.Fatalf("usage: comments ID")
	}
	comments, err := m.GetComments(c.Args().First())
	if err != nil {
		gordon.Fatalf("%s", err)
	}
	gordon.DisplayComments(comments)
}
开发者ID:rm3l,项目名称:gordon,代码行数:10,代码来源:main.go


示例10: checkoutCmd

func checkoutCmd(c *cli.Context) {
	if !c.Args().Present() {
		gordon.Fatalf("usage: checkout ID")
	}
	number := c.Args()[0]
	pr, err := m.GetPullRequest(number)
	if err != nil {
		gordon.Fatalf("%s", err)
	}
	if err := m.Checkout(pr); err != nil {
		gordon.Fatalf("%s", err)
	}
}
开发者ID:rm3l,项目名称:gordon,代码行数:13,代码来源:main.go


示例11: mergeCmd

func mergeCmd(c *cli.Context) {
	if !c.Args().Present() {
		gordon.Fatalf("usage: merge ID")
	}
	number := c.Args()[0]
	merge, err := m.MergePullRequest(number, c.String("m"), c.Bool("force"))
	if err != nil {
		gordon.Fatalf("%s", err)
	}
	if merge.Merged {
		fmt.Printf("%s\n", brush.Green(merge.Message))
	} else {
		gordon.Fatalf("%s", err)
	}
}
开发者ID:rm3l,项目名称:gordon,代码行数:15,代码来源:main.go


示例12: repositoryInfoCmd

func repositoryInfoCmd(c *cli.Context) {
	r, err := m.Repository()
	if err != nil {
		gordon.Fatalf("%s", err)
	}
	fmt.Printf("Name: %s\nForks: %d\nStars: %d\nIssues: %d\n", r.Name, r.Forks, r.Watchers, r.OpenIssues)
}
开发者ID:rm3l,项目名称:gordon,代码行数:7,代码来源:main.go


示例13: buildQuery

func buildQuery(c *cli.Context) string {
	r, err := m.Repository()
	if err != nil {
		gordon.Fatalf("%s", err)
	}
	// standard parameters
	query := fmt.Sprintf("q=%s+repo:%s", c.Args()[0], r.FullName)
	state := c.String("state")
	if state == "" {
		state = "open"
	}
	query += fmt.Sprintf("+state:%s", state)
	// optional parameters
	var optionalParameters = []string{
		"author",
		"assignee",
		"mentions",
		"commenter",
		"involves",
		"labels"}

	for i := 0; i < len(optionalParameters); i++ {
		param := optionalParameters[i]
		value := c.String(param)
		if value != "" {
			query += fmt.Sprintf("+%s:%s", param, value)
		}
	}
	return query
}
开发者ID:askb,项目名称:gordon,代码行数:30,代码来源:main.go


示例14: addComment

func addComment(number, comment string) {
	cmt, err := m.AddComment(number, comment)
	if err != nil {
		gordon.Fatalf("%s", err)
	}
	gordon.DisplayCommentAdded(cmt)
}
开发者ID:rm3l,项目名称:gordon,代码行数:7,代码来源:main.go


示例15: contributorsCmd

// Show contributors stats
func contributorsCmd(c *cli.Context) {
	contributors, err := m.GetContributors()
	if err != nil {
		gordon.Fatalf("%s", err)
	}
	gordon.DisplayContributors(c, contributors)
}
开发者ID:rm3l,项目名称:gordon,代码行数:8,代码来源:main.go


示例16: alruCmd

func alruCmd(c *cli.Context) {
	lru, err := m.GetFirstPullRequest("open", "updated")
	if err != nil {
		gordon.Fatalf("Error getting pull requests: %s", err)
	}
	fmt.Printf("%v (#%d)\n", gordon.HumanDuration(time.Since(lru.UpdatedAt)), lru.Number)
}
开发者ID:rm3l,项目名称:gordon,代码行数:7,代码来源:main.go


示例17: commentCmd

func commentCmd(c *cli.Context) {
	if !c.Args().Present() {
		gordon.Fatalf("Please enter the issue's number")
	}
	number := c.Args()[0]
	editor := os.Getenv("EDITOR")
	if editor == "" {
		editor = "nano"
	}
	tmp, err := ioutil.TempFile("", "pulls-comment-")
	if err != nil {
		gordon.Fatalf("%v", err)
	}
	defer os.Remove(tmp.Name())

	if template := c.String("template"); template != "" {
		f, err := os.Open(template)

		if err != nil {
			path := filepath.Join(templatePath, filepath.Base(c.String("template")))

			f, err = os.Open(path)
			if err != nil {
				gordon.Fatalf("%v", err)
			}
		}

		defer f.Close()

		if _, err := io.Copy(tmp, f); err != nil {
			gordon.Fatalf("%v", err)
		}
	}

	cmd := exec.Command(editor, tmp.Name())
	cmd.Stdin = os.Stdin
	cmd.Stdout = os.Stdout
	cmd.Stderr = os.Stderr
	if err := cmd.Run(); err != nil {
		gordon.Fatalf("%v", err)
	}

	if _, err := tmp.Seek(0, 0); err != nil {
		gordon.Fatalf("%v", err)
	}

	comment, err := ioutil.ReadAll(tmp)
	if err != nil {
		gordon.Fatalf("%v", err)
	}

	if _, err := m.AddComment(number, string(comment)); err != nil {
		gordon.Fatalf("%v", err)
	}
}
开发者ID:askb,项目名称:gordon,代码行数:55,代码来源:main.go


示例18: showCmd

// Show the patch in a PR
func showCmd(c *cli.Context) {
	if !c.Args().Present() {
		gordon.Fatalf("usage: show ID")
	}
	number := c.Args()[0]
	pr, err := m.GetPullRequest(number)
	if err != nil {
		gordon.Fatalf("%s", err)
	}
	patch, err := http.Get(pr.DiffURL)
	if err != nil {
		gordon.Fatalf("%s", err)
	}
	defer patch.Body.Close()

	if err := gordon.DisplayPatch(patch.Body); err != nil {
		gordon.Fatalf("%s", err)
	}
}
开发者ID:rm3l,项目名称:gordon,代码行数:20,代码来源:main.go


示例19: sendCmd

func sendCmd(c *cli.Context) {
	if nArgs := len(c.Args()); nArgs == 0 {
		// Push the branch, then create the PR
		// Pick a remote branch name
		commitMsg, err := exec.Command("git", "log", "--no-merges", "-1", "--pretty=format:%s", "HEAD").CombinedOutput()
		if err != nil {
			gordon.Fatalf("git log: %v", err)
		}
		brName := "pr_out_" + gordon.GenBranchName(string(commitMsg))
		fmt.Printf("remote branch = %s\n", brName)
		user, err := m.GetGithubUser()
		if err != nil {
			gordon.Fatalf("%v", err)
		}
		if user == nil {
			gordon.Fatalf("%v", gordon.ErrNoUsernameKnown)
		}

		repo, err := m.Repository()
		if err != nil {
			gordon.Fatalf("%v\n", err)
		}
		// FIXME: use the github API to get our fork's url (or create the fork if needed)
		if err := gordon.Git("push", "-f", fmt.Sprintf("ssh://[email protected]/%s/%s", user.Login, repo.Name), "HEAD:refs/heads/"+brName); err != nil {
			gordon.Fatalf("git push: %v", err)
		}
		prBase := "master"
		prHead := fmt.Sprintf("%s:%s", user.Login, brName)
		fmt.Printf("Creating pull request from %s to %s\n", prBase, prHead)
		pr, err := m.CreatePullRequest(prBase, prHead, string(commitMsg), "")
		if err != nil {
			gordon.Fatalf("create pull request: %v", err)
		}
		fmt.Printf("Created %v\n", pr.Number)
	} else if nArgs == 1 {
		pr, err := m.GetPullRequest(c.Args()[0])
		if err != nil {
			gordon.Fatalf("%v", err)
		}
		if err := gordon.Git("push", "-f", pr.Head.Repo.SSHURL, "HEAD:"+pr.Head.Ref); err != nil {
			gordon.Fatalf("%v", err)
		}
		fmt.Printf("Overwrote %v\n", pr.Number)
	} else {
		gordon.Fatalf("Usage: send [ID]")
	}
}
开发者ID:askb,项目名称:gordon,代码行数:47,代码来源:main.go


示例20: dropCmd

func dropCmd(c *cli.Context) {
	if !c.Args().Present() {
		gordon.Fatalf("usage: drop ID")
	}
	number := c.Args()[0]
	pr, err := m.GetPullRequest(number)
	if err != nil {
		gordon.Fatalf("%s", err)
	}
	user, err := m.GetGithubUser()
	if err != nil {
		gordon.Fatalf("%s", err)
	}
	if user == nil {
		gordon.Fatalf("%v", gordon.ErrNoUsernameKnown)
	}
	if pr.Assignee == nil || pr.Assignee.Login != user.Login {
		gordon.Fatalf("Can't drop %s: it's not yours.", number)
	}
	pr.Assignee = nil
	if _, err := m.PatchPullRequest(number, pr); err != nil {
		gordon.Fatalf("%s", err)
	}
	fmt.Printf("Unassigned PR %s\n", brush.Green(number))
}
开发者ID:askb,项目名称:gordon,代码行数:25,代码来源:main.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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