2023-02-08 09:16:10 +00:00
|
|
|
package git
|
|
|
|
|
|
|
|
import (
|
2024-05-05 20:14:55 +00:00
|
|
|
"github.com/thegeeklab/wp-plugin-go/v2/types"
|
2023-02-08 09:16:10 +00:00
|
|
|
"golang.org/x/sys/execabs"
|
|
|
|
)
|
|
|
|
|
2024-05-05 20:14:55 +00:00
|
|
|
// Init creates a new Git repository in the specified directory.
|
2024-05-06 18:29:57 +00:00
|
|
|
func (r *Repository) Init() *types.Cmd {
|
2024-05-06 06:52:25 +00:00
|
|
|
args := []string{
|
2023-02-08 09:16:10 +00:00
|
|
|
"init",
|
2024-05-06 06:52:25 +00:00
|
|
|
"-b",
|
2024-05-06 18:29:57 +00:00
|
|
|
r.Branch,
|
2024-05-06 06:52:25 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
cmd := execabs.Command(gitBin, args...)
|
2024-05-06 18:29:57 +00:00
|
|
|
cmd.Dir = r.WorkDir
|
2023-02-08 09:16:10 +00:00
|
|
|
|
2024-05-05 20:14:55 +00:00
|
|
|
return &types.Cmd{
|
|
|
|
Cmd: cmd,
|
|
|
|
}
|
2023-02-08 09:16:10 +00:00
|
|
|
}
|