Repository navigation
fix(opencode): tolerate CRLF in plugin self-heal regex - #54
Merged
Merged
Conversation
Windows CI (go-test windows-latest) failed two RefreshPluginIfStale tests. Root cause: plugin/opencode.js is LF in the repo, but Windows runners default to core.autocrlf=true, converting it to CRLF before go:embed bakes it into PluginJS. The binaryConstRe regex (?m)^const BINARY = "([^"]*)";$ anchored on $ which matches before \n — but \r sits between ; and \n in CRLF, breaking the anchor. bakedBinaryPath returned false → RefreshPluginIfStale silently no-op'd, so the self-heal meant to deliver JS fixes to existing users was completely broken on Windows. Two fixes: - binaryConstRe now uses ;\r?$ to tolerate CRLF (fixes reading existing CRLF plugin files on disk — the real user-facing bug) - .gitattributes pins plugin/opencode.js to eol=lf so the embedded content is byte-identical across platforms and bytes.Equal comparisons stay reliable Added TestRefreshPluginIfStaleHandlesCRLFLineEndings as a regression guard (verified it fails against the old regex).
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The
Testworkflow has been red ongo-test (windows-latest)across the last several runs (main + 2 PRs), while macOS/Ubuntu pass and the Release workflow is fine.Failing tests:
TestRefreshPluginIfStaleRewritesOutdatedTestRefreshPluginIfStalePreservesBakedBinaryPathBoth fail with
RefreshPluginIfStale() = false, want true for outdated plugin.Root cause
binaryConstReininternal/opencodehooks/settings.goanchored on$: