Skip to content

Commit

Permalink
fix platform dependendt paths
Browse files Browse the repository at this point in the history
  • Loading branch information
emilwareus committed Oct 7, 2023
1 parent 1a3c8b8 commit 37ba249
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
5 changes: 1 addition & 4 deletions internal/file/default_exclusion.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ func DefaultExclusionsFingerprint() []string {
output = append(output, filepath.Join("**", pattern, "**"))
}

for _, pattern := range EXCLUDED_DIRS_FINGERPRINT_RAW {
output = append(output, pattern)
}

output = append(output, EXCLUDED_DIRS_FINGERPRINT_RAW...)
return output

Check failure on line 29 in internal/file/default_exclusion.go

View workflow job for this annotation

GitHub Actions / Lint

return with no blank line before (nlreturn)
}
4 changes: 3 additions & 1 deletion internal/file/fingerprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ type FileFingerprint struct {
}

func (f FileFingerprint) ToString() string {
return fmt.Sprintf("file=%x,%d,%s", f.fingerprint, f.contentLength, f.path)
// Replace backslashes with forward slashes to make the path platform independent
path := strings.ReplaceAll(f.path, "\\", "/")
return fmt.Sprintf("file=%x,%d,%s", f.fingerprint, f.contentLength, path)

Check failure on line 88 in internal/file/fingerprint.go

View workflow job for this annotation

GitHub Actions / Lint

return with no blank line before (nlreturn)
}

func (f *Fingerprinter) FingerprintFiles(rootPath string, exclusions []string) (Fingerprints, error) {
Expand Down
11 changes: 11 additions & 0 deletions internal/file/fingerprint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,17 @@ func TestFingerprintFiles(t *testing.T) {

}

func TestFingerprintFilesBackslash(t *testing.T) {
fingerprint := FileFingerprint{
path: "testdata\\fingerprinter\\testfile.py",
contentLength: 21,
fingerprint: []byte{114, 33, 77, 180, 225, 229, 67, 1, 141, 27, 175, 232, 110, 163, 180, 68, 68, 68, 68, 68, 68},
}

assert.Equal(t, "file=72214db4e1e543018d1bafe86ea3b4444444444444,21,testdata/fingerprinter/testfile.py", fingerprint.ToString())

}

func TestFileFingerprintToString(t *testing.T) {
fileFingerprint := FileFingerprint{path: "path", contentLength: 10, fingerprint: []byte("fingerprint")}
assert.Equal(t, "file=66696e6765727072696e74,10,path", fileFingerprint.ToString())
Expand Down

0 comments on commit 37ba249

Please sign in to comment.