Files
hakurei/internal/rosa/git.go
Ophestra b482fd4abf internal/rosa: remove global handles
These no longer serve any purpose.

Signed-off-by: Ophestra <cat@gensokyo.uk>
2026-05-20 08:15:23 +09:00

42 lines
858 B
Go

package rosa
import (
"path"
"strings"
"hakurei.app/internal/pkg"
)
// Git is the package used by [Toolchain.NewViaGit].
var Git = H("git")
// NewViaGit returns a [pkg.Artifact] for cloning a git repository.
func (t Toolchain) NewViaGit(
url, rev string,
checksum pkg.Checksum,
) pkg.Artifact {
return t.New(strings.TrimSuffix(
path.Base(url),
".git",
)+"-src-"+path.Base(rev), THostNet, t.Append(nil,
nssCACert,
Git,
), &checksum, nil, `
git \
-c advice.detachedHead=false \
clone \
--depth=1 \
--revision=`+rev+` \
--shallow-submodules \
--recurse-submodules \
`+url+` \
/work
rm -rf /work/.git
`, resolvconf())
}
// newTagRemote is a helper around NewViaGit for a tag on a git remote.
func (t Toolchain) newTagRemote(url, tag, checksum string) pkg.Artifact {
return t.NewViaGit(url, "refs/tags/"+tag, mustDecode(checksum))
}