pub struct GitSource { /* private fields */ }Expand description
Shell-out driver for the source tracker. Everything goes through Git’s
public interface — never into .git directly — so it works identically
against a clone or, later, a projection.
Implementations§
Source§impl GitSource
impl GitSource
pub fn open(root: &Utf8Path, substrate: SourceSubstrate) -> Result<Self>
pub fn root(&self) -> &Utf8Path
Sourcepub fn is_ignored(&self, path: &str) -> Result<bool>
pub fn is_ignored(&self, path: &str) -> Result<bool>
Whether the store repo’s gitignore rules cover path (which need not
exist yet) — used to enforce the tracker-path invariant.
Sourcepub fn is_tracked(&self, path: &str) -> Result<bool>
pub fn is_tracked(&self, path: &str) -> Result<bool>
Whether path is tracked by the store repo — a tracker path that is
also in Git history is dual-tracked, deliberately or not.
pub fn branch_exists(&self, name: &str) -> Result<bool>
pub fn create_branch(&self, name: &str, base: &str) -> Result<()>
pub fn rev_parse(&self, revision: &str) -> Result<String>
Sourcepub fn clone_to(&self, branch: &str, destination: &Utf8Path) -> Result<()>
pub fn clone_to(&self, branch: &str, destination: &Utf8Path) -> Result<()>
Materialize branch as a full standalone clone at destination.
A local-path clone hardlinks objects; never --shared/--reference.
Sourcepub fn fetch_ref(
&self,
from: &Utf8Path,
remote_ref: &str,
local_ref: &str,
) -> Result<()>
pub fn fetch_ref( &self, from: &Utf8Path, remote_ref: &str, local_ref: &str, ) -> Result<()>
Fetch a ref from another repository (typically a workspace clone) into the store. Fetch, never push: the store pulls commits in when a checkpoint blesses them, and workspaces stay passive.
pub fn update_ref(&self, name: &str, rev: &str) -> Result<()>
Sourcepub fn refs_under(&self, prefix: &str) -> Result<Vec<String>>
pub fn refs_under(&self, prefix: &str) -> Result<Vec<String>>
Every ref under a namespace, e.g. refs/newgit/checkpoints/<slug>.
pub fn delete_ref(&self, name: &str) -> Result<()>
pub fn is_ancestor(&self, ancestor: &str, descendant: &str) -> Result<bool>
Sourcepub fn workspace_short_head(workspace: &Utf8Path) -> Result<String>
pub fn workspace_short_head(workspace: &Utf8Path) -> Result<String>
Live HEAD of a workspace clone, short form.
Sourcepub fn workspace_head(workspace: &Utf8Path) -> Result<String>
pub fn workspace_head(workspace: &Utf8Path) -> Result<String>
Live HEAD of a workspace clone, full form.
Sourcepub fn workspace_show_head(
workspace: &Utf8Path,
path: &Utf8Path,
) -> Result<Option<String>>
pub fn workspace_show_head( workspace: &Utf8Path, path: &Utf8Path, ) -> Result<Option<String>>
Committed content of one path in a workspace clone: the blob at HEAD,
not what is on disk. None when HEAD has no such path.
This is what a render substitutes into — see crate::render::apply.
Read raw, never through [run_git]: that trims, which is right for a
rev and silently destructive for file content — it would drop the
file’s trailing newline on every render.
Sourcepub fn workspace_skip_worktree(
workspace: &Utf8Path,
paths: &[Utf8PathBuf],
) -> Result<()>
pub fn workspace_skip_worktree( workspace: &Utf8Path, paths: &[Utf8PathBuf], ) -> Result<()>
Mark paths --skip-worktree in a workspace clone, so this instance’s
rendered values never show as a modification and cannot be committed
by an agent running git add -A.
The counterpart of .git/info/exclude for tracker paths: newgit does
not control the Git an agent runs, so what must not be committable has
to be made so by construction. v1’s stand-in for the projection a v2
materializer does properly.
Sourcepub fn workspace_dirty_commit(
workspace: &Utf8Path,
message: &str,
rendered: &[Utf8PathBuf],
) -> Result<Option<String>>
pub fn workspace_dirty_commit( workspace: &Utf8Path, message: &str, rendered: &[Utf8PathBuf], ) -> Result<Option<String>>
Snapshot uncommitted and untracked (non-ignored) workspace state as a
dangling commit on top of HEAD, without touching HEAD, the real
index, or the worktree. Returns None when the worktree is clean.
Mechanics: a throwaway GIT_INDEX_FILE seeded from HEAD, git add -A
into it, git write-tree, and git commit-tree — all public
interface, nothing reaches into .git internals.
rendered paths are marked skip-worktree in the throwaway index.
The real index carries that bit already, but a fresh index seeded from
HEAD does not, so without this git add -A would sweep the instance’s
rendered ports into the checkpoint — the one place skip-worktree does
not protect on its own.
pub fn workspace_update_ref( workspace: &Utf8Path, name: &str, rev: &str, ) -> Result<()>
pub fn workspace_delete_ref(workspace: &Utf8Path, name: &str) -> Result<()>
Sourcepub fn workspace_fetch_ref(
workspace: &Utf8Path,
from: &Utf8Path,
remote_ref: &str,
) -> Result<()>
pub fn workspace_fetch_ref( workspace: &Utf8Path, from: &Utf8Path, remote_ref: &str, ) -> Result<()>
Fetch a store ref into a workspace clone (undo may need objects the workspace has since discarded).
Sourcepub fn workspace_restore_to(
workspace: &Utf8Path,
head_rev: &str,
dirty_rev: Option<&str>,
) -> Result<()>
pub fn workspace_restore_to( workspace: &Utf8Path, head_rev: &str, dirty_rev: Option<&str>, ) -> Result<()>
Put a workspace back to a checkpointed source state: HEAD hard-reset
to head_rev, untracked (non-ignored) files removed, then — when the
checkpoint carried uncommitted state — that state reapplied to the
worktree as uncommitted changes again. Ignored files (tracker paths,
node_modules) are deliberately left alone; trackers and resources own
their restoration.
Sourcepub fn workspace_tracked_files(workspace: &Utf8Path) -> Result<Vec<Utf8PathBuf>>
pub fn workspace_tracked_files(workspace: &Utf8Path) -> Result<Vec<Utf8PathBuf>>
Every path the workspace’s Git tracks, workspace-relative. This is what “the source content of this branch” means for export: tracked files as they stand on disk, so uncommitted edits are included and ignored junk never is.
Sourcepub fn init_export_repo(
destination: &Utf8Path,
branch: &str,
message: &str,
) -> Result<String>
pub fn init_export_repo( destination: &Utf8Path, branch: &str, message: &str, ) -> Result<String>
Turn a directory of already-placed files into an ordinary Git
repository with one commit on branch. Returns the commit.
One commit, never a history rewrite: exporting the workspace’s Git history would carry every file any past commit contained, which is exactly the content the audience filter just excluded.