예제 #1
0
파일: hook_schema.go 프로젝트: soh335/ghh
func GetHookSchemas(c *github.Client) ([]HookSchema, *github.Response, error) {
	req, err := c.NewRequest("GET", "hooks", nil)
	if err != nil {
		return nil, nil, err
	}
	hookSchemas := new([]HookSchema)
	resp, err := c.Do(req, hookSchemas)
	if err != nil {
		return nil, resp, err
	}

	return *hookSchemas, resp, err
}
예제 #2
0
파일: hook_schema.go 프로젝트: soh335/ghh
func GetHookSchema(c *github.Client, name string) (*HookSchema, *github.Response, error) {
	req, err := c.NewRequest("GET", fmt.Sprintf("hooks/%v", name), nil)
	if err != nil {
		return nil, nil, err
	}
	hookSchema := new(HookSchema)
	resp, err := c.Do(req, hookSchema)
	if err != nil {
		return nil, resp, err
	}

	return hookSchema, resp, err
}
예제 #3
0
파일: main.go 프로젝트: astronoka/gh
func GitCommitStatuses(client *github.Client, owner, repo, sha string) (interface{}, *github.Response, error) {

	u := fmt.Sprintf("repos/%v/%v/commits/%v/statuses", owner, repo, sha)
	req, err := client.NewRequest("GET", u, nil)
	if err != nil {
		return nil, nil, err
	}

	var c interface{}
	resp, err := client.Do(req, &c)
	if err != nil {
		return nil, resp, err
	}
	return c, resp, err
}
예제 #4
0
파일: main.go 프로젝트: astronoka/gh
func PutGitCommitStatus(client *github.Client, owner, repo, sha string, body *CommitStatus) (interface{}, *github.Response, error) {

	u := fmt.Sprintf("repos/%v/%v/statuses/%v", owner, repo, sha)

	if body == nil {
		body = &CommitStatus{}
	}

	req, err := client.NewRequest("POST", u, body)
	if err != nil {
		return nil, nil, err
	}

	var c interface{}
	resp, err := client.Do(req, c)
	if err != nil {
		return nil, resp, err
	}

	return c, resp, err
}
예제 #5
0
func DownloadAsset(client *github.Client, asset *github.ReleaseAsset) error {
	req, _ := client.NewRequest("GET", *asset.URL, nil)
	req.Header.Set("Accept", "application/octet-stream")

	apiResponse, err := client.Do(req, nil)

	assetResponse, err := http.Get(apiResponse.Response.Request.URL.String())

	if err != nil {
		return err
	}

	f, err := os.Create(flags.Output)

	if err != nil {
		return err
	}

	defer f.Close()
	io.Copy(f, assetResponse.Body)

	return nil
}