mirror of
https://gitea.com/Lydanne/buildx.git
synced 2025-07-09 21:17:09 +08:00
build: lookup the right git binary on WSL
Signed-off-by: CrazyMax <crazy-max@users.noreply.github.com>
This commit is contained in:
@ -7,46 +7,46 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func GitInit(tb testing.TB) {
|
||||
func GitInit(c *Git, tb testing.TB) {
|
||||
tb.Helper()
|
||||
out, err := fakeGit("init")
|
||||
out, err := fakeGit(c, "init")
|
||||
require.NoError(tb, err)
|
||||
require.Contains(tb, out, "Initialized empty Git repository")
|
||||
require.NoError(tb, err)
|
||||
GitCheckoutBranch(tb, "main")
|
||||
_, _ = fakeGit("branch", "-D", "master")
|
||||
GitCheckoutBranch(c, tb, "main")
|
||||
_, _ = fakeGit(c, "branch", "-D", "master")
|
||||
}
|
||||
|
||||
func GitCommit(tb testing.TB, msg string) {
|
||||
func GitCommit(c *Git, tb testing.TB, msg string) {
|
||||
tb.Helper()
|
||||
out, err := fakeGit("commit", "--allow-empty", "-m", msg)
|
||||
out, err := fakeGit(c, "commit", "--allow-empty", "-m", msg)
|
||||
require.NoError(tb, err)
|
||||
require.Contains(tb, out, "main", msg)
|
||||
}
|
||||
|
||||
func GitTag(tb testing.TB, tag string) {
|
||||
func GitTag(c *Git, tb testing.TB, tag string) {
|
||||
tb.Helper()
|
||||
out, err := fakeGit("tag", tag)
|
||||
out, err := fakeGit(c, "tag", tag)
|
||||
require.NoError(tb, err)
|
||||
require.Empty(tb, out)
|
||||
}
|
||||
|
||||
func GitCheckoutBranch(tb testing.TB, name string) {
|
||||
func GitCheckoutBranch(c *Git, tb testing.TB, name string) {
|
||||
tb.Helper()
|
||||
out, err := fakeGit("checkout", "-b", name)
|
||||
out, err := fakeGit(c, "checkout", "-b", name)
|
||||
require.NoError(tb, err)
|
||||
require.Empty(tb, out)
|
||||
}
|
||||
|
||||
func GitAdd(tb testing.TB, file string) {
|
||||
func GitAdd(c *Git, tb testing.TB, file string) {
|
||||
tb.Helper()
|
||||
_, err := fakeGit("add", file)
|
||||
_, err := fakeGit(c, "add", file)
|
||||
require.NoError(tb, err)
|
||||
}
|
||||
|
||||
func GitSetRemote(tb testing.TB, url string) {
|
||||
func GitSetRemote(c *Git, tb testing.TB, url string) {
|
||||
tb.Helper()
|
||||
_, err := fakeGit("remote", "add", "origin", url)
|
||||
_, err := fakeGit(c, "remote", "add", "origin", url)
|
||||
require.NoError(tb, err)
|
||||
}
|
||||
|
||||
@ -62,7 +62,7 @@ func Mktmp(tb testing.TB) string {
|
||||
return folder
|
||||
}
|
||||
|
||||
func fakeGit(args ...string) (string, error) {
|
||||
func fakeGit(c *Git, args ...string) (string, error) {
|
||||
allArgs := []string{
|
||||
"-c", "user.name=buildx",
|
||||
"-c", "user.email=buildx@docker.com",
|
||||
@ -71,6 +71,5 @@ func fakeGit(args ...string) (string, error) {
|
||||
"-c", "log.showSignature=false",
|
||||
}
|
||||
allArgs = append(allArgs, args...)
|
||||
c := New()
|
||||
return c.clean(c.run(allArgs...))
|
||||
}
|
||||
|
Reference in New Issue
Block a user