Skip to content

Commit

Permalink
Add .git initialization on DownloadRepository for GitLab (#71)
Browse files Browse the repository at this point in the history
  • Loading branch information
omerzi committed Feb 28, 2023
1 parent f521aa6 commit d0c93d3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 3 additions & 2 deletions vcsclient/gitlab.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,8 @@ func (client *GitLabClient) DownloadRepository(ctx context.Context, owner, repos
return err
}
client.logger.Info("extracted repository successfully")
return nil
return vcsutils.CreateDotGitFolderWithRemote(localPath, "origin",
fmt.Sprintf("https://gitlab.com/%s/%s.git", owner, repository))
}

// CreatePullRequest on GitLab
Expand Down Expand Up @@ -394,7 +395,7 @@ func (client *GitLabClient) UploadCodeScanning(_ context.Context, _ string, _ st
}

// GetRepositoryEnvironmentInfo on GitLab
func (client *GitLabClient) GetRepositoryEnvironmentInfo(ctx context.Context, owner, repository, name string) (RepositoryEnvironmentInfo, error) {
func (client *GitLabClient) GetRepositoryEnvironmentInfo(_ context.Context, _, _, _ string) (RepositoryEnvironmentInfo, error) {
return RepositoryEnvironmentInfo{}, errGitLabGetRepoEnvironmentInfoNotSupported
}

Expand Down
5 changes: 3 additions & 2 deletions vcsclient/gitlab_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,9 @@ func TestGitLabClient_DownloadRepository(t *testing.T) {
require.NoError(t, err)
fileinfo, err := os.ReadDir(dir)
require.NoError(t, err)
assert.Len(t, fileinfo, 1)
assert.Equal(t, "README.md", fileinfo[0].Name())
assert.Len(t, fileinfo, 2)
assert.Equal(t, ".git", fileinfo[0].Name())
assert.Equal(t, "README.md", fileinfo[1].Name())
}

func TestGitLabClient_DownloadFileFromRepo(t *testing.T) {
Expand Down

0 comments on commit d0c93d3

Please sign in to comment.