@@ -55,8 +55,9 @@ func ApiCommand(c *cli.Context) error {
|
|||||||
|
|
||||||
home := c.String("home")
|
home := c.String("home")
|
||||||
remote := c.String("remote")
|
remote := c.String("remote")
|
||||||
|
branch := c.String("branch")
|
||||||
if len(remote) > 0 {
|
if len(remote) > 0 {
|
||||||
repo, _ := util.CloneIntoGitHome(remote)
|
repo, _ := util.CloneIntoGitHome(remote, branch)
|
||||||
if len(repo) > 0 {
|
if len(repo) > 0 {
|
||||||
home = repo
|
home = repo
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,9 @@ func GoCommand(c *cli.Context) error {
|
|||||||
namingStyle := c.String("style")
|
namingStyle := c.String("style")
|
||||||
home := c.String("home")
|
home := c.String("home")
|
||||||
remote := c.String("remote")
|
remote := c.String("remote")
|
||||||
|
branch := c.String("branch")
|
||||||
if len(remote) > 0 {
|
if len(remote) > 0 {
|
||||||
repo, _ := util.CloneIntoGitHome(remote)
|
repo, _ := util.CloneIntoGitHome(remote, branch)
|
||||||
if len(repo) > 0 {
|
if len(repo) > 0 {
|
||||||
home = repo
|
home = repo
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -67,8 +67,9 @@ func CreateServiceCommand(c *cli.Context) error {
|
|||||||
|
|
||||||
home := c.String("home")
|
home := c.String("home")
|
||||||
remote := c.String("remote")
|
remote := c.String("remote")
|
||||||
|
branch := c.String("branch")
|
||||||
if len(remote) > 0 {
|
if len(remote) > 0 {
|
||||||
repo, _ := util.CloneIntoGitHome(remote)
|
repo, _ := util.CloneIntoGitHome(remote, branch)
|
||||||
if len(repo) > 0 {
|
if len(repo) > 0 {
|
||||||
home = repo
|
home = repo
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -46,8 +46,9 @@ func DockerCommand(c *cli.Context) (err error) {
|
|||||||
home := c.String("home")
|
home := c.String("home")
|
||||||
version := c.String("version")
|
version := c.String("version")
|
||||||
remote := c.String("remote")
|
remote := c.String("remote")
|
||||||
|
branch := c.String("branch")
|
||||||
if len(remote) > 0 {
|
if len(remote) > 0 {
|
||||||
repo, _ := util.CloneIntoGitHome(remote)
|
repo, _ := util.CloneIntoGitHome(remote, branch)
|
||||||
if len(repo) > 0 {
|
if len(repo) > 0 {
|
||||||
home = repo
|
home = repo
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -111,6 +111,10 @@ var commands = []cli.Command{
|
|||||||
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
||||||
"https://github.com/zeromicro/go-zero-template directory structure",
|
"https://github.com/zeromicro/go-zero-template directory structure",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "branch",
|
||||||
|
Usage: "the branch of the remote repo, it does work with --remote",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: apigen.ApiCommand,
|
Action: apigen.ApiCommand,
|
||||||
Subcommands: []cli.Command{
|
Subcommands: []cli.Command{
|
||||||
@@ -130,6 +134,10 @@ var commands = []cli.Command{
|
|||||||
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
||||||
"https://github.com/zeromicro/go-zero-template directory structure",
|
"https://github.com/zeromicro/go-zero-template directory structure",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "branch",
|
||||||
|
Usage: "the branch of the remote repo, it does work with --remote",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "style",
|
Name: "style",
|
||||||
Usage: "the file naming format, see [https://github.com/zeromicro/go-zero/blob/master/tools/goctl/config/readme.md]",
|
Usage: "the file naming format, see [https://github.com/zeromicro/go-zero/blob/master/tools/goctl/config/readme.md]",
|
||||||
@@ -209,6 +217,10 @@ var commands = []cli.Command{
|
|||||||
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
||||||
"https://github.com/zeromicro/go-zero-template directory structure",
|
"https://github.com/zeromicro/go-zero-template directory structure",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "branch",
|
||||||
|
Usage: "the branch of the remote repo, it does work with --remote",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: gogen.GoCommand,
|
Action: gogen.GoCommand,
|
||||||
},
|
},
|
||||||
@@ -345,6 +357,10 @@ var commands = []cli.Command{
|
|||||||
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
||||||
"https://github.com/zeromicro/go-zero-template directory structure",
|
"https://github.com/zeromicro/go-zero-template directory structure",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "branch",
|
||||||
|
Usage: "the branch of the remote repo, it does work with --remote",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "version",
|
Name: "version",
|
||||||
Usage: "the goctl builder golang image version",
|
Usage: "the goctl builder golang image version",
|
||||||
@@ -445,6 +461,10 @@ var commands = []cli.Command{
|
|||||||
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
||||||
"https://github.com/zeromicro/go-zero-template directory structure",
|
"https://github.com/zeromicro/go-zero-template directory structure",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "branch",
|
||||||
|
Usage: "the branch of the remote repo, it does work with --remote",
|
||||||
|
},
|
||||||
cli.StringFlag{
|
cli.StringFlag{
|
||||||
Name: "serviceAccount",
|
Name: "serviceAccount",
|
||||||
Usage: "the ServiceAccount for the deployment",
|
Usage: "the ServiceAccount for the deployment",
|
||||||
@@ -482,6 +502,10 @@ var commands = []cli.Command{
|
|||||||
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
||||||
"https://github.com/zeromicro/go-zero-template directory structure",
|
"https://github.com/zeromicro/go-zero-template directory structure",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "branch",
|
||||||
|
Usage: "the branch of the remote repo, it does work with --remote",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: rpc.RPCNew,
|
Action: rpc.RPCNew,
|
||||||
},
|
},
|
||||||
@@ -504,6 +528,10 @@ var commands = []cli.Command{
|
|||||||
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
||||||
"https://github.com/zeromicro/go-zero-template directory structure",
|
"https://github.com/zeromicro/go-zero-template directory structure",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "branch",
|
||||||
|
Usage: "the branch of the remote repo, it does work with --remote",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: rpc.RPCTemplate,
|
Action: rpc.RPCTemplate,
|
||||||
},
|
},
|
||||||
@@ -548,6 +576,10 @@ var commands = []cli.Command{
|
|||||||
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
||||||
"https://github.com/zeromicro/go-zero-template directory structure",
|
"https://github.com/zeromicro/go-zero-template directory structure",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "branch",
|
||||||
|
Usage: "the branch of the remote repo, it does work with --remote",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -590,6 +622,10 @@ var commands = []cli.Command{
|
|||||||
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
||||||
"https://github.com/zeromicro/go-zero-template directory structure",
|
"https://github.com/zeromicro/go-zero-template directory structure",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "branch",
|
||||||
|
Usage: "the branch of the remote repo, it does work with --remote",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: rpc.RPC,
|
Action: rpc.RPC,
|
||||||
},
|
},
|
||||||
@@ -642,6 +678,10 @@ var commands = []cli.Command{
|
|||||||
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
||||||
"https://github.com/zeromicro/go-zero-template directory structure",
|
"https://github.com/zeromicro/go-zero-template directory structure",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "branch",
|
||||||
|
Usage: "the branch of the remote repo, it does work with --remote",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: model.MysqlDDL,
|
Action: model.MysqlDDL,
|
||||||
},
|
},
|
||||||
@@ -684,6 +724,10 @@ var commands = []cli.Command{
|
|||||||
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
||||||
"https://github.com/zeromicro/go-zero-template directory structure",
|
"https://github.com/zeromicro/go-zero-template directory structure",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "branch",
|
||||||
|
Usage: "the branch of the remote repo, it does work with --remote",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: model.MySqlDataSource,
|
Action: model.MySqlDataSource,
|
||||||
},
|
},
|
||||||
@@ -736,6 +780,10 @@ var commands = []cli.Command{
|
|||||||
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
||||||
"https://github.com/zeromicro/go-zero-template directory structure",
|
"https://github.com/zeromicro/go-zero-template directory structure",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "branch",
|
||||||
|
Usage: "the branch of the remote repo, it does work with --remote",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: model.PostgreSqlDataSource,
|
Action: model.PostgreSqlDataSource,
|
||||||
},
|
},
|
||||||
@@ -772,6 +820,10 @@ var commands = []cli.Command{
|
|||||||
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
"if they are, --remote has higher priority\n\tThe git repo directory must be consistent with the " +
|
||||||
"https://github.com/zeromicro/go-zero-template directory structure",
|
"https://github.com/zeromicro/go-zero-template directory structure",
|
||||||
},
|
},
|
||||||
|
cli.StringFlag{
|
||||||
|
Name: "branch",
|
||||||
|
Usage: "the branch of the remote repo, it does work with --remote",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
Action: mongo.Action,
|
Action: mongo.Action,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -44,8 +44,9 @@ func DeploymentCommand(c *cli.Context) error {
|
|||||||
nodePort := c.Int("nodePort")
|
nodePort := c.Int("nodePort")
|
||||||
home := c.String("home")
|
home := c.String("home")
|
||||||
remote := c.String("remote")
|
remote := c.String("remote")
|
||||||
|
branch := c.String("branch")
|
||||||
if len(remote) > 0 {
|
if len(remote) > 0 {
|
||||||
repo, _ := util.CloneIntoGitHome(remote)
|
repo, _ := util.CloneIntoGitHome(remote, branch)
|
||||||
if len(repo) > 0 {
|
if len(repo) > 0 {
|
||||||
home = repo
|
home = repo
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,8 +20,9 @@ func Action(ctx *cli.Context) error {
|
|||||||
s := ctx.String("style")
|
s := ctx.String("style")
|
||||||
home := ctx.String("home")
|
home := ctx.String("home")
|
||||||
remote := ctx.String("remote")
|
remote := ctx.String("remote")
|
||||||
|
branch := ctx.String("branch")
|
||||||
if len(remote) > 0 {
|
if len(remote) > 0 {
|
||||||
repo, _ := file.CloneIntoGitHome(remote)
|
repo, _ := file.CloneIntoGitHome(remote, branch)
|
||||||
if len(repo) > 0 {
|
if len(repo) > 0 {
|
||||||
home = repo
|
home = repo
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,8 @@ const (
|
|||||||
flagDatabase = "database"
|
flagDatabase = "database"
|
||||||
flagSchema = "schema"
|
flagSchema = "schema"
|
||||||
flagHome = "home"
|
flagHome = "home"
|
||||||
|
flagRemote = "remote"
|
||||||
|
flagBranch = "branch"
|
||||||
)
|
)
|
||||||
|
|
||||||
var errNotMatched = errors.New("sql not matched")
|
var errNotMatched = errors.New("sql not matched")
|
||||||
@@ -43,9 +45,10 @@ func MysqlDDL(ctx *cli.Context) error {
|
|||||||
style := ctx.String(flagStyle)
|
style := ctx.String(flagStyle)
|
||||||
database := ctx.String(flagDatabase)
|
database := ctx.String(flagDatabase)
|
||||||
home := ctx.String(flagHome)
|
home := ctx.String(flagHome)
|
||||||
remote := ctx.String("remote")
|
remote := ctx.String(flagRemote)
|
||||||
|
branch := ctx.String(flagBranch)
|
||||||
if len(remote) > 0 {
|
if len(remote) > 0 {
|
||||||
repo, _ := file.CloneIntoGitHome(remote)
|
repo, _ := file.CloneIntoGitHome(remote, branch)
|
||||||
if len(repo) > 0 {
|
if len(repo) > 0 {
|
||||||
home = repo
|
home = repo
|
||||||
}
|
}
|
||||||
@@ -68,10 +71,11 @@ func MySqlDataSource(ctx *cli.Context) error {
|
|||||||
cache := ctx.Bool(flagCache)
|
cache := ctx.Bool(flagCache)
|
||||||
idea := ctx.Bool(flagIdea)
|
idea := ctx.Bool(flagIdea)
|
||||||
style := ctx.String(flagStyle)
|
style := ctx.String(flagStyle)
|
||||||
home := ctx.String("home")
|
home := ctx.String(flagHome)
|
||||||
remote := ctx.String("remote")
|
remote := ctx.String(flagRemote)
|
||||||
|
branch := ctx.String(flagBranch)
|
||||||
if len(remote) > 0 {
|
if len(remote) > 0 {
|
||||||
repo, _ := file.CloneIntoGitHome(remote)
|
repo, _ := file.CloneIntoGitHome(remote, branch)
|
||||||
if len(repo) > 0 {
|
if len(repo) > 0 {
|
||||||
home = repo
|
home = repo
|
||||||
}
|
}
|
||||||
@@ -97,10 +101,11 @@ func PostgreSqlDataSource(ctx *cli.Context) error {
|
|||||||
idea := ctx.Bool(flagIdea)
|
idea := ctx.Bool(flagIdea)
|
||||||
style := ctx.String(flagStyle)
|
style := ctx.String(flagStyle)
|
||||||
schema := ctx.String(flagSchema)
|
schema := ctx.String(flagSchema)
|
||||||
home := ctx.String("home")
|
home := ctx.String(flagHome)
|
||||||
remote := ctx.String("remote")
|
remote := ctx.String(flagRemote)
|
||||||
|
branch := ctx.String(flagBranch)
|
||||||
if len(remote) > 0 {
|
if len(remote) > 0 {
|
||||||
repo, _ := file.CloneIntoGitHome(remote)
|
repo, _ := file.CloneIntoGitHome(remote, branch)
|
||||||
if len(repo) > 0 {
|
if len(repo) > 0 {
|
||||||
home = repo
|
home = repo
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -33,8 +33,9 @@ func RPC(c *cli.Context) error {
|
|||||||
goOptions := c.StringSlice("go_opt")
|
goOptions := c.StringSlice("go_opt")
|
||||||
home := c.String("home")
|
home := c.String("home")
|
||||||
remote := c.String("remote")
|
remote := c.String("remote")
|
||||||
|
branch := c.String("branch")
|
||||||
if len(remote) > 0 {
|
if len(remote) > 0 {
|
||||||
repo, _ := util.CloneIntoGitHome(remote)
|
repo, _ := util.CloneIntoGitHome(remote, branch)
|
||||||
if len(repo) > 0 {
|
if len(repo) > 0 {
|
||||||
home = repo
|
home = repo
|
||||||
}
|
}
|
||||||
@@ -89,8 +90,9 @@ func RPCNew(c *cli.Context) error {
|
|||||||
style := c.String("style")
|
style := c.String("style")
|
||||||
home := c.String("home")
|
home := c.String("home")
|
||||||
remote := c.String("remote")
|
remote := c.String("remote")
|
||||||
|
branch := c.String("branch")
|
||||||
if len(remote) > 0 {
|
if len(remote) > 0 {
|
||||||
repo, _ := util.CloneIntoGitHome(remote)
|
repo, _ := util.CloneIntoGitHome(remote, branch)
|
||||||
if len(repo) > 0 {
|
if len(repo) > 0 {
|
||||||
home = repo
|
home = repo
|
||||||
}
|
}
|
||||||
@@ -124,8 +126,9 @@ func RPCTemplate(c *cli.Context) error {
|
|||||||
protoFile := c.String("o")
|
protoFile := c.String("o")
|
||||||
home := c.String("home")
|
home := c.String("home")
|
||||||
remote := c.String("remote")
|
remote := c.String("remote")
|
||||||
|
branch := c.String("branch")
|
||||||
if len(remote) > 0 {
|
if len(remote) > 0 {
|
||||||
repo, _ := util.CloneIntoGitHome(remote)
|
repo, _ := util.CloneIntoGitHome(remote, branch)
|
||||||
if len(repo) > 0 {
|
if len(repo) > 0 {
|
||||||
home = repo
|
home = repo
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -54,8 +54,9 @@ func ZRPC(c *cli.Context) error {
|
|||||||
style := c.String("style")
|
style := c.String("style")
|
||||||
home := c.String("home")
|
home := c.String("home")
|
||||||
remote := c.String("remote")
|
remote := c.String("remote")
|
||||||
|
branch := c.String("branch")
|
||||||
if len(remote) > 0 {
|
if len(remote) > 0 {
|
||||||
repo, _ := util.CloneIntoGitHome(remote)
|
repo, _ := util.CloneIntoGitHome(remote, branch)
|
||||||
if len(repo) > 0 {
|
if len(repo) > 0 {
|
||||||
home = repo
|
home = repo
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ import (
|
|||||||
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
|
"github.com/zeromicro/go-zero/tools/goctl/util/pathx"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CloneIntoGitHome(url string) (dir string, err error) {
|
func CloneIntoGitHome(url string, branch string) (dir string, err error) {
|
||||||
gitHome, err := pathx.GetGitHome()
|
gitHome, err := pathx.GetGitHome()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -21,6 +21,9 @@ func CloneIntoGitHome(url string) (dir string, err error) {
|
|||||||
ext := filepath.Ext(url)
|
ext := filepath.Ext(url)
|
||||||
repo := strings.TrimSuffix(filepath.Base(url), ext)
|
repo := strings.TrimSuffix(filepath.Base(url), ext)
|
||||||
dir = filepath.Join(gitHome, repo)
|
dir = filepath.Join(gitHome, repo)
|
||||||
|
if pathx.FileExists(dir) {
|
||||||
|
os.RemoveAll(dir)
|
||||||
|
}
|
||||||
path, err := env.LookPath("git")
|
path, err := env.LookPath("git")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return "", err
|
return "", err
|
||||||
@@ -28,7 +31,12 @@ func CloneIntoGitHome(url string) (dir string, err error) {
|
|||||||
if !env.CanExec() {
|
if !env.CanExec() {
|
||||||
return "", fmt.Errorf("os %q can not call 'exec' command", runtime.GOOS)
|
return "", fmt.Errorf("os %q can not call 'exec' command", runtime.GOOS)
|
||||||
}
|
}
|
||||||
cmd := exec.Command(path, "clone", url, dir)
|
args := []string{"clone"}
|
||||||
|
if len(branch) > 0 {
|
||||||
|
args = append(args, "-b", branch)
|
||||||
|
}
|
||||||
|
args = append(args, url, dir)
|
||||||
|
cmd := exec.Command(path, args...)
|
||||||
cmd.Env = os.Environ()
|
cmd.Env = os.Environ()
|
||||||
cmd.Stdout = os.Stdout
|
cmd.Stdout = os.Stdout
|
||||||
cmd.Stderr = os.Stderr
|
cmd.Stderr = os.Stderr
|
||||||
|
|||||||
Reference in New Issue
Block a user