9 Commits

Author SHA1 Message Date
d36f61bc80 feat(合并提交): 合并提交,log改fmt减少依赖
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2022-03-10 09:50:10 +08:00
b45c7a8e32 Merge pull request #3 from dmokel/main
feat(all): body breakingChange
2022-03-10 09:40:31 +08:00
55c015a566 feat(all): body breakingChange
add body breakingchange closes
2022-03-10 00:31:37 +08:00
00b8e2c4b6 chore(调整构建): 调整构建
All checks were successful
continuous-integration/drone/push Build is passing
2021-09-22 10:19:24 +08:00
d4c9df855d docs(更新文档): 更新文档
All checks were successful
continuous-integration/drone/push Build is passing
continuous-integration/drone/tag Build is passing
2021-09-07 11:35:03 +08:00
10bffed6e5 fix(修正编译): 修正编译 2021-09-07 11:33:45 +08:00
23618d81ad fix(修正编译): 修正编译
Some checks failed
continuous-integration/drone/push Build is failing
2021-09-07 11:32:13 +08:00
bf37f8a281 feat(自动构建): 自动构建
Some checks reported errors
continuous-integration/drone/push Build encountered an error
continuous-integration/drone Build is failing
2021-09-07 11:25:20 +08:00
ce68380357 fix(更新文档): 更新文档 2021-09-07 11:08:40 +08:00
4 changed files with 86 additions and 20 deletions

View File

@ -3,8 +3,25 @@ type: docker
name: default
steps:
- name: generate
pull: if-not-exists
image: hkccr.ccs.tencentyun.com/xiaoqidun/build
commands:
- build -f build.sh -i gitcz.go -o release/gitcz
- name: build
pull: if-not-exists
image: golang:alpine
image: hkccr.ccs.tencentyun.com/xiaoqidun/goenv
commands:
- go build gitcz.go
- ./build.sh
- name: upload
image: hkccr.ccs.tencentyun.com/xiaoqidun/gocos
settings:
secret_id:
from_secret: cos_secret_id
secret_key:
from_secret: cos_secret_key
bucket_url:
from_secret: cos_bucket_url
source: release/
target: product/gitcz
strip_prefix: release/

View File

@ -1,7 +1,7 @@
# gitcz
Golang版本Git Commitizencommit规范工具
# 快速安装
go get -u github.com/xiaoqidun/gitcz
go install github.com/xiaoqidun/gitcz@latest
# 编译安装
```
git clone https://github.com/xiaoqidun/gitcz.git
@ -9,7 +9,7 @@ cd gitcz
go build gitcz.go
```
# 手动安装
1. 根据系统架构下载为你编译好的[二进制文件](https://github.com/xiaoqidun/gitcz/releases)
1. 根据系统架构下载为你编译好的[二进制文件](https://aite.xyz/product/gitcz/)
2. 将下载好的二进制文件重命名为gitcz并保留后缀
3. 把gitcz文件移动到系统PATH环境变量中的目录下
4. windows外的系统需使用chmod命令赋予可执行权限

View File

@ -6,7 +6,6 @@ import (
"flag"
"fmt"
"io/ioutil"
"log"
"os"
"os/exec"
"strconv"
@ -23,7 +22,8 @@ type CzCommit struct {
Scope *string
Subject *string
Body *string
Footer *string
BreakingChange *string
Closes *string
}
var StdinInput = bufio.NewReader(os.Stdin)
@ -32,6 +32,9 @@ var (
InputTypePrompt = "选择或输入一个提交类型(必填): "
InputScopePrompt = "说明本次提交的影响范围(必填): "
InputSubjectPrompt = "对本次提交进行简短描述(必填): "
InputBodyPrompt = "对本次提交进行完整描述(选填): "
InputBreakingChangePrompt = "如果当前代码版本与上一版本不兼容,对变动、变动的理由及迁移的方法进行描述(选填): "
InputClosesPrompt = "如果本次提交针对某个issue,列出关闭的issues(选填): "
)
var CzTypeList = []CzType{
@ -89,9 +92,12 @@ func main() {
czCommit.Type = InputType()
czCommit.Scope = InputScope()
czCommit.Subject = InputSubject()
czCommit.Body = InputBody()
czCommit.BreakingChange = InputBreakingChange()
czCommit.Closes = InputCloses()
commit := GenerateCommit(czCommit)
if err := GitCommit(commit, *amend); err != nil {
log.Println(err)
fmt.Println(err)
}
}
@ -154,6 +160,7 @@ func InputType() *CzType {
return &CzTypeList[i]
}
}
NewLine()
return InputType()
}
@ -165,6 +172,7 @@ func InputScope() *string {
NewLine()
return &text
}
NewLine()
return InputScope()
}
@ -176,22 +184,63 @@ func InputSubject() *string {
NewLine()
return &text
}
return InputScope()
NewLine()
return InputSubject()
}
func InputBody() *string {
fmt.Print(InputBodyPrompt)
text, _ := StdinInput.ReadString('\n')
text = strings.TrimSpace(text)
if text != "" {
NewLine()
return &text
}
NewLine()
return nil
}
func InputBreakingChange() *string {
fmt.Print(InputBreakingChangePrompt)
text, _ := StdinInput.ReadString('\n')
text = strings.TrimSpace(text)
if text != "" {
NewLine()
return &text
}
NewLine()
return nil
}
func InputCloses() *string {
fmt.Print(InputClosesPrompt)
text, _ := StdinInput.ReadString('\n')
text = strings.TrimSpace(text)
if text != "" {
NewLine()
return &text
}
NewLine()
return nil
}
func GenerateCommit(czCommit *CzCommit) string {
commit := fmt.Sprintf(
"%s(%s): %s\n",
"%s(%s): %s\n\n",
czCommit.Type.Type,
*czCommit.Scope,
*czCommit.Subject,
)
if czCommit.Body != nil {
commit += *czCommit.Body
commit += "\n\n"
}
commit += "\n"
if czCommit.Footer != nil {
commit += *czCommit.Footer
if czCommit.BreakingChange != nil {
commit += ("BREAKING CHANGE: " + *czCommit.BreakingChange)
commit += "\n\n"
}
if czCommit.Closes != nil {
commit += ("Closes fix " + *czCommit.Closes)
}
return commit
}

2
go.mod
View File

@ -1,3 +1,3 @@
module github.com/xiaoqidun/gitcz
go 1.15
go 1.18