Exemplo n.º 1
0
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
}
Exemplo n.º 2
0
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
}
Exemplo n.º 3
0
Arquivo: main.go Projeto: 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
}
Exemplo n.º 4
0
Arquivo: main.go Projeto: 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
}
Exemplo n.º 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
}