Skip to content

Commit 004cac9

Browse files
author
mritd
committed
feat(0.0.1): 增加分支创建命令
增加分支创建命令 Signed-off-by: mritd <[email protected]>
1 parent db46ee5 commit 004cac9

File tree

12 files changed

+392
-4
lines changed

12 files changed

+392
-4
lines changed

cmd/chore.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright © 2018 mritd <[email protected]>
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in
11+
// all copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
// THE SOFTWARE.
20+
21+
package cmd
22+
23+
import (
24+
"fmt"
25+
"os"
26+
27+
"github.com/mritd/gitflow-toolkit/pkg/consts"
28+
"github.com/mritd/gitflow-toolkit/pkg/util"
29+
"github.com/spf13/cobra"
30+
)
31+
32+
func NewChore() *cobra.Command {
33+
return &cobra.Command{
34+
Use: "chore",
35+
Short: "创建 chore 分支",
36+
Long: `
37+
创建一个以 chore 开头的分支`,
38+
Aliases: []string{"git-chore"},
39+
Run: func(cmd *cobra.Command, args []string) {
40+
if len(args) != 1 {
41+
fmt.Println("branch name is blank")
42+
os.Exit(1)
43+
}
44+
util.Checkout(consts.CHORE, args[0])
45+
},
46+
}
47+
}

cmd/docs.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright © 2018 mritd <[email protected]>
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in
11+
// all copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
// THE SOFTWARE.
20+
21+
package cmd
22+
23+
import (
24+
"fmt"
25+
"os"
26+
27+
"github.com/mritd/gitflow-toolkit/pkg/consts"
28+
"github.com/mritd/gitflow-toolkit/pkg/util"
29+
"github.com/spf13/cobra"
30+
)
31+
32+
func NewDocs() *cobra.Command {
33+
return &cobra.Command{
34+
Use: "docs",
35+
Short: "创建 docs 分支",
36+
Long: `
37+
创建一个以 docs 开头的分支`,
38+
Aliases: []string{"git-docs"},
39+
Run: func(cmd *cobra.Command, args []string) {
40+
if len(args) != 1 {
41+
fmt.Println("branch name is blank")
42+
os.Exit(1)
43+
}
44+
util.Checkout(consts.DOCS, args[0])
45+
},
46+
}
47+
}

cmd/feat.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright © 2018 mritd <[email protected]>
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in
11+
// all copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
// THE SOFTWARE.
20+
21+
package cmd
22+
23+
import (
24+
"fmt"
25+
"os"
26+
27+
"github.com/mritd/gitflow-toolkit/pkg/consts"
28+
"github.com/mritd/gitflow-toolkit/pkg/util"
29+
"github.com/spf13/cobra"
30+
)
31+
32+
func NewFeat() *cobra.Command {
33+
return &cobra.Command{
34+
Use: "feat",
35+
Short: "创建 feat 分支",
36+
Long: `
37+
创建一个以 feat 开头的分支`,
38+
Aliases: []string{"git-feat"},
39+
Run: func(cmd *cobra.Command, args []string) {
40+
if len(args) != 1 {
41+
fmt.Println("branch name is blank")
42+
os.Exit(1)
43+
}
44+
util.Checkout(consts.FEAT, args[0])
45+
},
46+
}
47+
}

cmd/fix.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright © 2018 mritd <[email protected]>
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in
11+
// all copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
// THE SOFTWARE.
20+
21+
package cmd
22+
23+
import (
24+
"fmt"
25+
"os"
26+
27+
"github.com/mritd/gitflow-toolkit/pkg/consts"
28+
"github.com/mritd/gitflow-toolkit/pkg/util"
29+
"github.com/spf13/cobra"
30+
)
31+
32+
func NewFix() *cobra.Command {
33+
return &cobra.Command{
34+
Use: "fix",
35+
Short: "创建 fix 分支",
36+
Long: `
37+
创建一个以 fix 开头的分支`,
38+
Aliases: []string{"git-fix"},
39+
Run: func(cmd *cobra.Command, args []string) {
40+
if len(args) != 1 {
41+
fmt.Println("branch name is blank")
42+
os.Exit(1)
43+
}
44+
util.Checkout(consts.FIX, args[0])
45+
},
46+
}
47+
}

cmd/perf.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright © 2018 mritd <[email protected]>
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in
11+
// all copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
// THE SOFTWARE.
20+
21+
package cmd
22+
23+
import (
24+
"fmt"
25+
"os"
26+
27+
"github.com/mritd/gitflow-toolkit/pkg/consts"
28+
"github.com/mritd/gitflow-toolkit/pkg/util"
29+
"github.com/spf13/cobra"
30+
)
31+
32+
func NewPerf() *cobra.Command {
33+
return &cobra.Command{
34+
Use: "perf",
35+
Short: "创建 perf 分支",
36+
Long: `
37+
创建一个以 perf 开头的分支`,
38+
Aliases: []string{"git-perf"},
39+
Run: func(cmd *cobra.Command, args []string) {
40+
if len(args) != 1 {
41+
fmt.Println("branch name is blank")
42+
os.Exit(1)
43+
}
44+
util.Checkout(consts.PERF, args[0])
45+
},
46+
}
47+
}

cmd/refactor.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright © 2018 mritd <[email protected]>
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in
11+
// all copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
// THE SOFTWARE.
20+
21+
package cmd
22+
23+
import (
24+
"fmt"
25+
"os"
26+
27+
"github.com/mritd/gitflow-toolkit/pkg/consts"
28+
"github.com/mritd/gitflow-toolkit/pkg/util"
29+
"github.com/spf13/cobra"
30+
)
31+
32+
func NewRefactor() *cobra.Command {
33+
return &cobra.Command{
34+
Use: "refactor",
35+
Short: "创建 refactor 分支",
36+
Long: `
37+
创建一个以 refactor 开头的分支`,
38+
Aliases: []string{"git-refactor"},
39+
Run: func(cmd *cobra.Command, args []string) {
40+
if len(args) != 1 {
41+
fmt.Println("branch name is blank")
42+
os.Exit(1)
43+
}
44+
util.Checkout(consts.REFACTOR, args[0])
45+
},
46+
}
47+
}

cmd/root.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,15 @@ func init() {
5050
// add sub cmd
5151
RootCmd.AddCommand(NewCi())
5252
RootCmd.AddCommand(NewCm())
53-
RootCmd.AddCommand(NewMr())
53+
RootCmd.AddCommand(NewXMr())
54+
RootCmd.AddCommand(NewFeat())
55+
RootCmd.AddCommand(NewFix())
56+
RootCmd.AddCommand(NewDocs())
57+
RootCmd.AddCommand(NewStyle())
58+
RootCmd.AddCommand(NewRefactor())
59+
RootCmd.AddCommand(NewPerf())
60+
RootCmd.AddCommand(NewTest())
61+
RootCmd.AddCommand(NewChore())
5462
RootCmd.AddCommand(NewInstall())
5563
RootCmd.AddCommand(NewUninstall())
5664
}

cmd/style.go

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
// Copyright © 2018 mritd <[email protected]>
2+
//
3+
// Permission is hereby granted, free of charge, to any person obtaining a copy
4+
// of this software and associated documentation files (the "Software"), to deal
5+
// in the Software without restriction, including without limitation the rights
6+
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7+
// copies of the Software, and to permit persons to whom the Software is
8+
// furnished to do so, subject to the following conditions:
9+
//
10+
// The above copyright notice and this permission notice shall be included in
11+
// all copies or substantial portions of the Software.
12+
//
13+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15+
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16+
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17+
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18+
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19+
// THE SOFTWARE.
20+
21+
package cmd
22+
23+
import (
24+
"fmt"
25+
"os"
26+
27+
"github.com/mritd/gitflow-toolkit/pkg/consts"
28+
"github.com/mritd/gitflow-toolkit/pkg/util"
29+
"github.com/spf13/cobra"
30+
)
31+
32+
func NewStyle() *cobra.Command {
33+
return &cobra.Command{
34+
Use: "style",
35+
Short: "创建 style 分支",
36+
Long: `
37+
创建一个以 style 开头的分支`,
38+
Aliases: []string{"git-style"},
39+
Run: func(cmd *cobra.Command, args []string) {
40+
if len(args) != 1 {
41+
fmt.Println("branch name is blank")
42+
os.Exit(1)
43+
}
44+
util.Checkout(consts.STYLE, args[0])
45+
},
46+
}
47+
}

cmd/xmr.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import (
2626
"github.com/spf13/cobra"
2727
)
2828

29-
func NewMr() *cobra.Command {
29+
func NewXMr() *cobra.Command {
3030
return &cobra.Command{
3131
Use: "xmr",
3232
Short: "发起 Merge Request",
@@ -42,7 +42,7 @@ func NewMr() *cobra.Command {
4242
repo.SaveRepository()
4343
}
4444

45-
repo.Mr()
45+
repo.XMr()
4646
},
4747
}
4848
}

0 commit comments

Comments
 (0)