Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zhangwt-cn/git-daily
基于git提交代码生成工作日报
https://github.com/zhangwt-cn/git-daily
daily git
Last synced: 6 days ago
JSON representation
基于git提交代码生成工作日报
- Host: GitHub
- URL: https://github.com/zhangwt-cn/git-daily
- Owner: zhangwt-cn
- License: mit
- Created: 2024-11-21T06:12:56.000Z (3 months ago)
- Default Branch: main
- Last Pushed: 2024-11-22T06:16:37.000Z (3 months ago)
- Last Synced: 2024-12-10T04:13:30.465Z (2 months ago)
- Topics: daily, git
- Language: Go
- Homepage:
- Size: 27.3 KB
- Stars: 16
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Git Daily 📝
[![Go Report Card](https://goreportcard.com/badge/github.com/zhangwt-cn/git-daily)](https://goreportcard.com/report/github.com/zhangwt-cn/git-daily)
[![GitHub release](https://img.shields.io/github/v/release/zhangwt-cn/git-daily)](https://github.com/zhangwt-cn/git-daily/releases)
[![License](https://img.shields.io/github/license/zhangwt-cn/git-daily)](LICENSE)
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](CONTRIBUTING.md)**基于 Git commit hooks 的智能工作日报生成工具**
## ✨ 特性
- 🔄 基于 Git post-commit hook 实现自动触发
- 🤖 利用 AI 智能分析代码变动内容
- 📊 生成结构化的工作日报
- ⚙️ 支持自定义配置
- 🚀 轻量级,低资源占用## 📦 安装
### 前置条件
- ✅ Git
### 安装步骤
#### 方法一:直接使用预编译的二进制文件(推荐) 🚀
1. 从 [Release 页面](https://github.com/zhangwt-cn/git-daily/releases) 下载适合你操作系统的最新版本
2. 解压下载的文件:
```bash
# 🪟 Windows
unzip git-daily-windows-amd64.zip# 🐧 Linux/🍎 MacOS
tar -xzf git-daily-linux-amd64.tar.gz
```3. 将解压出的 `git-daily` 二进制文件复制到你的 Git 项目的 hooks 目录:
```bash
# 进入你的项目目录
cd your-project# 复制 git-daily、config.json 到 .git/hooks/post-commit
cp path/to/post-commit .git/hooks/post-commit
cp path/to/config.json .git/hooks/config.json
```4. 确保 hook 文件具有执行权限(Linux/MacOS):
```bash
chmod +x .git/hooks/post-commit
```#### 方法二:从源码编译(可选) 🛠️
如果你有 Go 开发环境(Go 1.21.4),也可以从源码编译:
1. 克隆项目并编译:
```bash
git clone https://github.com/zhangwt-cn/git-daily.git
cd git-daily
go build
```2. 将编译好的二进制文件复制到你的项目的 hooks 目录:
```bash
cp git-daily /path/to/your-project/.git/hooks/post-commit
cp config.json /path/to/your-project/.git/hooks/config.json
```## 🚀 使用方法
### 1️⃣ 配置
在项目根目录创建 `config.json` 配置文件:
```json
{
"openai_base_url": "https://api.oaipro.com/v1",
"openai_api_key": "sk-xxx",
"moderation_model": "claude-3-5-sonnet-20241022",
"daily_path": ""
}
```### 2️⃣ 自动运行
完成配置后,工具会自动在每次 commit 后运行:
- 🔍 自动分析本次提交的代码变动
- 🤖 使用 AI 模型生成变更说明
- 📝 生成日报内容### 3️⃣ 输出说明
默认情况下,日报将保存在项目根目录的 `daily-report.md` 文件中:
- 📂 可以通过 `daily_path` 配置项修改输出位置
- 🔄 每次提交后会自动更新日报内容### 4️⃣ 使用示例
```bash
git add .
git commit -m "feat: add new feature"
# git-daily 会自动运行并生成日报
```## ⚙️ 配置说明
配置文件 (`config.json`) 参数说明:
| 参数 | 说明 | 默认值 |
|------|------|--------|
| `openai_base_url` | OpenAI API 基础 URL | `https://api.oaipro.com/v1` |
| `openai_api_key` | OpenAI API 密钥 | - |
| `moderation_model` | AI 模型选择 | `claude-3-5-sonnet-20241022` |
| `daily_path` | 日报输出路径 | 当前目录 |## 📋 日报示例
```markdown
# Daily Git Report - 2024-11-22### Repo: git-daily
**Commit Hash:** 5e645887f32be6129b1aef7413d000f2809df4a6
**Date:** 2024-11-22 09:37:39
**Message:** feat: 增加日志颜色输出
**Analysis:**
今日工作进展:
1. 增强日志输出功能
- 通过引入日志颜色输出功能,优化了系统的可读性和使用体验。不同颜色的日志信息可以帮助开发人员和运维人员快速区分和识别关键信息、警告和错误,从而提高问题诊断效率。
- 具体改进方面,在终端输出中新增了红色(错误)、蓝色(信息)、绿色(成功)、黄色(警告)等颜色表示,能够使日志分析更加直观和快速,减少了人工筛选和判断时间。
- 此功能不仅提升了日志的友好性,同时也预见性地减少了由于信息误读带来的潜在业务风险。后续我们计划根据实际的使用反馈,进一步调整和优化颜色配置,以适应更多场景需求。
```## 🔧 故障排除
### 常见问题
1. **🔴 权限问题**
```bash
# 解决方案
chmod +x .git/hooks/post-commit
```2. **🔴 配置文件无法读取**
- 确保 `config.json` 在.git/hooks目录下
- 检查 JSON 格式是否正确3. **🔴 Failed to fetch analysis**
- 验证 API 密钥是否正确
- 检查网络连接
- 确认 API 代理地址可访问## 🤝 贡献指南
1. Fork 本项目
2. 创建特性分支 (`git checkout -b feature/AmazingFeature`)
3. 提交更改 (`git commit -m 'Add some AmazingFeature'`)
4. 推送到分支 (`git push origin feature/AmazingFeature`)
5. 提交 Pull Request## 📄 许可证
本项目采用 MIT 许可证 - 查看 [LICENSE](LICENSE) 文件了解详情
## 👥 作者
- zhangwt-cn
## 🙏 致谢
感谢所有贡献者对本项目的支持!
---
如果这个项目对你有帮助,请给一个 ⭐️ Star ⭐️