Skip to content

Commit 55975fb

Browse files
author
mritd
committed
Merge branch 'develop' of github.com:mritd/gitflow-toolkit into develop
2 parents 9633401 + c3529d4 commit 55975fb

32 files changed

+109
-759
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,5 @@
1313
# Project-local glide cache, RE: https://github.com/Masterminds/glide/issues/736
1414
.glide/
1515
.idea
16+
17+
dist

README.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,26 @@
1-
# gitflow-toolkit
2-
gitflow-toolkit
1+
# GitFlow ToolKit
2+
3+
> 这是一个使用 go 编写的简单的 GitFlow 提交工具,用于规范 git commit 提交格式,目前仅支持 [Angular 社区规范](https://docs.google.com/document/d/1QrDFcIiPjSLDn3EL15IJygNPiHORgU1_OOAqWjiDU5Y/edit#heading=h.greljkmo14y0);同时该工具集成了一些扩展动作,比如快速创建指定名称前缀分支、命令行发起 GitLab MR 等
4+
5+
![example](imgs/example.gif)
6+
7+
## 支持命令
8+
9+
| 命令 | 描述 |
10+
| --- | --- |
11+
| ci | 交互式输入 `commit message` |
12+
| cm | 接受一个 `commit message` 字符串,并校验其格式(用作 commit hook) |
13+
| xmr | 交互式创建 GitLab MR,如果当前项目未配置,则首先配置项目信息 |
14+
| feat | 接受一个字符串,并创建一个 feat 分支,分支名称格式为 `feat/xxx` |
15+
| fix | 创建 fix 分支 |
16+
| hotfix | 创建 hotfix 分支(通常用于对 master 紧急修复) |
17+
| docs | 创建 docs 分支 |
18+
| style | 创建 style 分支 |
19+
| refactor | 创建 refactor 分支 |
20+
| chore | 创建 chore 分支 |
21+
| perf | 创建 perf 分支 |
22+
| style | 创建 style 分支 |
23+
24+
## 安装与卸载
25+
26+
下载对应二进制文件,执行 `sudo gitflow-toolkit install/uninstall` 即可

glide.lock

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

glide.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import:
33
- package: github.com/mritd/readline
44
version: ae245b60ddeb65cbbbe2b42da961f46d0b812f43
55
- package: github.com/mritd/promptx
6-
version: cd327e50600f1fc3e5ff14d047b127ad6a0c1fbd
6+
version: 986febf1a1c03a68067e2edc59123f9478c40345
77
- package: github.com/cpuguy83/go-md2man
88
version: 48d8747a2ca13185e7cc8efe6e9fc196a83f71a5
99
subpackages:

imgs/example.gif

297 KB
Loading

pkg/commit/ci.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func SelectCommitType() consts.CommitType {
4646
ActiveTpl: "» {{ .Type | cyan }} ({{ .ENDescription | cyan }})",
4747
InactiveTpl: " {{ .Type | white }} ({{ .ENDescription | white }})",
4848
SelectPrompt: "Commit Type",
49-
SelectedTpl: "{{ \"» Type:\" | green }} {{ .Type }}",
49+
SelectedTpl: "{{ \"» \" | green }}{{\"Type:\" | cyan }} {{ .Type }}",
5050
DisPlaySize: 9,
5151
DetailsTpl: `
5252
--------- Commit Type ----------

pkg/util/common.go

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ import (
1414
"github.com/mitchellh/go-homedir"
1515
)
1616

17+
const InstallBaseDir = "/usr/local/bin"
18+
1719
var GitFlowToolKitHome string
1820
var InstallPath string
1921
var HooksPath string
@@ -29,10 +31,10 @@ func init() {
2931
home, err := homedir.Dir()
3032
CheckAndExit(err)
3133

32-
GitFlowToolKitHome = home + string(filepath.Separator) + ".gitflow-toolkit"
33-
InstallPath = GitFlowToolKitHome + string(filepath.Separator) + "gitflow-toolkit"
34-
HooksPath = GitFlowToolKitHome + string(filepath.Separator) + "hooks"
35-
GitCMHookPath = HooksPath + string(filepath.Separator) + "commit-msg"
34+
GitFlowToolKitHome = home + "/.gitflow-toolkit"
35+
InstallPath = GitFlowToolKitHome + "/gitflow-toolkit"
36+
HooksPath = GitFlowToolKitHome + "/hooks"
37+
GitCMHookPath = HooksPath + "/commit-msg"
3638

3739
CurrentPath, err = exec.LookPath(os.Args[0])
3840
CheckAndExit(err)
@@ -45,18 +47,18 @@ func init() {
4547
func BinPaths() *[]string {
4648
return &[]string{
4749
GitCMHookPath,
48-
"/usr/local/bin/git-ci",
49-
"/usr/local/bin/git-feat",
50-
"/usr/local/bin/git-fix",
51-
"/usr/local/bin/git-docs",
52-
"/usr/local/bin/git-style",
53-
"/usr/local/bin/git-refactor",
54-
"/usr/local/bin/git-test",
55-
"/usr/local/bin/git-chore",
56-
"/usr/local/bin/git-perf",
57-
"/usr/local/bin/git-hotfix",
58-
"/usr/local/bin/git-xmr",
59-
"/usr/local/bin/git-xpr",
50+
InstallBaseDir + "/git-ci",
51+
InstallBaseDir + "/git-feat",
52+
InstallBaseDir + "/git-fix",
53+
InstallBaseDir + "/git-docs",
54+
InstallBaseDir + "/git-style",
55+
InstallBaseDir + "/git-refactor",
56+
InstallBaseDir + "/git-test",
57+
InstallBaseDir + "/git-chore",
58+
InstallBaseDir + "/git-perf",
59+
InstallBaseDir + "/git-hotfix",
60+
InstallBaseDir + "/git-xmr",
61+
InstallBaseDir + "/git-xpr",
6062
}
6163
}
6264

@@ -120,7 +122,10 @@ func OSEditInput() string {
120122

121123
f, err := ioutil.TempFile("", "gitflow-toolkit")
122124
CheckAndExit(err)
123-
defer os.Remove(f.Name())
125+
defer func() {
126+
f.Close()
127+
os.Remove(f.Name())
128+
}()
124129

125130
// write utf8 bom
126131
bom := []byte{0xef, 0xbb, 0xbf}

release.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
#!/bin/bash
2+
3+
if [ ! -n "$1" ]; then
4+
echo "Error:release version is blank!"
5+
exit 1
6+
fi
7+
8+
gox -osarch="darwin/amd64 linux/386 linux/amd64" -output="dist/{{.Dir}}_{{.OS}}_{{.Arch}}"
9+
ghr -u mritd -t $GITHUB_RELEASE_TOKEN -replace -recreate --debug $1 dist/

vendor/github.com/mritd/promptx/util/common.go

Lines changed: 0 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/github.com/xanzy/go-gitlab/.travis.yml

Lines changed: 2 additions & 17 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)