func (j *JobService) GetLog(ctx context.Context, id int64, include ...string) (*Log, error) {
	path := "/job/" + strconv.FormatInt(id, 10) + "/log"
	includes := strings.Join(include, ",")
	if includes != "" {
		path += "?include=" + includes
	}
	req, err := j.client.NewRequest("GET", path, nil)
	if err != nil {
		return nil, err
	}
	req = req.WithContext(ctx)
	build := new(Log)
	if err := j.client.Do(req, build); err != nil {
		return nil, err
	}
	return build, nil
}
GetLog retrieves the job log for the job with the given ID, or an error.
include is a list of resources to eager load.
package travis
import (
	"bufio"
	"context"
	"encoding/json"
	"fmt"
	"io"
	"io/ioutil"
	"net/http"
	"net/url"
	"os"
	"os/user"
	"path/filepath"
	"regexp"
	"strconv"
	"strings"
	"time"
	"github.com/BurntSushi/toml"
	git "github.com/kevinburke/go-git"
	types "github.com/kevinburke/go-types"
	"github.com/kevinburke/rest"
	"github.com/knq/ini"
	colorable "github.com/mattn/go-colorable"
	"golang.org/x/crypto/ssh/terminal"
	"golang.org/x/sync/errgroup"
)
func GetToken(organization string) (string, error) {
	var filename string
	var f io.ReadCloser
	var err error
	checkedLocations := make([]string, 1)
	if cfg, ok := os.LookupEnv("XDG_CONFIG_HOME"); ok {
		filename = filepath.Join(cfg, "travis")
		f, err = os.Open(filename)
		checkedLocations[0] = filename
	} else {
		var homeDir string
		user, userErr := user.Current()
		if userErr == nil {
			homeDir = user.HomeDir
		} else {
			homeDir = os.Getenv("HOME")
		}
		filename = filepath.Join(homeDir, "cfg", "travis")
		f, err = os.Open(filename)
		checkedLocations[0] = filename
		if err != nil {  
			rcFilename := filepath.Join(homeDir, ".travis")
			f, err = os.Open(rcFilename)
			checkedLocations = append(checkedLocations, rcFilename)
		}
	}
	if err != nil {
		err = fmt.Errorf(`Couldn't find a config file in %s.
Add a configuration file with your Travis token, like this:
[organizations]
    [organizations.kevinburke]
    token = "aabbccddeeff00"
Go to https://travis-ci.org/profile/<your-username> if you need to find your token.
`, strings.Join(checkedLocations, " or "))
		return "", err
	}
	defer f.Close()
	var c FileConfig
	_, err = toml.DecodeReader(bufio.NewReader(f), &c)
	if err != nil {
		return "", err
	}
	org, ok := getCaseInsensitiveOrg(organization, c.Organizations)
	if ok {
		return org.Token, nil
	}
	if c.Default != "" {
		defaultOrg, ok := getCaseInsensitiveOrg(c.Default, c.Organizations)
		if ok {
			return defaultOrg.Token, nil
		}
		return "", fmt.Errorf(`Couldn't find organization %s in the config.
Go to https: 
`, organization)
	}
	return "", fmt.Errorf(`Couldn't find organization %s in the config.
Set one of your organizations to be the default:
default = "kevinburke"
[organizations]
    [organizations.kevinburke]
    token = "abcdef-bcd-fgh"
Or go to https: 
`, organization)
}
const Version = "0.7"
const Host = "https://api.travis-ci.org"
const WebHost = "https://travis-ci.org"
type Client struct {
	*rest.Client
	token string
	Builds *BuildService
	Jobs *JobService
	Repos *RepoService
	Users *UserService
}
type travisError struct {
	Type         string `json:"@type"`
	ErrorType    string `json:"error_type"`
	ErrorMessage string `json:"error_message"`
	ResourceType string `json:"resource_type"`
	Permission   string `json:"permission"`
}
func parseError(r *http.Response) error {
	resBody, err := ioutil.ReadAll(r.Body)
	if err != nil {
		return err
	}
	defer r.Body.Close()
	terr := new(travisError)
	if err := json.Unmarshal(resBody, terr); err != nil {
		return fmt.Errorf("invalid response body: %s", string(resBody))
	}
	return &rest.Error{
		Title:  terr.ErrorMessage,
		ID:     terr.ErrorType,
		Status: r.StatusCode,
	}
}
func getHost() string {
	root, err := git.Root("")
	if err != nil {
		return ""
	}
	f, err := os.Open(filepath.Join(root, ".git", "config"))
	if err != nil {
		return ""
	}
	file, err := ini.Load(f)
	if err != nil {
		return ""
	}
	section := file.GetSection("travis")
	if section == nil {
		return ""
	}
	h := section.Get("host")
	if h == "" {
		return ""
	}
	if !strings.HasPrefix(h, "http") {
		h = "https://" + h
	}
	return h
}
func NewClient(token string) *Client {
	host := getHost()
	if host == "" {
		host = Host
	}
	rc := rest.NewClient("", "", host)
	rc.ErrorParser = parseError
	c := &Client{
		Client: rc,
		token:  token,
	}
	c.Builds = &BuildService{client: c}
	c.Jobs = &JobService{client: c}
	c.Repos = &RepoService{client: c}
	c.Users = &UserService{client: c}
	return c
}
type BuildService struct {
	client *Client
}
type JobService struct {
	client *Client
}
type RepoService struct {
	client *Client
}
type UserService struct {
	client *Client
}
func (u *UserService) Current(ctx context.Context) (*User, error) {
	path := "/user"
	req, err := u.client.NewRequest("GET", path, nil)
	if err != nil {
		return nil, err
	}
	req = req.WithContext(ctx)
	user := new(User)
	if err := u.client.Do(req, user); err != nil {
		return nil, err
	}
	return user, nil
}
func (u *UserService) Sync(ctx context.Context, id int64) error {
	path := "/user/" + strconv.FormatInt(id, 10) + "/sync"
	req, err := u.client.NewRequest("POST", path, nil)
	if err != nil {
		return err
	}
	req = req.WithContext(ctx)
	return u.client.Do(req, nil)
}
func (r *RepoService) Activate(ctx context.Context, slug string) error {
	path := "/repo/" + url.PathEscape(slug) + "/activate"
	req, err := r.client.NewRequest("POST", path, nil)
	if err != nil {
		return err
	}
	req = req.WithContext(ctx)
	return r.client.Do(req, nil)
}
func (r *RepoService) Deactivate(ctx context.Context, slug string) error {
	path := "/repo/" + url.PathEscape(slug) + "/deactivate"
	req, err := r.client.NewRequest("POST", path, nil)
	if err != nil {
		return err
	}
	req = req.WithContext(ctx)
	return r.client.Do(req, nil)
}
func (c *Client) fetchBuildLogs(ctx context.Context, b *Build) ([]*Log, error) {
	if len(b.Jobs) == 0 {
		return make([]*Log, 0), nil
	}
	logs := make([]*Log, len(b.Jobs))
	group, errctx := errgroup.WithContext(ctx)
	for i := range b.Jobs {
		i := i
		group.Go(func() error {
			log, err := c.Jobs.GetLog(errctx, b.Jobs[i].ID)
			if err != nil {
				return err
			}
			logs[i] = log
			return nil
		})
	}
	if err := group.Wait(); err != nil {
		return nil, err
	}
	return logs, nil
}
func (b *BuildService) Get(ctx context.Context, id int64, include ...string) (*Build, error) {
	path := "/build/" + strconv.FormatInt(id, 10)
	includes := strings.Join(include, ",")
	if includes != "" {
		path += "?include=" + includes
	}
	build := new(Build)
	if err := b.client.RequestRetryUnauth(ctx, "GET", path, nil, build); err != nil {
		return nil, err
	}
	return build, nil
}
type Log struct {
	Type           string          `json:"@type"`
	HREF           string          `json:"@href"`
	Representation string          `json:"@representation"`
	Permissions    map[string]bool `json:"@permissions"`
	RawLogHREF     string          `json:"@raw_log_href"`
	ID             int64           `json:"id"`
	Content        string          `json:"content"`
	LogParts       []*LogPart      `json:"log_parts"`
}
type LogPart struct {
	Content string `json:"content"`
	Final   bool   `json:"final"`
	Number  int    `json:"number"`
}