Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: CI

on:
push:
branches: [ main ]
pull_request:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ '3.8', '3.12' ]

steps:
- uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install build Pillow>=8.0

- name: Compile check
run: |
python -m py_compile run.py
python -m py_compile git_analytics.py
python -m py_compile generate_report.py
python -m py_compile gen_share_card.py

- name: CLI help
run: python run.py --help

- name: Run scan
run: python run.py --no-wizard --max-depth 0 --output-dir /tmp/git-analytics-ci --share-card

- name: Build package
run: python -m build
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Git Analytics

[![CI](https://github.com/mark-618/git-analytics/actions/workflows/ci.yml/badge.svg)](https://github.com/mark-618/git-analytics/actions/workflows/ci.yml)

**扫描本地 Git 仓库,生成你的开发者人格画像和代码习惯体检报告。**

不只统计 commits 和 lines——它告诉你:你是什么类型的开发者,你的代码习惯健康吗。
Expand All @@ -10,6 +12,8 @@
pip install git-analytics-cli
```

> **Package name vs command name**: PyPI package name is `git-analytics-cli`, CLI command is `git-analytics`.

## 30 秒快速开始

```bash
Expand All @@ -22,6 +26,18 @@ git-analytics ~/Projects

向导会引导你选择扫描目录、扫描深度、输出目录等,不需要记任何参数。

## Interactive Wizard

运行 `git-analytics` 不带参数时,会启动交互式向导:

1. 选择扫描目录(当前目录、Desktop、Projects 等)
2. 选择扫描深度(3 或 5)
3. 输入输出目录
4. 是否自动打开报告
5. 是否生成分享卡片设计器

向导会显示配置摘要,确认后开始扫描。输入 `q` 可随时退出。

## CLI 用法

```bash
Expand Down
4 changes: 2 additions & 2 deletions gen_share_card.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
try:
from PIL import Image, ImageDraw, ImageFont
except ImportError:
print("需要安装 Pillow 才能生成 PNG 分享卡片。")
print("运行: pip install git-analytics-cli[share-card]")
print("Pillow 是 git-analytics-cli 的必需依赖,请重新安装:")
print("pip install --upgrade git-analytics-cli")
sys.exit(1)


Expand Down
24 changes: 20 additions & 4 deletions run.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,6 @@ def _confirm(title, default=True):
return raw in {"y", "yes", "1", "true"}


def _path_label(path):
return os.path.abspath(os.path.expanduser(path))


def _existing_path(path):
expanded = os.path.abspath(os.path.expanduser(path))
return expanded if os.path.isdir(expanded) else None
Expand Down Expand Up @@ -140,6 +136,26 @@ def _run_wizard(args):
args.output_dir = output_dir
args.open = _confirm("生成后自动打开报告?", default=True)
args.share_card = _confirm("同时生成分享卡片设计器?", default=True)

# 显示配置摘要并确认
print()
print("=" * 40)
print("📋 配置摘要")
print("=" * 40)
print("扫描目录:")
for item in scan_dirs:
print(f" - {os.path.abspath(os.path.expanduser(item))}")
print(f"扫描深度: {max_depth}")
print(f"输出目录: {os.path.abspath(os.path.expanduser(output_dir))}")
print(f"自动打开报告: {'是' if args.open else '否'}")
print(f"生成分享卡片: {'是' if args.share_card else '否'}")
print("=" * 40)

confirm = input("[Enter] 开始,输入 q 退出: ").strip().lower()
if confirm in {"q", "quit", "exit"}:
print("已退出。")
sys.exit(0)

print()
return args

Expand Down
Loading