Skip to content

feat: add Source for fetching earlier template revisions - #68

Draft
jvmakine wants to merge 2 commits into
block:mainfrom
jvmakine:juho/template-revisions
Draft

jvmakine wants to merge 2 commits into
block:mainfrom
jvmakine:juho/template-revisions

Conversation

@jvmakine

@jvmakine jvmakine commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

To update a directory that was scaffolded earlier, a tool has to render the templates again exactly as they were back then, then compare that with a render of the latest templates. Open can't do this, because it doesn't report which revision it fetched.

This adds an interface for sources that can reproduce earlier revisions:

type Source interface {
	Open(ctx context.Context) (*Revision, error)
	OpenRevision(ctx context.Context, revision string) (*Revision, error)
}

A Revision holds the templates as an fs.FS, along with the ID to pass back to OpenRevision later. Close removes the fetched files.

NewSource accepts the same remote source forms as Open. For now only git implements it. Any other source returns ErrNoRevisions.

For git:

  • The revision is the commit hash, read with git rev-parse HEAD before .git is removed.
  • Open keeps the source's ref and depth.
  • OpenRevision replaces ref with getit's new commit parameter and sets depth=1, so only that one commit is fetched. This needs git 2.49 or later.

Open is unchanged. getit is bumped to the commit that adds commit (block/getit#4). It also brings fuller git error messages and process-group cancellation for git clones.

🤖 Generated with Claude Code

jvmakine and others added 2 commits October 23, 2026 14:51
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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