Пример #1
0
// GetFile is a heper function that retrieves a file from
// GitHub and returns its contents in byte array format.
func GetFile(client *github.Client, owner, name, path, ref string) ([]byte, error) {
	var opts = new(github.RepositoryContentGetOptions)
	opts.Ref = ref
	content, _, _, err := client.Repositories.GetContents(owner, name, path, opts)
	if err != nil {
		return nil, err
	}
	return content.Decode()
}
Пример #2
0
// File fetches the file from the Bitbucket repository and returns its contents.
func (c *client) File(u *model.User, r *model.Repo, b *model.Build, f string) ([]byte, error) {
	client := c.newClientToken(u.Token)

	opts := new(github.RepositoryContentGetOptions)
	opts.Ref = b.Commit
	data, _, _, err := client.Repositories.GetContents(r.Owner, r.Name, f, opts)
	if err != nil {
		return nil, err
	}
	return data.Decode()
}