Skip to content

Commit

Permalink
it works better with auth
Browse files Browse the repository at this point in the history
  • Loading branch information
helaili committed Jun 14, 2023
1 parent 679cddc commit 532eda1
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion entitlementConfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (

"github.com/bradleyfalzon/ghinstallation/v2"
"github.com/go-git/go-git/v5"
githttp "github.com/go-git/go-git/v5/plumbing/transport/http"
"github.com/golang-jwt/jwt/v5"
"github.com/google/go-github/v53/github"
"golang.org/x/text/cases"
Expand Down Expand Up @@ -68,8 +69,16 @@ func (config *EntitlementConfig) load(appTransport *ghinstallation.AppsTransport
// Need to clean up the download directory before cloning the repo
os.RemoveAll(fmt.Sprintf("/tmp/%s/%s", config.Login, config.Repo))

_, err := git.PlainClone(fmt.Sprintf("/tmp/%s/%s", config.Login, config.Repo), false, &git.CloneOptions{
token, err := itr.Token(context.Background())
if err != nil {
log.Printf("couldn't get token for installation %d on org %s", config.InstallationId, config.Login)
return err
}

log.Println(token)
_, err = git.PlainClone(fmt.Sprintf("/tmp/%s/%s", config.Login, config.Repo), false, &git.CloneOptions{
URL: fmt.Sprintf("%s/%s/%s", config.GitUrl, config.Login, config.Repo),
Auth: &githttp.BasicAuth{Username: "username", Password: token},
Progress: os.Stdout,
})
if err != nil {
Expand Down

0 comments on commit 532eda1

Please sign in to comment.