示例#1
0
文件: main.go 项目: pombredanne/pulls
// 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)
	}
}
示例#2
0
文件: main.go 项目: rogaha/gordon
// Show the patch in a PR
func showCmd(c *cli.Context) {
	if !c.Args().Present() {
		fmt.Println("Please enter a pull request number")
		return
	}
	number := c.Args()[0]
	pr, _, err := m.GetPullRequest(number, false)
	if err != nil {
		gordon.WriteError("%s", err)
	}
	patch, err := http.Get(pr.DiffURL)
	if err != nil {
		gordon.WriteError("%s", err)
	}
	defer patch.Body.Close()

	if err := gordon.DisplayPatch(patch.Body); err != nil {
		gordon.WriteError("%s", err)
	}
}