diff --git a/.gitattributes b/.gitattributes index e4504cf..2a9ada5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1,3 @@ .git* export-ignore + +*.test.secrets eol=lf filter=git-crypt diff=git-crypt \ No newline at end of file diff --git a/.gitignore b/.gitignore index 584b8c2..c85d29a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ *.o git-crypt +git-crypt.exe .vscode/* \ No newline at end of file diff --git a/tests/fake.test.secrets b/tests/fake.test.secrets new file mode 100644 index 0000000..d53ec00 Binary files /dev/null and b/tests/fake.test.secrets differ diff --git a/tests/key.gitcrypt b/tests/key.gitcrypt new file mode 100644 index 0000000..023eabd Binary files /dev/null and b/tests/key.gitcrypt differ diff --git a/tests/linux/basic-test.sh b/tests/linux/basic-test.sh index 8df4417..be0a3e4 100644 --- a/tests/linux/basic-test.sh +++ b/tests/linux/basic-test.sh @@ -1,6 +1,6 @@ #!/bin/bash set -e - +REPO_HOME="$PWD" # Export the built git-crypt binary to PATH export PATH="$PWD:$PATH" @@ -124,3 +124,23 @@ else fi echo "::notice:: ✅ Passed worktree test" + +echo "test compatibility with git-crypt 0.7.0..." + +# move to original repo +cd "$REPO_HOME" + +# clean git changes +git reset --hard + +git crypt unlock "./tests/key.gitcrypt" +# check if tests/fake.test.secrets is decrypted + +if xxd "./tests/fake.test.secrets" | grep -q 'GITCRYPT'; then + echo "fake.test.secrets is encrypted" + exit 1 +else + echo "fake.test.secrets is decrypted" + echo "::notice:: ✅ Passed 0.7.0 compatibility test" +fi + diff --git a/tests/windows/basic-test.ps1 b/tests/windows/basic-test.ps1 index 98b0292..70741e1 100644 --- a/tests/windows/basic-test.ps1 +++ b/tests/windows/basic-test.ps1 @@ -4,6 +4,7 @@ $ErrorActionPreference = "Stop" # Export the built git-crypt.exe to PATH $env:PATH = "$PWD;" + $env:PATH +$REPO_HOME = "$PWD" # Create a temporary directory for testing $TEMP_DIR = [System.IO.Path]::GetTempPath() $TEST_DIR = Join-Path ([System.IO.Path]::GetTempPath()) ([System.Guid]::NewGuid().ToString()) @@ -126,8 +127,29 @@ try { Write-Host "::notice:: ✅ Passed worktree test" + # Test compatibility with git-crypt 0.7.0 + Write-Host "Testing compatibility with git-crypt 0.7.0..." + + Push-Location "$REPO_HOME" + + git reset --hard + + git crypt unlock ".\tests\key.gitcrypt" + + # Check if the test file is properly decrypted + $testFilePath = ".\tests\fake.test.secrets" + $bytes = [System.IO.File]::ReadAllBytes($testFilePath)[0..8] + $headerString = [System.Text.Encoding]::ASCII.GetString($bytes) + + if ($headerString -eq "`0GITCRYPT") { + Write-Error "fake.test.secrets is still encrypted" + exit 1 + } else { + Write-Host "fake.test.secrets is decrypted" + Write-Host "::notice:: ✅ Passed 0.7.0 compatibility test" + } + } finally { - Pop-Location Remove-Item -Recurse -Force $TEST_DIR }