gitcode-insight 0.1.0__tar.gz → 0.1.1__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (29) hide show
  1. {gitcode_insight-0.1.0/src/gitcode_insight.egg-info → gitcode_insight-0.1.1}/PKG-INFO +81 -9
  2. gitcode_insight-0.1.1/README.md +149 -0
  3. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/pyproject.toml +1 -1
  4. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/src/gitcode_insight/__init__.py +1 -1
  5. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/src/gitcode_insight/cli.py +6 -6
  6. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/src/gitcode_insight/community.py +3 -4
  7. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/src/gitcode_insight/utils.py +51 -0
  8. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1/src/gitcode_insight.egg-info}/PKG-INFO +81 -9
  9. gitcode_insight-0.1.0/README.md +0 -77
  10. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/LICENSE +0 -0
  11. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/setup.cfg +0 -0
  12. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/src/gitcode_insight/dashboard.py +0 -0
  13. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/src/gitcode_insight/issue.py +0 -0
  14. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/src/gitcode_insight/pr.py +0 -0
  15. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/src/gitcode_insight/repo_stats.py +0 -0
  16. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/src/gitcode_insight/report.py +0 -0
  17. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/src/gitcode_insight.egg-info/SOURCES.txt +0 -0
  18. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/src/gitcode_insight.egg-info/dependency_links.txt +0 -0
  19. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/src/gitcode_insight.egg-info/entry_points.txt +0 -0
  20. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/src/gitcode_insight.egg-info/requires.txt +0 -0
  21. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/src/gitcode_insight.egg-info/top_level.txt +0 -0
  22. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/tests/test_cli.py +0 -0
  23. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/tests/test_community.py +0 -0
  24. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/tests/test_dashboard.py +0 -0
  25. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/tests/test_issue.py +0 -0
  26. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/tests/test_pr.py +0 -0
  27. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/tests/test_repo_stats.py +0 -0
  28. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/tests/test_report.py +0 -0
  29. {gitcode_insight-0.1.0 → gitcode_insight-0.1.1}/tests/test_utils.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitcode-insight
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: GitCode 平台代码洞察工具
5
5
  Author: GitCode Insight Team
6
6
  License-Expression: MIT
@@ -28,9 +28,12 @@ Dynamic: license-file
28
28
 
29
29
  [![Python Version](https://img.shields.io/badge/python-3.7%2B-blue.svg)](https://www.python.org/downloads/)
30
30
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
31
+ [![PyPI](https://img.shields.io/pypi/v/gitcode-insight.svg)](https://pypi.org/project/gitcode-insight/)
31
32
 
32
33
  GitCode 平台代码洞察命令行工具,支持社区洞察、Issue/PR 分析、仓库统计,生成可视化报告。
33
34
 
35
+ **PyPI**: https://pypi.org/project/gitcode-insight/
36
+
34
37
  ## 功能
35
38
 
36
39
  | 功能 | 说明 |
@@ -43,28 +46,47 @@ GitCode 平台代码洞察命令行工具,支持社区洞察、Issue/PR 分析
43
46
 
44
47
  ## 快速开始
45
48
 
49
+ ### 从 PyPI 安装
50
+
46
51
  ```bash
47
- # 安装
48
52
  pip install gitcode-insight
53
+ ```
49
54
 
50
- # 或从源码安装
55
+ ### 从源码安装(推荐开发使用)
56
+
57
+ ```bash
58
+ # 克隆仓库
51
59
  git clone https://gitcode.com/gitcode-cli/insight.git
52
60
  cd insight
61
+
62
+ # 创建虚拟环境
53
63
  python3 -m venv .venv
54
- .venv/bin/pip install -e ".[test]"
64
+
65
+ # 激活虚拟环境
66
+ # Linux/macOS:
67
+ source .venv/bin/activate
68
+ # Windows:
69
+ # .venv\Scripts\activate
70
+
71
+ # 安装(开发模式,包含测试依赖)
72
+ pip install -e ".[test]"
55
73
 
56
74
  # 创建配置文件
57
75
  cp config/gitcode.json.example config/gitcode.json
58
76
  # 编辑配置文件,填入 access_token 和 owner
77
+ ```
59
78
 
79
+ ### 使用示例
80
+
81
+ ```bash
60
82
  # 生成社区看板
61
83
  gc-insight dashboard
62
84
 
63
85
  # 分析单个仓库
64
- gc-insight issue --repo your-repo --token your_token --days 30
65
- gc-insight pr --repo your-repo --token your_token --days 30
66
- gc-insight repo-stats --repo your-repo --token your_token --days 30
67
- gc-insight report --repo your-repo --token your_token --days 30
86
+ gc-insight issue --repo kernel --owner openeuler --token your_token --days 7
87
+ gc-insight pr --repo kernel --owner openeuler --token your_token --days 7
88
+ gc-insight repo-stats --repo kernel --owner openeuler --token your_token --days 7
89
+ gc-insight report --repo kernel --owner openeuler --token your_token --days 7
68
90
  ```
69
91
 
70
92
  ## 配置
@@ -74,12 +96,46 @@ gc-insight report --repo your-repo --token your_token --days 30
74
96
  ```json
75
97
  {
76
98
  "access_token": "your_gitcode_access_token",
77
- "owner": "your_organization_name"
99
+ "owner": "your_organization_name",
100
+ "repo_whitelist": ["repo1", "repo2"],
101
+ "repo_blacklist": ["repo3", "repo4"]
78
102
  }
79
103
  ```
80
104
 
105
+ | 字段 | 说明 |
106
+ |------|------|
107
+ | `access_token` | GitCode API 访问令牌(必填) |
108
+ | `owner` | 组织/社区名称(必填) |
109
+ | `repo_whitelist` | 仓库白名单,仅统计指定仓库 |
110
+ | `repo_blacklist` | 仓库黑名单,排除指定仓库 |
111
+
81
112
  获取 Access Token:GitCode → 设置 → 访问令牌 → 创建新令牌
82
113
 
114
+ ## 输出产物
115
+
116
+ 所有命令执行后生成三种标准产物,保存在 `./output/` 目录:
117
+
118
+ | 格式 | 说明 | 用途 |
119
+ |------|------|------|
120
+ | `.json` | 原始数据 + 统计计算数据 | 数据存档、二次开发 |
121
+ | `.md` | Markdown 格式总结报告 | 文档集成、Git 提交 |
122
+ | `.html` | HTML 格式可视化报告 | 浏览器查看、分享展示 |
123
+
124
+ **示例**:
125
+
126
+ ```
127
+ output/
128
+ ├── issue_insight_kvrocks_30d.json # Issue 数据
129
+ ├── issue_insight_kvrocks_30d.md # Issue Markdown 报告
130
+ ├── issue_insight_kvrocks_30d.html # Issue 可视化报告
131
+ ├── pr_insight_kvrocks_30d.json
132
+ ├── pr_insight_kvrocks_30d.md
133
+ ├── pr_insight_kvrocks_30d.html
134
+ ├── report_openeuler_kernel_30d.json
135
+ ├── report_openeuler_kernel_30d.md
136
+ └── report_openeuler_kernel_30d.html
137
+ ```
138
+
83
139
  ## 常见问题
84
140
 
85
141
  **Q: 输出文件在哪里?**
@@ -91,11 +147,27 @@ A: GitCode API 每分钟限制 100 次请求,工具已内置限流处理。如
91
147
  **Q: CSV 文件中文乱码?**
92
148
  A: 文件使用 UTF-8-BOM 编码,Excel 可正常打开。
93
149
 
150
+ **Q: 安装时报错 `externally-managed-environment`?**
151
+ A: 这是 Debian/Ubuntu 系统(Python 3.11+)的保护机制,防止破坏系统 Python 环境。请使用虚拟环境安装:
152
+
153
+ ```bash
154
+ # 创建虚拟环境
155
+ python3 -m venv .venv
156
+
157
+ # 激活虚拟环境
158
+ source .venv/bin/activate # Linux/macOS
159
+ # .venv\Scripts\activate # Windows
160
+
161
+ # 安装
162
+ pip install gitcode-insight
163
+ ```
164
+
94
165
  ## 文档
95
166
 
96
167
  - [用户指南](doc/user_guide.md) - 详细的安装配置和命令说明
97
168
  - [开发指南](doc/development.md) - 本地开发和测试
98
169
  - [贡献指南](CONTRIBUTING.md) - 参与项目贡献
170
+ - [发布流程](doc/release.md) - PyPI 发布说明
99
171
  - [API 文档](doc/gitcode_api/) - GitCode API 接口说明
100
172
 
101
173
  ## 许可证
@@ -0,0 +1,149 @@
1
+ # GitCode Insight
2
+
3
+ [![Python Version](https://img.shields.io/badge/python-3.7%2B-blue.svg)](https://www.python.org/downloads/)
4
+ [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
5
+ [![PyPI](https://img.shields.io/pypi/v/gitcode-insight.svg)](https://pypi.org/project/gitcode-insight/)
6
+
7
+ GitCode 平台代码洞察命令行工具,支持社区洞察、Issue/PR 分析、仓库统计,生成可视化报告。
8
+
9
+ **PyPI**: https://pypi.org/project/gitcode-insight/
10
+
11
+ ## 功能
12
+
13
+ | 功能 | 说明 |
14
+ |------|------|
15
+ | 社区洞察 | 分析组织下所有仓库的统计数据,生成看板 |
16
+ | Issue 洞察 | Issue 数量、响应时间、关闭率、标签分布 |
17
+ | PR 洞察 | 评审效率、合并耗时、变更规模、冲突率 |
18
+ | 仓库统计 | 下载量、Fork、订阅用户、编程语言 |
19
+ | 综合报告 | 整合所有模块的一站式报告 |
20
+
21
+ ## 快速开始
22
+
23
+ ### 从 PyPI 安装
24
+
25
+ ```bash
26
+ pip install gitcode-insight
27
+ ```
28
+
29
+ ### 从源码安装(推荐开发使用)
30
+
31
+ ```bash
32
+ # 克隆仓库
33
+ git clone https://gitcode.com/gitcode-cli/insight.git
34
+ cd insight
35
+
36
+ # 创建虚拟环境
37
+ python3 -m venv .venv
38
+
39
+ # 激活虚拟环境
40
+ # Linux/macOS:
41
+ source .venv/bin/activate
42
+ # Windows:
43
+ # .venv\Scripts\activate
44
+
45
+ # 安装(开发模式,包含测试依赖)
46
+ pip install -e ".[test]"
47
+
48
+ # 创建配置文件
49
+ cp config/gitcode.json.example config/gitcode.json
50
+ # 编辑配置文件,填入 access_token 和 owner
51
+ ```
52
+
53
+ ### 使用示例
54
+
55
+ ```bash
56
+ # 生成社区看板
57
+ gc-insight dashboard
58
+
59
+ # 分析单个仓库
60
+ gc-insight issue --repo kernel --owner openeuler --token your_token --days 7
61
+ gc-insight pr --repo kernel --owner openeuler --token your_token --days 7
62
+ gc-insight repo-stats --repo kernel --owner openeuler --token your_token --days 7
63
+ gc-insight report --repo kernel --owner openeuler --token your_token --days 7
64
+ ```
65
+
66
+ ## 配置
67
+
68
+ 配置文件 `config/gitcode.json`:
69
+
70
+ ```json
71
+ {
72
+ "access_token": "your_gitcode_access_token",
73
+ "owner": "your_organization_name",
74
+ "repo_whitelist": ["repo1", "repo2"],
75
+ "repo_blacklist": ["repo3", "repo4"]
76
+ }
77
+ ```
78
+
79
+ | 字段 | 说明 |
80
+ |------|------|
81
+ | `access_token` | GitCode API 访问令牌(必填) |
82
+ | `owner` | 组织/社区名称(必填) |
83
+ | `repo_whitelist` | 仓库白名单,仅统计指定仓库 |
84
+ | `repo_blacklist` | 仓库黑名单,排除指定仓库 |
85
+
86
+ 获取 Access Token:GitCode → 设置 → 访问令牌 → 创建新令牌
87
+
88
+ ## 输出产物
89
+
90
+ 所有命令执行后生成三种标准产物,保存在 `./output/` 目录:
91
+
92
+ | 格式 | 说明 | 用途 |
93
+ |------|------|------|
94
+ | `.json` | 原始数据 + 统计计算数据 | 数据存档、二次开发 |
95
+ | `.md` | Markdown 格式总结报告 | 文档集成、Git 提交 |
96
+ | `.html` | HTML 格式可视化报告 | 浏览器查看、分享展示 |
97
+
98
+ **示例**:
99
+
100
+ ```
101
+ output/
102
+ ├── issue_insight_kvrocks_30d.json # Issue 数据
103
+ ├── issue_insight_kvrocks_30d.md # Issue Markdown 报告
104
+ ├── issue_insight_kvrocks_30d.html # Issue 可视化报告
105
+ ├── pr_insight_kvrocks_30d.json
106
+ ├── pr_insight_kvrocks_30d.md
107
+ ├── pr_insight_kvrocks_30d.html
108
+ ├── report_openeuler_kernel_30d.json
109
+ ├── report_openeuler_kernel_30d.md
110
+ └── report_openeuler_kernel_30d.html
111
+ ```
112
+
113
+ ## 常见问题
114
+
115
+ **Q: 输出文件在哪里?**
116
+ A: 默认保存在 `./output/` 目录。
117
+
118
+ **Q: 请求频繁失败怎么办?**
119
+ A: GitCode API 每分钟限制 100 次请求,工具已内置限流处理。如遇问题,等待几分钟后重试。
120
+
121
+ **Q: CSV 文件中文乱码?**
122
+ A: 文件使用 UTF-8-BOM 编码,Excel 可正常打开。
123
+
124
+ **Q: 安装时报错 `externally-managed-environment`?**
125
+ A: 这是 Debian/Ubuntu 系统(Python 3.11+)的保护机制,防止破坏系统 Python 环境。请使用虚拟环境安装:
126
+
127
+ ```bash
128
+ # 创建虚拟环境
129
+ python3 -m venv .venv
130
+
131
+ # 激活虚拟环境
132
+ source .venv/bin/activate # Linux/macOS
133
+ # .venv\Scripts\activate # Windows
134
+
135
+ # 安装
136
+ pip install gitcode-insight
137
+ ```
138
+
139
+ ## 文档
140
+
141
+ - [用户指南](doc/user_guide.md) - 详细的安装配置和命令说明
142
+ - [开发指南](doc/development.md) - 本地开发和测试
143
+ - [贡献指南](CONTRIBUTING.md) - 参与项目贡献
144
+ - [发布流程](doc/release.md) - PyPI 发布说明
145
+ - [API 文档](doc/gitcode_api/) - GitCode API 接口说明
146
+
147
+ ## 许可证
148
+
149
+ [MIT License](LICENSE)
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
4
4
 
5
5
  [project]
6
6
  name = "gitcode-insight"
7
- version = "0.1.0"
7
+ version = "0.1.1"
8
8
  description = "GitCode 平台代码洞察工具"
9
9
  readme = "README.md"
10
10
  license = "MIT"
@@ -3,7 +3,7 @@
3
3
  GitCode Insight - GitCode 平台代码洞察工具
4
4
  """
5
5
 
6
- __version__ = "0.1.0"
6
+ __version__ = "0.1.1"
7
7
  __author__ = "GitCode Insight Team"
8
8
 
9
9
  from .community import GitCodeCommunityStats
@@ -5,7 +5,6 @@ GitCode Insight 命令行入口
5
5
 
6
6
  import argparse
7
7
  import os
8
- import json
9
8
 
10
9
  from .community import GitCodeCommunityStats
11
10
  from .issue import GitCodeIssueInsight
@@ -13,6 +12,7 @@ from .pr import GitCodePRInsight
13
12
  from .dashboard import generate_dashboard
14
13
  from .repo_stats import GitCodeRepoStats
15
14
  from .report import GitCodeReport
15
+ from .utils import load_config
16
16
 
17
17
 
18
18
  def get_config_owner(config_file):
@@ -20,11 +20,11 @@ def get_config_owner(config_file):
20
20
  if config_file is None:
21
21
  config_file = os.path.join(os.getcwd(), "config", "gitcode.json")
22
22
 
23
- if os.path.exists(config_file):
24
- with open(config_file, 'r', encoding='utf-8') as f:
25
- config = json.load(f)
26
- return config.get("owner", "")
27
- return ""
23
+ try:
24
+ config = load_config(config_file)
25
+ return config.get("owner", "")
26
+ except SystemExit:
27
+ return ""
28
28
 
29
29
 
30
30
  def cmd_community(args):
@@ -12,7 +12,7 @@ import csv
12
12
  import os
13
13
  import requests
14
14
 
15
- from .utils import request_with_retry
15
+ from .utils import request_with_retry, load_config
16
16
 
17
17
 
18
18
  class GitCodeCommunityStats:
@@ -36,9 +36,8 @@ class GitCodeCommunityStats:
36
36
 
37
37
  self.output_dir = output_dir
38
38
 
39
- # 读取配置文件
40
- with open(config_file, 'r', encoding='utf-8') as f:
41
- config = json.load(f)
39
+ # 读取并验证配置文件
40
+ config = load_config(config_file)
42
41
 
43
42
  self.base_url = "https://api.gitcode.com/api/v5"
44
43
  self.headers = {
@@ -4,11 +4,62 @@
4
4
  提供统一的请求重试、限流处理等功能
5
5
  """
6
6
 
7
+ import json
8
+ import os
9
+ import sys
7
10
  import time
8
11
  from typing import Optional, Dict, Any
9
12
  import requests
10
13
 
11
14
 
15
+ def load_config(config_file: str) -> dict:
16
+ """
17
+ 加载并验证配置文件
18
+
19
+ Args:
20
+ config_file: 配置文件路径
21
+
22
+ Returns:
23
+ 配置字典
24
+
25
+ Raises:
26
+ SystemExit: 配置文件不存在、格式错误或必填项缺失时退出程序
27
+ """
28
+ # 检查配置文件是否存在
29
+ if not os.path.exists(config_file):
30
+ print(f"错误: 配置文件不存在")
31
+ print(f" 路径: {config_file}")
32
+ print(f" 请创建配置文件: cp config/gitcode.json.example config/gitcode.json")
33
+ sys.exit(1)
34
+
35
+ # 尝试解析 JSON 文件
36
+ try:
37
+ with open(config_file, 'r', encoding='utf-8') as f:
38
+ config = json.load(f)
39
+ except json.JSONDecodeError as e:
40
+ print(f"错误: 配置文件格式错误")
41
+ print(f" 路径: {config_file}")
42
+ print(f" 详情: {e}")
43
+ sys.exit(1)
44
+ except Exception as e:
45
+ print(f"错误: 无法读取配置文件")
46
+ print(f" 路径: {config_file}")
47
+ print(f" 详情: {e}")
48
+ sys.exit(1)
49
+
50
+ # 验证必填项
51
+ required_fields = ["access_token", "owner"]
52
+ missing_fields = [field for field in required_fields if not config.get(field)]
53
+
54
+ if missing_fields:
55
+ print(f"错误: 配置文件缺少必填项")
56
+ print(f" 路径: {config_file}")
57
+ print(f" 缺失字段: {', '.join(missing_fields)}")
58
+ sys.exit(1)
59
+
60
+ return config
61
+
62
+
12
63
  def request_with_retry(
13
64
  session: requests.Session,
14
65
  url: str,
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: gitcode-insight
3
- Version: 0.1.0
3
+ Version: 0.1.1
4
4
  Summary: GitCode 平台代码洞察工具
5
5
  Author: GitCode Insight Team
6
6
  License-Expression: MIT
@@ -28,9 +28,12 @@ Dynamic: license-file
28
28
 
29
29
  [![Python Version](https://img.shields.io/badge/python-3.7%2B-blue.svg)](https://www.python.org/downloads/)
30
30
  [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
31
+ [![PyPI](https://img.shields.io/pypi/v/gitcode-insight.svg)](https://pypi.org/project/gitcode-insight/)
31
32
 
32
33
  GitCode 平台代码洞察命令行工具,支持社区洞察、Issue/PR 分析、仓库统计,生成可视化报告。
33
34
 
35
+ **PyPI**: https://pypi.org/project/gitcode-insight/
36
+
34
37
  ## 功能
35
38
 
36
39
  | 功能 | 说明 |
@@ -43,28 +46,47 @@ GitCode 平台代码洞察命令行工具,支持社区洞察、Issue/PR 分析
43
46
 
44
47
  ## 快速开始
45
48
 
49
+ ### 从 PyPI 安装
50
+
46
51
  ```bash
47
- # 安装
48
52
  pip install gitcode-insight
53
+ ```
49
54
 
50
- # 或从源码安装
55
+ ### 从源码安装(推荐开发使用)
56
+
57
+ ```bash
58
+ # 克隆仓库
51
59
  git clone https://gitcode.com/gitcode-cli/insight.git
52
60
  cd insight
61
+
62
+ # 创建虚拟环境
53
63
  python3 -m venv .venv
54
- .venv/bin/pip install -e ".[test]"
64
+
65
+ # 激活虚拟环境
66
+ # Linux/macOS:
67
+ source .venv/bin/activate
68
+ # Windows:
69
+ # .venv\Scripts\activate
70
+
71
+ # 安装(开发模式,包含测试依赖)
72
+ pip install -e ".[test]"
55
73
 
56
74
  # 创建配置文件
57
75
  cp config/gitcode.json.example config/gitcode.json
58
76
  # 编辑配置文件,填入 access_token 和 owner
77
+ ```
59
78
 
79
+ ### 使用示例
80
+
81
+ ```bash
60
82
  # 生成社区看板
61
83
  gc-insight dashboard
62
84
 
63
85
  # 分析单个仓库
64
- gc-insight issue --repo your-repo --token your_token --days 30
65
- gc-insight pr --repo your-repo --token your_token --days 30
66
- gc-insight repo-stats --repo your-repo --token your_token --days 30
67
- gc-insight report --repo your-repo --token your_token --days 30
86
+ gc-insight issue --repo kernel --owner openeuler --token your_token --days 7
87
+ gc-insight pr --repo kernel --owner openeuler --token your_token --days 7
88
+ gc-insight repo-stats --repo kernel --owner openeuler --token your_token --days 7
89
+ gc-insight report --repo kernel --owner openeuler --token your_token --days 7
68
90
  ```
69
91
 
70
92
  ## 配置
@@ -74,12 +96,46 @@ gc-insight report --repo your-repo --token your_token --days 30
74
96
  ```json
75
97
  {
76
98
  "access_token": "your_gitcode_access_token",
77
- "owner": "your_organization_name"
99
+ "owner": "your_organization_name",
100
+ "repo_whitelist": ["repo1", "repo2"],
101
+ "repo_blacklist": ["repo3", "repo4"]
78
102
  }
79
103
  ```
80
104
 
105
+ | 字段 | 说明 |
106
+ |------|------|
107
+ | `access_token` | GitCode API 访问令牌(必填) |
108
+ | `owner` | 组织/社区名称(必填) |
109
+ | `repo_whitelist` | 仓库白名单,仅统计指定仓库 |
110
+ | `repo_blacklist` | 仓库黑名单,排除指定仓库 |
111
+
81
112
  获取 Access Token:GitCode → 设置 → 访问令牌 → 创建新令牌
82
113
 
114
+ ## 输出产物
115
+
116
+ 所有命令执行后生成三种标准产物,保存在 `./output/` 目录:
117
+
118
+ | 格式 | 说明 | 用途 |
119
+ |------|------|------|
120
+ | `.json` | 原始数据 + 统计计算数据 | 数据存档、二次开发 |
121
+ | `.md` | Markdown 格式总结报告 | 文档集成、Git 提交 |
122
+ | `.html` | HTML 格式可视化报告 | 浏览器查看、分享展示 |
123
+
124
+ **示例**:
125
+
126
+ ```
127
+ output/
128
+ ├── issue_insight_kvrocks_30d.json # Issue 数据
129
+ ├── issue_insight_kvrocks_30d.md # Issue Markdown 报告
130
+ ├── issue_insight_kvrocks_30d.html # Issue 可视化报告
131
+ ├── pr_insight_kvrocks_30d.json
132
+ ├── pr_insight_kvrocks_30d.md
133
+ ├── pr_insight_kvrocks_30d.html
134
+ ├── report_openeuler_kernel_30d.json
135
+ ├── report_openeuler_kernel_30d.md
136
+ └── report_openeuler_kernel_30d.html
137
+ ```
138
+
83
139
  ## 常见问题
84
140
 
85
141
  **Q: 输出文件在哪里?**
@@ -91,11 +147,27 @@ A: GitCode API 每分钟限制 100 次请求,工具已内置限流处理。如
91
147
  **Q: CSV 文件中文乱码?**
92
148
  A: 文件使用 UTF-8-BOM 编码,Excel 可正常打开。
93
149
 
150
+ **Q: 安装时报错 `externally-managed-environment`?**
151
+ A: 这是 Debian/Ubuntu 系统(Python 3.11+)的保护机制,防止破坏系统 Python 环境。请使用虚拟环境安装:
152
+
153
+ ```bash
154
+ # 创建虚拟环境
155
+ python3 -m venv .venv
156
+
157
+ # 激活虚拟环境
158
+ source .venv/bin/activate # Linux/macOS
159
+ # .venv\Scripts\activate # Windows
160
+
161
+ # 安装
162
+ pip install gitcode-insight
163
+ ```
164
+
94
165
  ## 文档
95
166
 
96
167
  - [用户指南](doc/user_guide.md) - 详细的安装配置和命令说明
97
168
  - [开发指南](doc/development.md) - 本地开发和测试
98
169
  - [贡献指南](CONTRIBUTING.md) - 参与项目贡献
170
+ - [发布流程](doc/release.md) - PyPI 发布说明
99
171
  - [API 文档](doc/gitcode_api/) - GitCode API 接口说明
100
172
 
101
173
  ## 许可证
@@ -1,77 +0,0 @@
1
- # GitCode Insight
2
-
3
- [![Python Version](https://img.shields.io/badge/python-3.7%2B-blue.svg)](https://www.python.org/downloads/)
4
- [![License](https://img.shields.io/badge/license-MIT-green.svg)](LICENSE)
5
-
6
- GitCode 平台代码洞察命令行工具,支持社区洞察、Issue/PR 分析、仓库统计,生成可视化报告。
7
-
8
- ## 功能
9
-
10
- | 功能 | 说明 |
11
- |------|------|
12
- | 社区洞察 | 分析组织下所有仓库的统计数据,生成看板 |
13
- | Issue 洞察 | Issue 数量、响应时间、关闭率、标签分布 |
14
- | PR 洞察 | 评审效率、合并耗时、变更规模、冲突率 |
15
- | 仓库统计 | 下载量、Fork、订阅用户、编程语言 |
16
- | 综合报告 | 整合所有模块的一站式报告 |
17
-
18
- ## 快速开始
19
-
20
- ```bash
21
- # 安装
22
- pip install gitcode-insight
23
-
24
- # 或从源码安装
25
- git clone https://gitcode.com/gitcode-cli/insight.git
26
- cd insight
27
- python3 -m venv .venv
28
- .venv/bin/pip install -e ".[test]"
29
-
30
- # 创建配置文件
31
- cp config/gitcode.json.example config/gitcode.json
32
- # 编辑配置文件,填入 access_token 和 owner
33
-
34
- # 生成社区看板
35
- gc-insight dashboard
36
-
37
- # 分析单个仓库
38
- gc-insight issue --repo your-repo --token your_token --days 30
39
- gc-insight pr --repo your-repo --token your_token --days 30
40
- gc-insight repo-stats --repo your-repo --token your_token --days 30
41
- gc-insight report --repo your-repo --token your_token --days 30
42
- ```
43
-
44
- ## 配置
45
-
46
- 配置文件 `config/gitcode.json`:
47
-
48
- ```json
49
- {
50
- "access_token": "your_gitcode_access_token",
51
- "owner": "your_organization_name"
52
- }
53
- ```
54
-
55
- 获取 Access Token:GitCode → 设置 → 访问令牌 → 创建新令牌
56
-
57
- ## 常见问题
58
-
59
- **Q: 输出文件在哪里?**
60
- A: 默认保存在 `./output/` 目录。
61
-
62
- **Q: 请求频繁失败怎么办?**
63
- A: GitCode API 每分钟限制 100 次请求,工具已内置限流处理。如遇问题,等待几分钟后重试。
64
-
65
- **Q: CSV 文件中文乱码?**
66
- A: 文件使用 UTF-8-BOM 编码,Excel 可正常打开。
67
-
68
- ## 文档
69
-
70
- - [用户指南](doc/user_guide.md) - 详细的安装配置和命令说明
71
- - [开发指南](doc/development.md) - 本地开发和测试
72
- - [贡献指南](CONTRIBUTING.md) - 参与项目贡献
73
- - [API 文档](doc/gitcode_api/) - GitCode API 接口说明
74
-
75
- ## 许可证
76
-
77
- [MIT License](LICENSE)
File without changes