refactor: replace SourceInfo with TemplateOrigin enum#99
Merged
Conversation
Deploying diecut with
|
| Latest commit: |
02fd64a
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://db3b6cbf.diecut.pages.dev |
| Branch Preview URL: | https://fix-diecut-thb.diecut.pages.dev |
SourceInfo encoded local-vs-Git origin through three nullable Option
fields, relying on url.is_some() as a proxy for 'Git template'.
Replace with an explicit enum:
TemplateOrigin::Local
TemplateOrigin::Git { url, git_ref, commit_sha }
- Hook-warning check becomes matches!(origin, TemplateOrigin::Git { .. })
- write_answers now takes &TemplateOrigin directly
- Construction sites in plan_generation updated (2 locations)
- Integration test updated to use TemplateOrigin::Local
02fd64a to
213df03
Compare
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.
Whether a template came from a git repo or a local path was encoded by convention: if all three fields of
SourceInfoareNone, it's local; ifurlis set, it's from git. The hook-warning check readsource_info.url.is_some()as a proxy for "is this a remote template?" That's implicit and easy to misread.Replaced
SourceInfowith an explicit enum:The hook-warning check is now
matches!(origin, TemplateOrigin::Git { .. }), which says what it means. Construction sites inplan_generationand the integration test updated accordingly.