Creates a .lengua/ directory at path holding its first source — an
empty git repository with a templates/ directory inside it, ready for
lq_add() — or, with from_dir/from_repo, adopts an existing store as
that first source instead of starting empty. A library can later pool
more than one source together; see lq_fetch()/lq_update().
Usage
lq_init(
path,
name = NULL,
from_dir = NULL,
from_repo = NULL,
ref = NULL,
subdir = NULL,
force = FALSE
)Arguments
- path
Directory to initialize. Must not already contain a
.lengua/directory (unless importing withsubdirandforce = TRUE).- name
Name for the first source. Defaults to
"local"when starting empty, or is derived fromfrom_dir/from_repowhen adopting one.- from_dir
Use a local directory as the store source instead of starting empty. Full history and every tag are preserved. Mutually exclusive with
from_repo.- from_repo
Clone a git repo as the store source: a full URL, or
"[host/]owner/repo[/subdir][@ref]"shorthand (host defaults togithub.com— give one explicitly for GitHub Enterprise). Mutually exclusive withfrom_dir.- ref
Branch or tag to check out (not a commit id). Only valid with
from_repo; overrides any@refembedded in its shorthand. See Details for a residual limitation when combined with a localfrom_repopath.- subdir
Import only this subdirectory of the resolved source as the new source. Overrides any subdirectory embedded in
from_repo's shorthand. Unlike a plainfrom_dir/from_repoadoption, this imports the subdirectory's current content only — the source's history and any tags under it are not preserved (there's no lossless way to extract a subdirectory's history without a fullgit subtree-style rewrite) — and it can't later be refreshed withlq_update().- force
With
subdir, allow re-importing into a source that already exists, overwriting templates with the same name.
Details
from_dir (and from_repo when it names a local path rather than a
genuine remote) adopts the source with a plain filesystem copy — real,
independent history and tags, but no network protocol involved. This
isn't just an optimization: gix's network-transport clone shells out to
a git-upload-pack child process even for a local source, and that
process fails under R's SIGPIPE = SIG_IGN startup disposition (a
long-standing R embedding quirk) with "ignoring SIGPIPE signal" — the
filesystem copy sidesteps that entirely rather than working around it.
from_repo against a genuine remote host (https://, ssh://, ...)
still goes through gix's transport, which is socket-based rather than a
subprocess and isn't affected. The one remaining edge case: from_repo
naming a local path together with an explicit ref/@ref still uses
the transport-based clone (checking out an arbitrary ref after a plain
copy isn't implemented), so that specific combination could still hit the
same failure under R — prefer from_dir for local sources when you don't
need to select a non-default ref.
Examples
store <- withr::local_tempdir()
lq_init(store)
# adopting an existing store:
copy <- withr::local_tempdir()
lq_init(copy, from_dir = store)