0
0
mirror of https://github.com/thegeeklab/wp-git-action.git synced 2024-11-24 02:30:41 +00:00
wp-git-action/git/clone.go

41 lines
690 B
Go
Raw 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 18:29:57 +00:00
fmt.Sprintf("+%s:", r.Branch),
}
cmd := plugin_exec.Command(gitBin, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
2024-05-06 18:29:57 +00:00
cmd.Dir = r.WorkDir
2024-05-06 20:43:56 +00:00
return cmd
}
// CheckoutHead handles branch checkout.
func (r *Repository) CheckoutHead() *plugin_exec.Cmd {
args := []string{
"checkout",
"-qf",
2024-05-06 18:29:57 +00:00
r.Branch,
}
cmd := plugin_exec.Command(gitBin, args...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
2024-05-06 18:29:57 +00:00
cmd.Dir = r.WorkDir
2024-05-06 20:43:56 +00:00
return cmd
}