forked from rosa/hakurei
42 lines
858 B
Go
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))
|
|
}
|