Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 4 additions & 2 deletions internal/bundle/bundle_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,11 @@ package bundle

import (
"context"
deepcode2 "github.com/snyk/code-client-go/internal/deepcode"
"os"
"path/filepath"

deepcode2 "github.com/snyk/code-client-go/internal/deepcode"

"github.com/puzpuzpuz/xsync"
"github.com/rs/zerolog"

Expand Down Expand Up @@ -116,9 +117,10 @@ func (b *bundleManager) Create(ctx context.Context,
}
relativePath = util.EncodePath(relativePath)

bundleFile := deepcode2.BundleFileFrom(absoluteFilePath, fileContent)
bundleFile := deepcode2.BundleFileFrom(fileContent)
bundleFiles[relativePath] = bundleFile
fileHashes[relativePath] = bundleFile.Hash
b.logger.Trace().Str("method", "BundleFileFrom").Str("hash", bundleFile.Hash).Str("filePath", absoluteFilePath).Msg("")

if changedFiles[absoluteFilePath] {
limitToFiles = append(limitToFiles, relativePath)
Expand Down
5 changes: 1 addition & 4 deletions internal/deepcode/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@
package deepcode

import (
"github.com/rs/zerolog/log"

"github.com/snyk/code-client-go/internal/util"
)

Expand All @@ -26,11 +24,10 @@ type BundleFile struct {
Content string `json:"content"`
}

func BundleFileFrom(filePath string, content []byte) BundleFile {
func BundleFileFrom(content []byte) BundleFile {
file := BundleFile{
Hash: util.Hash(content),
Content: string(content),
}
log.Trace().Str("method", "BundleFileFrom").Str("hash", file.Hash).Str("filePath", filePath).Msg("")
return file
}
11 changes: 6 additions & 5 deletions scan_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,14 @@ package codeclient_test

import (
"context"
"os"
"path/filepath"
"testing"

"github.com/snyk/code-client-go/internal/bundle"
bundleMocks "github.com/snyk/code-client-go/internal/bundle/mocks"
"github.com/snyk/code-client-go/internal/deepcode"
deepcodeMocks "github.com/snyk/code-client-go/internal/deepcode/mocks"
"os"
"path/filepath"
"testing"

"github.com/golang/mock/gomock"
"github.com/rs/zerolog"
Expand All @@ -40,8 +41,8 @@ func Test_UploadAndAnalyze(t *testing.T) {
baseDir, firstDocPath, secondDocPath, firstDocContent, secondDocContent := setupDocs(t)
docs := sliceToChannel([]string{firstDocPath, secondDocPath})
files := map[string]deepcode.BundleFile{
firstDocPath: deepcode.BundleFileFrom(firstDocPath, firstDocContent),
firstDocPath: deepcode.BundleFileFrom(secondDocPath, secondDocContent),
firstDocPath: deepcode.BundleFileFrom(firstDocContent),
firstDocPath: deepcode.BundleFileFrom(secondDocContent),
}

logger := zerolog.Nop()
Expand Down