Skip to content

Optional hunk size - #167

Merged
fredbi merged 3 commits into
go-openapi:masterfrom
fredbi:optional-hunk-size
Sep 7, 2026
Merged

Optional hunk size#167
fredbi merged 3 commits into
go-openapi:masterfrom
fredbi:optional-hunk-size

Conversation

@fredbi

@fredbi fredbi commented Sep 7, 2026

Copy link
Copy Markdown
Member

Change type

Please select: 🆕 New feature or enhancement|🔧 Bug fix'|📃 Documentation update

Short description

Fixes

Full description

Checklist

  • I have signed all my commits with my name and email (see DCO. This does not require a PGP-signed commit
  • I have rebased and squashed my work, so only one commit remains
  • I have added tests to cover my changes.
  • I have properly enriched go doc comments in code.
  • I have properly documented any breaking change.

fredbi and others added 3 commits September 7, 2026 16:47
assert.New(t) and require.New(t) now accept Option values. WithHunkSize
is the only one so far: it sets how many unchanged lines the diff shows
around each change in the failure message of Equal, EqualT, EqualValues,
EqualExportedValues and Exactly. The default stays 1.

BuildOptions folds the options into an unexported options value that the
forward methods append to msgAndArgs, and splitArgs pulls it back out
before the message is formatted, so it never reaches the reader. The same
door would let a caller pass an Option straight to a top-level function;
that case is left commented out in splitArgs, so assert.Equal(t, ...)
keeps its signature and a hunk size of 1.

Codegen:
- the forward and format templates render the o field, the opts parameter
  on New, and the call carrying a.o; forwardArgs takes variadic extras;
- a new "excluded:" comment tag keeps a function out of the generated
  packages, the domain pages and the metrics. BuildOptions carries it,
  since it returns an opaque any and has no business in assert/require.

Refers to stretchr#1878.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015qDqrLvtn2K5uA6RpSoHvR
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
WithHunkSize said only "modifies the size of the hunk context in diff".
It now names the five assertions that render a diff (Equal, EqualT,
EqualValues, EqualExportedValues, Exactly), states the default of 1, the
clamp below 1, the whole-value case above the rendered length, and shows
the call.

USAGE.md gains a "Widening the Diff Context" section under Customization,
comparing the real output of the same struct at hunk size 1 and 4, and a
warning that options ride on the Assertions object: assert.Equal at
package level always uses a hunk size of 1. The Forward Methods section
links to it.

CHANGES.md records the option under Major Additions.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015qDqrLvtn2K5uA6RpSoHvR
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
Moves stretchr#1878 from Monitoring to Adapted, restricted to the
forward methods, and starts monitoring stretchr#1945 (a Must
helper returning a value when there is no error).

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_015qDqrLvtn2K5uA6RpSoHvR
Signed-off-by: Frederic BIDON <fredbi@yahoo.com>
@codecov

codecov Bot commented Sep 7, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 99.36609% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.67%. Comparing base (0aaa1d5) to head (369de65).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
codegen/internal/model/model.go 72.72% 3 Missing ⚠️
codegen/internal/generator/doc_generator.go 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #167      +/-   ##
==========================================
- Coverage   93.71%   93.67%   -0.05%     
==========================================
  Files         103      104       +1     
  Lines       13937    13991      +54     
==========================================
+ Hits        13061    13106      +45     
- Misses        869      878       +9     
  Partials        7        7              

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

@fredbi
fredbi merged commit dd84de6 into go-openapi:master Sep 7, 2026
25 checks passed
@fredbi
fredbi deleted the optional-hunk-size branch September 7, 2026 16:41
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.

1 participant