0
0
mirror of https://github.com/thegeeklab/wp-git-action.git synced 2024-06-02 18:29:41 +02:00
wp-git-action/git/clone.go

41 lines
690 B
Go
Raw Permalink Normal View History

package git
import (
"fmt"
"os"
plugin_exec "github.com/thegeeklab/wp-plugin-go/v3/exec"
)
// FetchSource fetches the source from remote.
func (r *Repository) FetchSource() *plugin_exec.Cmd {
args := []string{
"fetch",
"origin",
2024-05-06 20:29:57 +02:00
fmt.Sprintf("+%s:", r.Branch),
}
cmd := plugin_exec.Command(gitBin, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
2024-05-06 20:29:57 +02:00
cmd.Dir = r.WorkDir
2024-05-06 22:43:56 +02:00
return cmd
}
// CheckoutHead handles branch checkout.
func (r *Repository) CheckoutHead() *plugin_exec.Cmd {
args := []string{
"checkout",
"-qf",
2024-05-06 20:29:57 +02:00
r.Branch,
}
cmd := plugin_exec.Command(gitBin, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
2024-05-06 20:29:57 +02:00
cmd.Dir = r.WorkDir
2024-05-06 22:43:56 +02:00
return cmd
}