Skip to content

Commit

Permalink
Make git user account optional
Browse files Browse the repository at this point in the history
Signed-off-by: Tamal Saha <[email protected]>
  • Loading branch information
tamalsaha committed Jun 25, 2020
1 parent eca3c27 commit 67cb460
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions cmds/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -307,7 +307,7 @@ func processAssets(sh *shell.Session, a api.AssetListing) error {
wdOrig := sh.Getwd()
defer sh.SetDir(wdOrig)

owner, repo := ParseRepoURL(a.RepoURL)
owner, repo := parseRepoURL(a.RepoURL)

// TODO: cache git repo
wdCur := filepath.Join(Workspace, owner)
Expand Down Expand Up @@ -360,7 +360,7 @@ func processProduct(sh *shell.Session, p api.Product) error {
wdOrig := sh.Getwd()
defer sh.SetDir(wdOrig)

owner, repo := ParseRepoURL(p.RepoURL)
owner, repo := parseRepoURL(p.RepoURL)

// TODO: cache git repo
wdCur := filepath.Join(Workspace, owner)
Expand Down Expand Up @@ -723,7 +723,7 @@ func processSubProject(sh *shell.Session, p api.Product, v api.ProductVersion, v
return err
}

owner, repo := ParseRepoURL(sp.RepoURL)
owner, repo := parseRepoURL(sp.RepoURL)

// TODO: cache git repo
wdCur := filepath.Join(Workspace, owner)
Expand Down Expand Up @@ -929,7 +929,7 @@ func exists(name string) bool {
return true
}

func ParseRepoURL(repoURL string) (string, string) {
func parseRepoURL(repoURL string) (string, string) {
if !strings.Contains(repoURL, "://") {
repoURL = "https://" + repoURL
}
Expand Down Expand Up @@ -963,6 +963,8 @@ func gitURL(repoURL string) string {
if err != nil {
panic(err)
}
u.User = url.UserPassword(os.Getenv(GitHubUserKey), os.Getenv(GitHubTokenKey))
if os.Getenv(GitHubUserKey) != "" && os.Getenv(GitHubTokenKey) != "" {
u.User = url.UserPassword(os.Getenv(GitHubUserKey), os.Getenv(GitHubTokenKey))
}
return u.String()
}

0 comments on commit 67cb460

Please sign in to comment.