Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix broken test for gitlab. #473

Merged
merged 1 commit into from
Apr 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion pkg/sources/gitlab/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,13 @@ func (s *Source) scanRepos(ctx context.Context, chunksChan chan *sources.Chunk,
if s.authMethod == "UNAUTHENTICATED" {
path, repo, err = git.CloneRepoUsingUnauthenticated(repoURL.String())
} else {
path, repo, err = git.CloneRepoUsingToken(s.token, repoURL.String(), s.user)
// If a username is not provided we need to use a default one in order to clone a private repo.
// Not setting "placeholder" as s.user on purpose in case any downstream services rely on a "" value for s.user.
user := s.user
if user == "" {
user = "placeholder"
}
path, repo, err = git.CloneRepoUsingToken(s.token, repoURL.String(), user)
}
defer os.RemoveAll(path)
if err != nil {
Expand Down