0
0
mirror of https://github.com/thegeeklab/wp-git-action.git synced 2024-09-20 01:12:47 +02:00
wp-git-action/git/clone.go

41 lines
631 B
Go
Raw Normal View History

package git
import (
"fmt"
"github.com/thegeeklab/wp-plugin-go/v2/types"
"golang.org/x/sys/execabs"
)
// FetchSource fetches the source from remote.
2024-05-06 20:29:57 +02:00
func (r *Repository) FetchSource() *types.Cmd {
args := []string{
"fetch",
"origin",
2024-05-06 20:29:57 +02:00
fmt.Sprintf("+%s:", r.Branch),
}
cmd := execabs.Command(gitBin, args...)
2024-05-06 20:29:57 +02:00
cmd.Dir = r.WorkDir
return &types.Cmd{
Cmd: cmd,
}
}
// CheckoutHead handles branch checkout.
2024-05-06 20:29:57 +02:00
func (r *Repository) CheckoutHead() *types.Cmd {
args := []string{
"checkout",
"-qf",
2024-05-06 20:29:57 +02:00
r.Branch,
}
cmd := execabs.Command(gitBin, args...)
2024-05-06 20:29:57 +02:00
cmd.Dir = r.WorkDir
return &types.Cmd{
Cmd: cmd,
}
}