Skip to content

Commit d9633a4

Browse files
some code
1 parent ec200b7 commit d9633a4

File tree

6 files changed

+545
-522
lines changed

6 files changed

+545
-522
lines changed

pkg/output/legacy_json.go

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,27 +25,26 @@ import (
2525
type LegacyJSONPrinter struct{ mu sync.Mutex }
2626

2727
func (p *LegacyJSONPrinter) Print(ctx context.Context, r *detectors.ResultWithMetadata) error {
28-
var repo string
28+
var repo, repoPath string
2929
switch r.SourceType {
3030
case sourcespb.SourceType_SOURCE_TYPE_GIT:
3131
repo = r.SourceMetadata.GetGit().Repository
32+
repoPath = r.SourceMetadata.GetGit().RepositoryLocalPath
3233
case sourcespb.SourceType_SOURCE_TYPE_GITHUB:
3334
repo = r.SourceMetadata.GetGithub().Repository
35+
repoPath = r.SourceMetadata.GetGithub().RepositoryLocalPath
3436
case sourcespb.SourceType_SOURCE_TYPE_GITLAB:
3537
repo = r.SourceMetadata.GetGitlab().Repository
38+
repoPath = r.SourceMetadata.GetGitlab().RepositoryLocalPath
3639
default:
3740
return fmt.Errorf("unsupported source type for legacy json output: %s", r.SourceType)
3841
}
3942

4043
// cloning the repo again here is not great and only works with unauthed repos
41-
repoPath := ""
4244
remote := false
4345
var err error
4446

45-
if r.SourceMetadata != nil && r.SourceMetadata.GetGitlab().RepositoryLocalPath != "" {
46-
repoPath = r.SourceMetadata.GetGitlab().RepositoryLocalPath + "/.git"
47-
remote = true
48-
} else {
47+
if repoPath == "" {
4948
repoPath, remote, err = git.PrepareRepo(ctx, repo, "")
5049
if err != nil || repoPath == "" {
5150
return fmt.Errorf("error preparing git repo for scanning: %w", err)

0 commit comments

Comments
 (0)