0
0
mirror of https://github.com/thegeeklab/wp-git-action.git synced 2024-11-24 12:40:39 +00:00
wp-git-action/git/clone.go

36 lines
522 B
Go
Raw Normal View History

package git
import (
"fmt"
"os"
"os/exec"
)
// FetchSource fetches the source from remote.
func FetchSource(repo Repository) *exec.Cmd {
cmd := exec.Command(
"git",
"fetch",
"origin",
fmt.Sprintf("+%s:", repo.Branch),
)
cmd.Dir = repo.WorkDir
cmd.Stderr = os.Stderr
return cmd
}
// CheckoutHead handles branch checkout.
func CheckoutHead(repo Repository) *exec.Cmd {
cmd := exec.Command(
"git",
"checkout",
"-qf",
repo.Branch,
)
cmd.Dir = repo.WorkDir
cmd.Stderr = os.Stderr
return cmd
}