github.com/keysonzzz/kmg@v0.0.0-20151121023212-05317bfd7d39/kmg/SubCommand/gitCmd/GitSubmoduleInit.go (about)

     1  package gitCmd
     2  
     3  import (
     4  	"flag"
     5  	"fmt"
     6  	"github.com/bronze1man/kmg/kmgConsole"
     7  	"github.com/bronze1man/kmg/third/kmgGit"
     8  )
     9  
    10  // fake     //伪造submodule
    11  // add      //添加伪submodule
    12  // recover  //恢复伪submodule(可能要拉项目)
    13  // status
    14  func init() {
    15  	kmgConsole.AddAction(kmgConsole.Command{
    16  		Name:   "GitSubmoduleCommit",
    17  		Desc:   "git fake submodule Commit",
    18  		Runner: func() { kmgGit.DefaultRepository().MustFakeSubmoduleCommit() },
    19  	})
    20  	kmgConsole.AddAction(kmgConsole.Command{
    21  		Name:   "GitSubmoduleUpdate",
    22  		Desc:   "git fake submodule Update",
    23  		Runner: func() { kmgGit.DefaultRepository().MustFakeSubmoduleUpdate() },
    24  	})
    25  	kmgConsole.AddAction(kmgConsole.Command{
    26  		Name: "GitSmallestChange",
    27  		Runner: func() {
    28  			Local := ""
    29  			Target := ""
    30  			flag.StringVar(&Local, "local", "", "localcommit id (sha256 commit id or branch name or HEAD)")
    31  			flag.StringVar(&Target, "target", "", "targetCommit id (sha256 commit id or branch name or HEAD)")
    32  			flag.Parse()
    33  			if Local == "" || Target == "" {
    34  				flag.Usage()
    35  				return
    36  			}
    37  			result := kmgGit.DefaultRepository().MustSmallestChange(Local, Target)
    38  			fmt.Println(result)
    39  			fmt.Println("#see diff: git diff --stat " + Local + " " + result)
    40  		},
    41  	})
    42  }