Skip to content

refactor: replace SourceInfo with TemplateOrigin enum#99

Merged
raiderrobert merged 1 commit into
mainfrom
fix/diecut-thb
Feb 20, 2026
Merged

refactor: replace SourceInfo with TemplateOrigin enum#99
raiderrobert merged 1 commit into
mainfrom
fix/diecut-thb

Conversation

@raiderrobert

@raiderrobert raiderrobert commented Feb 20, 2026

Copy link
Copy Markdown
Owner

Whether a template came from a git repo or a local path was encoded by convention: if all three fields of SourceInfo are None, it's local; if url is set, it's from git. The hook-warning check read source_info.url.is_some() as a proxy for "is this a remote template?" That's implicit and easy to misread.

Replaced SourceInfo with an explicit enum:

pub enum TemplateOrigin {
    Local,
    Git { url: String, git_ref: Option<String>, commit_sha: Option<String> },
}

The hook-warning check is now matches!(origin, TemplateOrigin::Git { .. }), which says what it means. Construction sites in plan_generation and the integration test updated accordingly.

@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying diecut with  Cloudflare Pages  Cloudflare Pages

Latest commit: 02fd64a
Status: ✅  Deploy successful!
Preview URL: https://db3b6cbf.diecut.pages.dev
Branch Preview URL: https://fix-diecut-thb.diecut.pages.dev

View logs

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
@raiderrobert raiderrobert merged commit a16415e into main Feb 20, 2026
5 checks passed
@raiderrobert raiderrobert deleted the fix/diecut-thb branch February 20, 2026 15:10
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