-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
submodule.go
43 lines (36 loc) · 1.17 KB
/
submodule.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
package commands
var cmdSubmodule = &Command{
Run: submodule,
GitExtension: true,
Usage: "submodule add [-p] OPTIONS [USER/]REPOSITORY DIRECTORY",
Short: "Initialize, update or inspect submodules",
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)
}
/**
$ hub submodule add jingweno/gh vendor/gh
> git submodule add git://github.com/jingweno/gh.git vendor/gh
$ hub submodule add -p jingweno/gh vendor/gh
> git submodule add git@github.com:jingweno/gh.git vendor/gh
$ 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
**/
func submodule(command *Command, args *Args) {
if !args.IsParamsEmpty() {
transformSubmoduleArgs(args)
}
}
func transformSubmoduleArgs(args *Args) {
var idx int
if idx = args.IndexOfParam("add"); idx == -1 {
return
}
args.RemoveParam(idx)
transformCloneArgs(args)
args.InsertParam(idx, "add")
}