17 Commits

Author SHA1 Message Date
021a8e521b feat(构建脚本): 更新构建脚本 2025-12-02 12:54:34 +08:00
835ce6ed56 chore(构建脚本): 添加latest 2025-11-29 19:35:44 +08:00
4d815a6e81 docs(更新文档): 更新文档 2025-11-27 16:43:27 +08:00
ae8060fc9e docs(更新文档): 更新文档 2025-11-27 16:41:52 +08:00
49e77c8325 docs(更新文档): 更新文档 2025-11-27 16:37:52 +08:00
ded2a32ce6 feat(构建迁移): 构建迁移 2025-11-27 16:35:26 +08:00
8c594faab7 chore(触发构建): 触发构建 2023-10-07 14:55:14 +08:00
945c08d9c3 feat(自动构建): 自动构建 2023-09-10 18:24:15 +08:00
1364c50b90 feat(调整脚本): 调整脚本 2023-07-12 13:28:36 +08:00
9743118378 feat(测试部署): 测试部署 2023-07-07 03:10:42 +08:00
d898a07ea9 feat(修正构建): 修正构建 2023-07-07 03:06:15 +08:00
5a879147b9 chore(构建脚本): 更新构建脚本 2023-07-07 02:52:03 +08:00
8aad2018ff feat(替换函数): 使用新函数替换废弃函数 2023-02-23 23:16:01 +08:00
85015449ca Merge pull request #4 from dmokel/main
feat(all): add support for signing commit (#2)
2023-02-23 23:11:15 +08:00
David Mokel
36dcaa56a5 feat(all): add support for signing commit (#2) 2023-02-23 21:40:18 +08:00
8e203b7689 feat(编译目标): 切换到go1.19,预编译二进制添加龙芯支持 2022-08-09 16:15:38 +08:00
8168b719fd style(代码风格): 调整风格 2022-03-10 14:05:13 +08:00
6 changed files with 61 additions and 41 deletions

View File

@@ -1,27 +0,0 @@
kind: pipeline
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: hkccr.ccs.tencentyun.com/xiaoqidun/goenv
commands:
- ./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

@@ -0,0 +1,28 @@
on: [push, workflow_dispatch]
jobs:
build:
runs-on: cn
steps:
- name: checkout
uses: actions/checkout@v6
- name: generate
uses: docker://ccr.ccs.tencentyun.com/xiaoqidun/build:latest
with:
args: -f build.sh -i gitcz.go -o release/gitcz
- name: docker goenv
uses: docker://ccr.ccs.tencentyun.com/xiaoqidun/goenv:latest
env:
GIT_SERVER: ${{ secrets.git_server }}
GIT_USER: ${{ secrets.git_user }}
GIT_TOKEN: ${{ secrets.git_token }}
with:
args: bash build.sh
- name: upload to cos
uses: xiaoqidun/gocos@main
with:
secret_id: ${{ secrets.cos_secret_id }}
secret_key: ${{ secrets.cos_secret_key }}
bucket_url: ${{ secrets.cos_bucket_url }}
source_path: release
target_path: product/gitcz
strip_prefix: release

2
.gitignore vendored
View File

@@ -1 +1,3 @@
.idea/ .idea/
.vscode/
.devcontainer/

View File

@@ -1,26 +1,40 @@
# gitcz # gitcz
Golang版本Git Commitizencommit规范工具
Go语言Git Commitizencommit规范工具
# 快速安装 # 快速安装
```
go install github.com/xiaoqidun/gitcz@latest go install github.com/xiaoqidun/gitcz@latest
```
# 编译安装 # 编译安装
``` ```
git clone https://github.com/xiaoqidun/gitcz.git git clone https://github.com/xiaoqidun/gitcz.git
cd gitcz cd gitcz
go build gitcz.go go build gitcz.go
``` ```
# 手动安装 # 手动安装
1. 根据系统架构下载为你编译好的[二进制文件](https://aite.xyz/product/gitcz/) 1. 根据系统架构下载为你编译好的[二进制文件](https://aite.xyz/product/gitcz/)
2. 将下载好的二进制文件重命名为gitcz并保留后缀 2. 将下载好的二进制文件重命名为 gitcz 并保留后缀
3. 把gitcz文件移动到系统PATH环境变量中的目录下 3. gitcz 文件移动到系统 PATH 环境变量中的目录下
4. windows外的系统需使用chmod命令赋予可执行权限 4. windows 外的系统需使用 chmod 命令赋予可执行权限
# 使用说明 # 使用说明
```shell script ```shell script
# 添加文件到本地仓库 # 添加文件到本地仓库
git add . git add .
# 使用-amend参数可覆盖最近一次提交信息等同于git commit --amend # 使用-amend参数可覆盖最近一次提交信息等同于git commit --amend
# 使用-S参数可进行签署commit操作等同于git commit -S
gitcz gitcz
# 推送文件到远程仓库 # 推送文件到远程仓库
git push git push
``` ```
# 规范文档 # 规范文档
gitcz使用[angular git commit规范](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines)
gitcz 使用 [angular git commit](https://github.com/angular/angular.js/blob/master/DEVELOPERS.md#-git-commit-guidelines) 规范

View File

@@ -5,7 +5,6 @@ import (
"bytes" "bytes"
"flag" "flag"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"os/exec" "os/exec"
"strconv" "strconv"
@@ -33,8 +32,8 @@ var (
InputScopePrompt = "说明本次提交的影响范围(必填): " InputScopePrompt = "说明本次提交的影响范围(必填): "
InputSubjectPrompt = "对本次提交进行简短描述(必填): " InputSubjectPrompt = "对本次提交进行简短描述(必填): "
InputBodyPrompt = "对本次提交进行完整描述(选填): " InputBodyPrompt = "对本次提交进行完整描述(选填): "
InputBreakingChangePrompt = "如果当前代码版本与上一版本不兼容,对变动、变动的理由及迁移的方法进行描述(选填): " InputBreakingChangePrompt = "如果当前代码版本与上一版本不兼容, 对变动、变动的理由及迁移的方法进行描述(选填): "
InputClosesPrompt = "如果本次提交针对某个issue,列出关闭的issues(选填): " InputClosesPrompt = "如果本次提交针对某个issue, 列出关闭的issues(选填): "
) )
var CzTypeList = []CzType{ var CzTypeList = []CzType{
@@ -78,6 +77,7 @@ func main() {
false, false,
"覆盖上次提交信息", "覆盖上次提交信息",
) )
sign := flag.Bool("S", false, "对commit进行签名")
author := flag.Bool( author := flag.Bool(
"author", "author",
false, false,
@@ -96,7 +96,7 @@ func main() {
czCommit.BreakingChange = InputBreakingChange() czCommit.BreakingChange = InputBreakingChange()
czCommit.Closes = InputCloses() czCommit.Closes = InputCloses()
commit := GenerateCommit(czCommit) commit := GenerateCommit(czCommit)
if err := GitCommit(commit, *amend); err != nil { if err := GitCommit(commit, *amend, *sign); err != nil {
fmt.Println(err) fmt.Println(err)
} }
} }
@@ -114,8 +114,8 @@ func NewLine() {
fmt.Println() fmt.Println()
} }
func GitCommit(commit string, amend bool) (err error) { func GitCommit(commit string, amend bool, sign bool) (err error) {
tempFile, err := ioutil.TempFile("", "git_commit_") tempFile, err := os.CreateTemp("", "git_commit_")
if err != nil { if err != nil {
return return
} }
@@ -130,6 +130,9 @@ func GitCommit(commit string, amend bool) (err error) {
if amend { if amend {
args = append(args, "--amend") args = append(args, "--amend")
} }
if sign {
args = append(args, "-S")
}
args = append(args, "-F", tempFile.Name()) args = append(args, "-F", tempFile.Name())
cmd := exec.Command("git", args...) cmd := exec.Command("git", args...)
result, err := cmd.CombinedOutput() result, err := cmd.CombinedOutput()
@@ -236,11 +239,11 @@ func GenerateCommit(czCommit *CzCommit) string {
commit += "\n\n" commit += "\n\n"
} }
if czCommit.BreakingChange != nil { if czCommit.BreakingChange != nil {
commit += ("BREAKING CHANGE: " + *czCommit.BreakingChange) commit += "BREAKING CHANGE: " + *czCommit.BreakingChange
commit += "\n\n" commit += "\n\n"
} }
if czCommit.Closes != nil { if czCommit.Closes != nil {
commit += ("Closes fix " + *czCommit.Closes) commit += "Closes fix " + *czCommit.Closes
} }
return commit return commit
} }

2
go.mod
View File

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