Skip to content

Commit c09b492

Browse files
committed
Improve gitgo with comprehensive comments and documentation enhancements
- Add detailed English/Chinese comments to new_git.go core implementation - Add English/Chinese comments to gcm.go Git operation methods - Add English/Chinese comments to git_up.go Git info fetch functions - Improve utils.go with complete English/Chinese documentation - Add comprehensive test function comments to each test file - Update README.md and README.zh.md with related project links (gitgo ↔ gogit) - Optimize README wording with improved naming (Repo abbreviation) - Update Go version badge from 1.25+ to 1.22--1.25 matching go.mod requirements - Add 1.25.x to GitHub Actions test matrix in release.yml - Update dependencies in go.mod and go.sum - Enhance test coverage in git_up_test.go with edge cases
1 parent 4e35911 commit c09b492

File tree

13 files changed

+533
-375
lines changed

13 files changed

+533
-375
lines changed

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
runs-on: ubuntu-latest
2828
strategy:
2929
matrix:
30-
go: [ "1.22.x", "1.23.x", "1.24.x", "stable" ]
30+
go: [ "1.22.x", "1.23.x", "1.24.x", "1.25.x", "stable" ]
3131
steps:
3232
- uses: actions/checkout@v4
3333

README.md

Lines changed: 48 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/go-xlan/gitgo/release.yml?branch=main&label=BUILD)](https://github.com/go-xlan/gitgo/actions/workflows/release.yml?query=branch%3Amain)
22
[![GoDoc](https://pkg.go.dev/badge/github.com/go-xlan/gitgo)](https://pkg.go.dev/github.com/go-xlan/gitgo)
33
[![Coverage Status](https://img.shields.io/coveralls/github/go-xlan/gitgo/main.svg)](https://coveralls.io/github/go-xlan/gitgo?branch=main)
4-
[![Supported Go Versions](https://img.shields.io/badge/Go-1.22--1.25-lightgrey.svg)](https://go.dev/)
4+
[![Supported Go Versions](https://img.shields.io/badge/Go-1.22--1.25-lightgrey.svg)](https://github.com/go-xlan/gitgo)
55
[![GitHub Release](https://img.shields.io/github/release/go-xlan/gitgo.svg)](https://github.com/go-xlan/gitgo/releases)
66
[![Go Report Card](https://goreportcard.com/badge/github.com/go-xlan/gitgo)](https://goreportcard.com/report/github.com/go-xlan/gitgo)
77

@@ -19,11 +19,16 @@ Streamlined Git command execution engine with fluent chaining interface and comp
1919

2020
## Main Features
2121

22-
🔗 **Fluent Chaining Interface**: Method chaining for complex Git workflows with automatic error propagation
23-
**Comprehensive Git Operations**: Full coverage of Git commands including commit, push, pull, and branch management
24-
🔍 **Smart State Detection**: Intelligent checking for staged/unstaged changes, clean working trees, and repository status
25-
🎯 **Error Handling**: Robust error propagation with detailed context and debug information
26-
📋 **Repository Querying**: Advanced repository introspection with branch, commit, and status information
22+
🔗 **Fluent Chaining Interface**: Method chaining with complex Git workflows and automatic issue propagation
23+
**Comprehensive Git Operations**: Complete Git commands coverage including commit, push, fetch, and branch management
24+
🔍 **Smart State Detection**: Intelligent checking on staged and unstaged changes, clean working trees, and repo status
25+
🎯 **Issue Handling**: Robust issue propagation with detailed context and debug information
26+
📋 **Repo Querying**: Advanced repo introspection with branch, commit, and status information
27+
28+
## Related Projects
29+
30+
- **[gogit](https://github.com/go-xlan/gogit)** - Enhanced Git operations toolkit with go-git foundation, providing pure Go implementation without CLI dependencies
31+
- **[gitgo](https://github.com/go-xlan/gitgo)** (this project) - Streamlined Git command execution engine with fluent chaining interface
2732

2833
## Installation
2934

@@ -70,7 +75,7 @@ func main() {
7075

7176
⬆️ **Source:** [Source](internal/demos/demo1x/main.go)
7277

73-
### Repository State Detection
78+
### Repo State Detection
7479

7580
```go
7681
package main
@@ -116,7 +121,7 @@ func main() {
116121

117122
⬆️ **Source:** [Source](internal/demos/demo2x/main.go)
118123

119-
### Tags and Repository Information
124+
### Tags and Repo Information
120125

121126
```go
122127
package main
@@ -161,42 +166,41 @@ func main() {
161166

162167
⬆️ **Source:** [Source](internal/demos/demo3x/main.go)
163168

164-
165169
## API Reference
166170

167171
### Core Methods
168172

169-
- `New(path string) *Gcm` - Create new Git command manager
170-
- `NewGcm(path, execConfig) *Gcm` - Create with custom configuration
173+
- `New(path string) *Gcm` - Create new Git command engine
174+
- `NewGcm(path, execConfig) *Gcm` - Create with custom settings
171175

172176
### Git Operations
173177

174-
- `Status() *Gcm` - Display working tree status
175-
- `Add() *Gcm` - Stage all changes
178+
- `Status() *Gcm` - Show working tree status
179+
- `Add() *Gcm` - Stage changes
176180
- `Commit(message) *Gcm` - Create commit with message
177-
- `Push() *Gcm` - Push to remote repository
178-
- `Pull() *Gcm` - Pull from remote repository
181+
- `Push() *Gcm` - Push to remote repo
182+
- `Pull() *Gcm` - Fetch and merge from remote repo
179183

180184
### Branch Management
181185

182186
- `CheckoutNewBranch(name) *Gcm` - Create and switch to new branch
183187
- `Checkout(name) *Gcm` - Switch to existing branch
184-
- `GetCurrentBranch() (string, error)` - Get current branch name
185-
- `ListBranches() ([]string, error)` - List all branches
188+
- `GetCurrentBranch() (string, error)` - Get the branch name
189+
- `ListBranches() ([]string, error)` - Get branches as a list
186190

187-
### Repository State
191+
### Repo State
188192

189-
- `HasStagingChanges() (bool, error)` - Check for staged changes
190-
- `HasUnstagedChanges() (bool, error)` - Check for unstaged changes
191-
- `HasChanges() (bool, error)` - Check for any changes
192-
- `GetCommitCount() (int, error)` - Get total commit count
193-
- `GitCommitHash(ref) (string, error)` - Get commit hash for reference
194-
- `GetRemoteURL(remote) (string, error)` - Get remote repository URL
193+
- `HasStagingChanges() (bool, error)` - Check staged changes existence
194+
- `HasUnstagedChanges() (bool, error)` - Check unstaged changes existence
195+
- `HasChanges() (bool, error)` - Check changes existence
196+
- `GetCommitCount() (int, error)` - Get commit count
197+
- `GitCommitHash(ref) (string, error)` - Get commit hash with reference
198+
- `GetRemoteURL(remote) (string, error)` - Get remote repo URL
195199

196-
### Error Handling
200+
### Issue Handling
197201

198-
- `Result() ([]byte, error)` - Get output and check for errors
199-
- `MustDone() *Gcm` - Panic if error occurred
202+
- `Result() ([]byte, error)` - Get output and check issues
203+
- `MustDone() *Gcm` - Panic when issues happen
200204

201205
<!-- TEMPLATE (EN) BEGIN: STANDARD PROJECT FOOTER -->
202206
<!-- VERSION 2025-09-06 04:53:24.895249 +0000 UTC -->
@@ -212,44 +216,44 @@ MIT License. See [LICENSE](LICENSE).
212216
Contributions are welcome! Report bugs, suggest features, and contribute code:
213217

214218
- 🐛 **Found a bug?** Open an issue on GitHub with reproduction steps
215-
- 💡 **Have a feature idea?** Create an issue to discuss the suggestion
216-
- 📖 **Documentation confusing?** Report it so we can improve
217-
- 🚀 **Need new features?** Share the use cases to help us understand requirements
219+
- 💡 **Have a feature idea?** Create an issue to discuss the concept
220+
- 📖 **Documentation confusing?** Report it and we can enhance
221+
- 🚀 **Need new features?** Share the use cases to help us understand needs
218222
-**Performance issue?** Help us optimize through reporting slow operations
219223
- 🔧 **Configuration problem?** Ask questions about complex setups
220224
- 📢 **Follow project progress?** Watch the repo to get new releases and features
221-
- 🌟 **Success stories?** Share how this package improved the workflow
222-
- 💬 **Feedback?** We welcome suggestions and comments
225+
- 🌟 **Success stories?** Share how this package helped the workflow
226+
- 💬 **Feedback?** We welcome input and comments
223227

224228
---
225229

226230
## 🔧 Development
227231

228-
New code contributions, follow this process:
232+
When contributing new code, follow this process:
229233

230-
1. **Fork**: Fork the repo on GitHub (using the webpage UI).
231-
2. **Clone**: Clone the forked project (`git clone https://github.com/yourname/repo-name.git`).
234+
1. **Fork**: Fork the repo on GitHub (using the webpage UI)
235+
2. **Clone**: Clone the forked project (`git clone https://github.com/yourname/repo-name.git`)
232236
3. **Navigate**: Navigate to the cloned project (`cd repo-name`)
233-
4. **Branch**: Create a feature branch (`git checkout -b feature/xxx`).
237+
4. **Branch**: Create a feature branch (`git checkout -b feature/xxx`)
234238
5. **Code**: Implement the changes with comprehensive tests
235-
6. **Testing**: (Golang project) Ensure tests pass (`go test ./...`) and follow Go code style conventions
236-
7. **Documentation**: Update documentation to support client-facing changes and use significant commit messages
239+
6. **Testing**: (Golang project) Make sure tests pass (`go test ./...`) and follow Go code conventions
240+
7. **Documentation**: Update documentation to support changes and write commit messages with substance
237241
8. **Stage**: Stage changes (`git add .`)
238-
9. **Commit**: Commit changes (`git commit -m "Add feature xxx"`) ensuring backward compatible code
239-
10. **Push**: Push to the branch (`git push origin feature/xxx`).
240-
11. **PR**: Open a pull request on GitHub (on the GitHub webpage) with detailed description.
242+
9. **Commit**: Commit changes (`git commit -m "Add feature xxx"`) with backward compatible code
243+
10. **Push**: Push to the branch (`git push origin feature/xxx`)
244+
11. **PR**: Open a PR on GitHub (on the GitHub webpage) with detailed description
241245

242-
Please ensure tests pass and include relevant documentation updates.
246+
Make sure tests pass and include documentation updates as needed.
243247

244248
---
245249

246250
## 🌟 Support
247251

248-
Welcome to contribute to this project via submitting merge requests and reporting issues.
252+
Welcome to contribute to this project through submitting PRs and reporting issues.
249253

250254
**Project Support:**
251255

252-
-**Give GitHub stars** if this project helps you
256+
-**Give GitHub stars** when this project helps you
253257
- 🤝 **Share with teammates** and (golang) programming friends
254258
- 📝 **Write tech blogs** about development tools and workflows - we provide content writing support
255259
- 🌟 **Join the ecosystem** - committed to supporting open source and the (golang) development scene

README.zh.md

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/go-xlan/gitgo/release.yml?branch=main&label=BUILD)](https://github.com/go-xlan/gitgo/actions/workflows/release.yml?query=branch%3Amain)
22
[![GoDoc](https://pkg.go.dev/badge/github.com/go-xlan/gitgo)](https://pkg.go.dev/github.com/go-xlan/gitgo)
33
[![Coverage Status](https://img.shields.io/coveralls/github/go-xlan/gitgo/main.svg)](https://coveralls.io/github/go-xlan/gitgo?branch=main)
4-
[![Supported Go Versions](https://img.shields.io/badge/Go-1.22--1.25-lightgrey.svg)](https://go.dev/)
4+
[![Supported Go Versions](https://img.shields.io/badge/Go-1.22--1.25-lightgrey.svg)](https://github.com/go-xlan/gitgo)
55
[![GitHub Release](https://img.shields.io/github/release/go-xlan/gitgo.svg)](https://github.com/go-xlan/gitgo/releases)
66
[![Go Report Card](https://goreportcard.com/badge/github.com/go-xlan/gitgo)](https://goreportcard.com/report/github.com/go-xlan/gitgo)
77

@@ -19,12 +19,17 @@
1919

2020
## 核心特性
2121

22-
🔗 **流式链式接口**: 复杂 Git 工作流的方法链式调用,具有自动错误传播
22+
🔗 **流式链式接口**: 复杂 Git 工作流的方法链式调用,具有自动问题传播
2323
**全面 Git 操作**: 完整覆盖 Git 命令,包括提交、推送、拉取和分支管理
24-
🔍 **智能状态检测**: 智能检查暂存/未暂存更改、干净工作树和仓库状态
25-
🎯 **错误处理**: 强大的错误传播,具有详细上下文和调试信息
24+
🔍 **智能状态检测**: 智能检查暂存和未暂存更改、干净工作树和仓库状态
25+
🎯 **问题处理**: 强健的问题传播,具有详细上下文和调试信息
2626
📋 **仓库查询**: 高级仓库信息查询,包括分支、提交和状态信息
2727

28+
## 关联项目
29+
30+
- **[gogit](https://github.com/go-xlan/gogit)** - 增强型 Git 操作工具包,基于 go-git 实现,提供纯 Go 实现无需 CLI 依赖
31+
- **[gitgo](https://github.com/go-xlan/gitgo)**(本项目)- 流式 Git 命令执行引擎,具有流畅的链式调用接口
32+
2833
## 安装
2934

3035
```bash
@@ -165,37 +170,37 @@ func main() {
165170

166171
### 核心方法
167172

168-
- `New(path string) *Gcm` - 创建新的 Git 命令管理器
169-
- `NewGcm(path, execConfig) *Gcm` - 使用自定义配置创建
173+
- `New(path string) *Gcm` - 创建新的 Git 命令引擎
174+
- `NewGcm(path, execConfig) *Gcm` - 使用自定义设置创建
170175

171176
### Git 操作
172177

173178
- `Status() *Gcm` - 显示工作树状态
174-
- `Add() *Gcm` - 暂存所有更改
179+
- `Add() *Gcm` - 暂存更改
175180
- `Commit(message) *Gcm` - 创建带消息的提交
176181
- `Push() *Gcm` - 推送到远程仓库
177-
- `Pull() *Gcm` - 从远程仓库拉取
182+
- `Pull() *Gcm` - 从远程仓库获取并合并
178183

179184
### 分支管理
180185

181186
- `CheckoutNewBranch(name) *Gcm` - 创建并切换到新分支
182187
- `Checkout(name) *Gcm` - 切换到现有分支
183-
- `GetCurrentBranch() (string, error)` - 获取当前分支名称
184-
- `ListBranches() ([]string, error)` - 列出所有分支
188+
- `GetCurrentBranch() (string, error)` - 获取分支名称
189+
- `ListBranches() ([]string, error)` - 获取分支列表
185190

186191
### 仓库状态
187192

188-
- `HasStagingChanges() (bool, error)` - 检查暂存更改
189-
- `HasUnstagedChanges() (bool, error)` - 检查未暂存更改
190-
- `HasChanges() (bool, error)` - 检查任何更改
191-
- `GetCommitCount() (int, error)` - 获取总提交数量
192-
- `GitCommitHash(ref) (string, error)` - 获取引用的提交哈希
193+
- `HasStagingChanges() (bool, error)` - 检查暂存更改是否存在
194+
- `HasUnstagedChanges() (bool, error)` - 检查未暂存更改是否存在
195+
- `HasChanges() (bool, error)` - 检查更改是否存在
196+
- `GetCommitCount() (int, error)` - 获取提交数量
197+
- `GitCommitHash(ref) (string, error)` - 使用引用获取提交哈希
193198
- `GetRemoteURL(remote) (string, error)` - 获取远程仓库 URL
194199

195-
### 错误处理
200+
### 问题处理
196201

197-
- `Result() ([]byte, error)` - 获取输出并检查错误
198-
- `MustDone() *Gcm` - 如果发生错误则触发 panic
202+
- `Result() ([]byte, error)` - 获取输出并检查问题
203+
- `MustDone() *Gcm` - 当问题发生时触发 panic
199204

200205
<!-- TEMPLATE (ZH) BEGIN: STANDARD PROJECT FOOTER -->
201206
<!-- VERSION 2025-09-06 04:53:24.895249 +0000 UTC -->
@@ -232,7 +237,7 @@ MIT 许可证。详见 [LICENSE](LICENSE)。
232237
4. **分支**:创建功能分支(`git checkout -b feature/xxx`
233238
5. **编码**:实现您的更改并编写全面的测试
234239
6. **测试**:(Golang 项目)确保测试通过(`go test ./...`)并遵循 Go 代码风格约定
235-
7. **文档**:为面向用户的更改更新文档,并使用有意义的提交消息
240+
7. **文档**:为面向用户的更改更新文档,并编写有内容的提交消息
236241
8. **暂存**:暂存更改(`git add .`
237242
9. **提交**:提交更改(`git commit -m "Add feature xxx"`)确保向后兼容的代码
238243
10. **推送**:推送到分支(`git push origin feature/xxx`

0 commit comments

Comments
 (0)