Skip to content

Commit dba52c5

Browse files
committed
Skip the SHA256 test if git has not support for it
If you are building and running the tests in an environment with an older version of git, it might not have SHA256 support. This should not cause the git-sizer test suite to fail as it's not an issue with git-sizer. Detect this situation and skip the test.
1 parent 22f1158 commit dba52c5

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

git_sizer_test.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -867,7 +867,11 @@ func TestSHA256(t *testing.T) {
867867
// exist yet:
868868
cmd := exec.Command("git", "init", "--object-format", "sha256", testRepo.Path)
869869
cmd.Env = testutils.CleanGitEnv()
870-
err = cmd.Run()
870+
output, err := cmd.CombinedOutput()
871+
872+
if err != nil && strings.HasPrefix(string(output), "error: unknown option `object-format'") {
873+
t.Skip("skipping due to lack of SHA256 support")
874+
}
871875
require.NoError(t, err)
872876

873877
timestamp := time.Unix(1112911993, 0)

0 commit comments

Comments
 (0)