Skip to content

fix: reset rewritten state for no-decl files#91

Open
oshokin wants to merge 1 commit into
pingcap:masterfrom
oshokin:fix/rewritefile-reset-rewritten-state
Open

fix: reset rewritten state for no-decl files#91
oshokin wants to merge 1 commit into
pingcap:masterfrom
oshokin:fix/rewritefile-reset-rewritten-state

Conversation

@oshokin
Copy link
Copy Markdown

@oshokin oshokin commented May 6, 2026

Summary

  • reset Rewriter.rewritten at the start of RewriteFile
  • prevent stale rewrite state leaking into files without declarations (e.g. doc.go)
  • add regression test for sequential rewrite: failpoint file -> no-decl file

Repro

  • rewrite a file with failpoint injection using one Rewriter instance
  • then rewrite doc.go (package x only) with the same instance
  • before fix, GetRewritten() incorrectly stays true

Test

  • go test ./code -run TestRewriteFileResetRewrittenStateForNoDeclFile -count=1

@pingcap-cla-assistant
Copy link
Copy Markdown

pingcap-cla-assistant Bot commented May 6, 2026

CLA assistant check
All committers have signed the CLA.

@oshokin
Copy link
Copy Markdown
Author

oshokin commented May 9, 2026

I've signed license multiple times already 😿

@kennytm
Copy link
Copy Markdown
Contributor

kennytm commented May 9, 2026

@oshokin The commit 3d3a367 is authored by "oleg.shokin" <oleg.shokin@myoffice.team>. If this is you, the CLA bot is unable to associate that email address with your account, and thus rejects the contribution.

You can associate that email address to your GitHub account (see https://docs.github.com/en/account-and-profile/how-tos/email-preferences/adding-an-email-address-to-your-github-account), or rewrite that commit using your GitHub email address instead.

@oshokin
Copy link
Copy Markdown
Author

oshokin commented May 9, 2026

@oshokin The commit 3d3a367 is authored by "oleg.shokin" <oleg.shokin@myoffice.team>. If this is you, the CLA bot is unable to associate that email address with your account, and thus rejects the contribution.

You can associate that email address to your GitHub account (see https://docs.github.com/en/account-and-profile/how-tos/email-preferences/adding-an-email-address-to-your-github-account), or rewrite that commit using your GitHub email address instead.

I see, thanks for explanation.
I'm gonna remake that commit better from my personal PC.

@oshokin oshokin force-pushed the fix/rewritefile-reset-rewritten-state branch from 3d3a367 to fc5f482 Compare May 10, 2026 18:35
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.

2 participants