git: GitRepo pull/push lack token auth + no Git-LFS support (forces downstream re-implementation) #150
Labels
No labels
prio_critical
prio_low
type_bug
type_contact
type_issue
type_lead
type_question
type_story
type_task
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
lhumina_code/hero_lib#150
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
herolib_os::git(crates/os/src/git/) is a capable general-purpose git toolkit, but two gaps in the per-repoGitRepoAPI forcedhero_slidesto roll its own ~750-line git module for git-linked deck collections instead of reusing this one. Filing so the gaps are visible and can be closed upstream.Gap 1 —
GitReponetwork ops can't authenticate a private repoGitRepo::pull,push,fetch, andcommitshell out to a bareCommand::new("git").args(["-C", path, ...])(seegit_core.rs). They inject:http.extraHeaderAuthorization token, so a private Forgejo repo can't be pulled/pushed;GIT_TERMINAL_PROMPT=0, so on a tty-less server git hangs on the credential prompt instead of failing fast.Token injection today lives only in the
Forgeworkflow layer (forge.rs,http.extraHeader=Authorization: token <FORGE_TOKEN>) and inGitExecutor(Redis-backed). ButForgeis hard-wired to the flat$PATH_CODE/{name}layout from env, so it can't operate on an arbitrary working-tree path the wayGitRepo::new(path)can. There is no way to do an authenticated pull/push on an arbitrary checkout.Suggested fix
Give
GitRepoan optional token (e.g.GitRepo::new(path).with_token(tok)or aclone_repo(...).token(tok)builder option) that, when set, injects-c http.extraHeader=...on network commands and always setsGIT_TERMINAL_PROMPT=0. This is the one genuinely reusable gap — it would makeGitRepousable for private repos at any path.Gap 2 — no Git-LFS support at all
There is zero LFS handling anywhere in
crates/os/src/git/(no pointer parsing, no batch API, no smudge handling).hero_slidescollections are image-heavy and stored with Git-LFS, so it had to implement:operation: download,transfers: [basic]) so nogit-lfsbinary is required on the host;oid sha256:,size), sha256 verification of fetched blobs;GIT_LFS_SKIP_SMUDGE=1on clone so a missing-LFS-auth smudge doesn't abort the checkout;--skip-worktreemarking of smudged files so they don't dirtygit status/ block pull/push;lfs_counts(present/total) helper for a download progress bar.Forgejo's LFS endpoint authenticates with HTTP Basic (token as username) — distinct from the
http.extraHeadertoken scheme — which is part of why this is non-trivial and worth having once, centrally.Suggested fix
Consider an optional LFS module (feature-gated) providing at minimum: pointer detection, batch-API resolve+download, and a present/total count. Even just the native batch download (no
git-lfsbinary dependency) would let multiple downstream services drop bespoke code.Context / reference impl
The working reference implementation is
hero_slides'scrates/hero_slides_lib/src/git.rs(token via per-commandhttp.extraHeader,GIT_TERMINAL_PROMPT=0,GIT_LFS_SKIP_SMUDGE=1, native LFS batch download, skip-worktree, lfs_counts). Tracking issue on the slides side: lhumina_code/hero_slides#97.Impact
Until at least Gap 1 is closed, services that sync private repos at arbitrary paths cannot use
GitRepoand must reach forForge(wrong layout) or hand-roll git. Gap 2 is a nice-to-have but would eliminate real duplication for image/asset-backed services.