2013-07-13 12:19:42 +04:00
|
|
|
package commands
|
|
|
|
|
|
|
|
var cmdSubmodule = &Command{
|
2013-07-20 10:00:45 +04:00
|
|
|
Run: submodule,
|
2013-07-13 12:19:42 +04:00
|
|
|
GitExtension: true,
|
2013-07-20 10:00:45 +04:00
|
|
|
Usage: "submodule add [-p] OPTIONS [USER/]REPOSITORY DIRECTORY",
|
|
|
|
Short: "Initialize, update or inspect submodules",
|
2013-07-13 12:19:42 +04:00
|
|
|
Long: `Submodule repository "git://github.com/USER/REPOSITORY.git" into
|
|
|
|
DIRECTORY as with git-submodule(1). When USER/ is omitted,
|
|
|
|
assumes your GitHub login. With -p, use private remote
|
|
|
|
"git@github.com:USER/REPOSITORY.git".`,
|
|
|
|
}
|
|
|
|
|
2013-12-30 02:18:14 +04:00
|
|
|
func init() {
|
|
|
|
CmdRunner.Use(cmdSubmodule)
|
|
|
|
}
|
|
|
|
|
2013-07-13 12:19:42 +04:00
|
|
|
/**
|
2016-01-19 21:31:47 +03:00
|
|
|
$ hub submodule add jingweno/gh vendor/gh
|
2013-07-20 18:31:12 +04:00
|
|
|
> git submodule add git://github.com/jingweno/gh.git vendor/gh
|
2013-07-13 12:19:42 +04:00
|
|
|
|
2016-01-19 21:31:47 +03:00
|
|
|
$ hub submodule add -p jingweno/gh vendor/gh
|
2013-07-20 18:31:12 +04:00
|
|
|
> git submodule add git@github.com:jingweno/gh.git vendor/gh
|
2013-07-13 12:19:42 +04:00
|
|
|
|
2016-01-19 21:31:47 +03:00
|
|
|
$ hub submodule add -b gh --name gh jingweno/gh vendor/gh
|
2013-07-20 18:31:12 +04:00
|
|
|
> git submodule add -b gh --name gh git://github.com/jingweno/gh.git vendor/gh
|
2013-07-13 12:19:42 +04:00
|
|
|
**/
|
|
|
|
|
|
|
|
func submodule(command *Command, args *Args) {
|
|
|
|
if !args.IsParamsEmpty() {
|
|
|
|
transformSubmoduleArgs(args)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func transformSubmoduleArgs(args *Args) {
|
2013-12-17 04:35:51 +04:00
|
|
|
var idx int
|
|
|
|
if idx = args.IndexOfParam("add"); idx == -1 {
|
2013-07-20 18:31:12 +04:00
|
|
|
return
|
2013-07-13 12:19:42 +04:00
|
|
|
}
|
2013-12-17 04:35:51 +04:00
|
|
|
args.RemoveParam(idx)
|
2013-07-20 18:31:12 +04:00
|
|
|
transformCloneArgs(args)
|
2013-12-17 04:35:51 +04:00
|
|
|
args.InsertParam(idx, "add")
|
2013-07-13 12:19:42 +04:00
|
|
|
}
|