Skip to content

Conversation

@carlosmn
Copy link
Contributor

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.

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.
@carlosmn carlosmn requested a review from a team as a code owner January 16, 2026 11:42
Copilot AI review requested due to automatic review settings January 16, 2026 11:42
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds logic to gracefully skip the SHA256 test when running in environments with older Git versions that lack SHA256 support. This prevents test suite failures due to missing Git features rather than issues with git-sizer itself.

Changes:

  • Modified the TestSHA256 function to capture git command output
  • Added detection for the "unknown option" error indicating lack of SHA256 support
  • Skip the test with an informative message when SHA256 is not available

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if err != nil && strings.HasPrefix(string(output), "error: unknown option `object-format'") {
t.Skip("skipping due to lack of SHA256 support")
}
require.NoError(t, err)
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If the git init command fails for a reason other than missing SHA256 support, the error message at line 875 won't include the command output, making it harder to diagnose the failure. Consider adding the output to the error message, for example by using require.NoError(t, err, \"git init failed: %s\", string(output)) or a similar approach that includes the output in failure cases.

Suggested change
require.NoError(t, err)
require.NoError(t, err, "git init failed: %s", string(output))

Copilot uses AI. Check for mistakes.
Comment on lines 872 to 873
if err != nil && strings.HasPrefix(string(output), "error: unknown option `object-format'") {
t.Skip("skipping due to lack of SHA256 support")
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The error message matching uses an exact prefix match which may be fragile across different git versions or locales. Consider using strings.Contains to match a key part of the error (e.g., "unknown option" and "object-format") for more robust detection, or document the git version assumptions if this exact format is intentional.

Suggested change
if err != nil && strings.HasPrefix(string(output), "error: unknown option `object-format'") {
t.Skip("skipping due to lack of SHA256 support")
if err != nil {
msg := string(output)
if strings.Contains(msg, "unknown option") && strings.Contains(msg, "object-format") {
t.Skip("skipping due to lack of SHA256 support")
}

Copilot uses AI. Check for mistakes.
Version 2 wants to use the old URL so that also fails to run. The latest is
version 6 so let's update to that and at the same time update to the same Go
version that we want to download in the build script.
torstenwalter
torstenwalter previously approved these changes Jan 16, 2026
mhagger
mhagger previously approved these changes Jan 16, 2026
Copy link
Member

@mhagger mhagger left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot's second suggestion sounds like a good idea, but with or without that change, 👍

@carlosmn
Copy link
Contributor Author

The locale comment doesn't make much sense if we're still putting in the "unknown option" text. We can presumably reduce it to "object-format" if we're not trying to match exactly.

As pointed out by the robot, this can be an issue with different locales. It is
enough for our purposes to know that the error message includes "object-format"
so we know it's unhappy with it.
@carlosmn carlosmn dismissed stale reviews from mhagger and torstenwalter via 37ca70f January 16, 2026 14:24
@carlosmn carlosmn merged commit 88eaa80 into master Jan 16, 2026
11 checks passed
@carlosmn carlosmn deleted the cmn/skip-on-no-sha256 branch January 16, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants