hub/commands/submodule.go

44 строки
1.2 KiB
Go
Исходник Обычный вид История

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".`,
}
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
> 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
> 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
> 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 {
return
2013-07-13 12:19:42 +04:00
}
2013-12-17 04:35:51 +04:00
args.RemoveParam(idx)
transformCloneArgs(args)
2013-12-17 04:35:51 +04:00
args.InsertParam(idx, "add")
2013-07-13 12:19:42 +04:00
}