From faeb0914b26b60210e5b66fb004ce8b86379f85b Mon Sep 17 00:00:00 2001 From: Eduardo Argollo Date: Thu, 30 May 2019 15:09:45 -0700 Subject: [PATCH] Solving error on authentication --- src/repo.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/repo.go b/src/repo.go index 8ac2ba64..8266d32f 100644 --- a/src/repo.go +++ b/src/repo.go @@ -15,6 +15,7 @@ import ( diffType "gopkg.in/src-d/go-git.v4/plumbing/format/diff" "gopkg.in/src-d/go-git.v4/plumbing/object" "gopkg.in/src-d/go-git.v4/plumbing/storer" + gitHttp "gopkg.in/src-d/go-git.v4/plumbing/transport/http" "gopkg.in/src-d/go-git.v4/storage/memory" ) @@ -98,10 +99,17 @@ func (repoInfo *RepoInfo) clone() error { Auth: config.sshAuth, }) } else { - repo, err = git.Clone(memory.NewStorage(), nil, &git.CloneOptions{ + options := &git.CloneOptions{ URL: opts.Repo, Progress: os.Stdout, - }) + } + if os.Getenv("GITHUB_TOKEN") != "" { + options.Auth = &gitHttp.BasicAuth{ + Username: "fakeUsername", // yes, this can be anything except an empty string + Password: os.Getenv("GITHUB_TOKEN"), + } + } + repo, err = git.Clone(memory.NewStorage(), nil, options) } } repoInfo.repository = repo