mirror of
https://github.com/thegeeklab/wp-git-action.git
synced 2024-11-22 00:00:39 +00:00
41 lines
690 B
Go
41 lines
690 B
Go
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",
|
|
fmt.Sprintf("+%s:", r.Branch),
|
|
}
|
|
|
|
cmd := plugin_exec.Command(gitBin, args...)
|
|
cmd.Stdout = os.Stdout
|
|
cmd.Stderr = os.Stderr
|
|
cmd.Dir = r.WorkDir
|
|
|
|
return cmd
|
|
}
|
|
|
|
// CheckoutHead handles branch checkout.
|
|
func (r *Repository) CheckoutHead() *plugin_exec.Cmd {
|
|
args := []string{
|
|
"checkout",
|
|
"-qf",
|
|
r.Branch,
|
|
}
|
|
|
|
cmd := plugin_exec.Command(gitBin, args...)
|
|
cmd.Stdout = os.Stdout
|
|
cmd.Stderr = os.Stderr
|
|
cmd.Dir = r.WorkDir
|
|
|
|
return cmd
|
|
}
|