Skip to content

Commit

Permalink
remove normalization and checkout unix style
Browse files Browse the repository at this point in the history
  • Loading branch information
emilwareus committed Oct 9, 2023
1 parent a2444ce commit 5a9aa93
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ jobs:
os: [ 'ubuntu-latest', 'windows-latest', 'macos-latest' ]
runs-on: ${{ matrix.os }}
steps:
- name: Set git to use LF
run: |
git config --global core.autocrlf input
git config --global core.eol lf
- uses: actions/checkout@v3

- name: Set up Go
Expand Down
11 changes: 2 additions & 9 deletions internal/file/fingerprint.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,26 +148,19 @@ func shouldProcessFile(fileInfo os.FileInfo, exclusions []string, path string) b
return true
}

func normalizeLineEndings(data []byte) []byte {
// Convert to Unix line endings
return []byte(strings.ReplaceAll(string(data), "\r\n", "\n"))
}

func computeMD5(filename string) (FileFingerprint, error) {
data, err := os.ReadFile(filename)
if err != nil {
return FileFingerprint{}, err
}

normalizedData := normalizeLineEndings(data)

hash := md5.New() // #nosec

if _, err := hash.Write(normalizedData); err != nil {
if _, err := hash.Write(data); err != nil {
return FileFingerprint{}, err
}

contentLength := int64(len(normalizedData))
contentLength := int64(len(data))

if err != nil {
return FileFingerprint{}, err
Expand Down

0 comments on commit 5a9aa93

Please sign in to comment.