Skip to main content

GitCode Insight

Python Version License PyPI

GitCode 平台代码洞察命令行工具,支持社区洞察、Issue/PR 分析、仓库统计,生成可视化报告。

PyPI: https://pypi.org/project/gitcode-insight/

功能

功能 说明
社区洞察 分析组织下所有仓库的统计数据,生成看板
Issue 洞察 Issue 数量、响应时间、关闭率、标签分布
PR 洞察 评审效率、合并耗时、变更规模、冲突率
仓库统计 下载量、Fork、订阅用户、编程语言
综合报告 整合所有模块的一站式报告

快速开始

从 PyPI 安装

pip install gitcode-insight

从源码安装(推荐开发使用)

# 克隆仓库
git clone https://gitcode.com/gitcode-cli/insight.git
cd insight

# 创建虚拟环境
python3 -m venv .venv

# 激活虚拟环境
# Linux/macOS:
source .venv/bin/activate
# Windows:
# .venv\Scripts\activate

# 安装(开发模式,包含测试依赖)
pip install -e ".[test]"

# 创建配置文件
cp config/gitcode.json.example config/gitcode.json
# 编辑配置文件,填入 access_token 和 owner

使用示例

# 生成社区看板
gc-insight dashboard

# 分析单个仓库
gc-insight issue --repo kernel --owner openeuler --token your_token --days 7
gc-insight pr --repo kernel --owner openeuler --token your_token --days 7
gc-insight repo-stats --repo kernel --owner openeuler --token your_token --days 7
gc-insight report --repo kernel --owner openeuler --token your_token --days 7

配置

配置文件 config/gitcode.json:

{
    "access_token": "your_gitcode_access_token",
    "owner": "your_organization_name",
    "label_ci_success": "ci-pipeline-passed",
    "label_ci_running": "ci-pipeline-running",
    "label_yellow_ci_running": "SC-RUNNING",
    "label_yellow_ci_success": "SC-SUCC",
    "repo_whitelist": ["repo1", "repo2"],
    "repo_blacklist": ["repo3", "repo4"]
}

必选参数

字段 说明
access_token GitCode API 访问令牌,用于 API 认证
owner 组织/社区名称,如 openeuler、boostkit

可选参数

字段 默认值 说明
label_ci_success ci-pipeline-passed 蓝区 CI 通过标签名称
label_ci_running ci-pipeline-running 蓝区 CI 运行中标签名称
label_yellow_ci_running SC-RUNNING 黄区 CI 运行中标签名称
label_yellow_ci_success SC-SUCC 黄区 CI 通过标签名称
repo_whitelist [] 仓库白名单,仅统计指定仓库(与黑名单互斥,优先使用)
repo_blacklist [] 仓库黑名单,排除指定仓库

获取 Access Token:GitCode → 设置 → 访问令牌 → 创建新令牌

输出产物

所有命令执行后生成三种标准产物,保存在 ./output/ 目录:

格式 说明 用途
.json 原始数据 + 统计计算数据 数据存档、二次开发
.md Markdown 格式总结报告 文档集成、Git 提交
.html HTML 格式可视化报告 浏览器查看、分享展示

示例:

output/
├── issue_insight_kvrocks_30d.json    # Issue 数据
├── issue_insight_kvrocks_30d.md      # Issue Markdown 报告
├── issue_insight_kvrocks_30d.html    # Issue 可视化报告
├── pr_insight_kvrocks_30d.json
├── pr_insight_kvrocks_30d.md
├── pr_insight_kvrocks_30d.html
├── report_openeuler_kernel_30d.json
├── report_openeuler_kernel_30d.md
└── report_openeuler_kernel_30d.html

常见问题

Q: 输出文件在哪里? A: 默认保存在 ./output/ 目录。

Q: 请求频繁失败怎么办? A: GitCode API 每分钟限制 100 次请求,工具已内置限流处理。如遇问题,等待几分钟后重试。

Q: CSV 文件中文乱码? A: 文件使用 UTF-8-BOM 编码,Excel 可正常打开。

Q: 安装时报错 externally-managed-environment? A: 这是 Debian/Ubuntu 系统(Python 3.11+)的保护机制,防止破坏系统 Python 环境。请使用虚拟环境安装:

# 创建虚拟环境
python3 -m venv .venv

# 激活虚拟环境
source .venv/bin/activate  # Linux/macOS
# .venv\Scripts\activate   # Windows

# 安装
pip install gitcode-insight

文档

许可证

MIT License

Metadata

Release files for gitcode-insight 0.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gitcode-insight 0.1.2
File Size Uploaded
gitcode_insight-0.1.2.tar.gz 55.6 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gitcode-insight 0.1.2
File Interpreter ABI Platform
gitcode_insight-0.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 104.2 kB

Release files / gitcode_insight-0.1.2.tar.gz

Download URL gitcode_insight-0.1.2.tar.gz
Size 55.6 kB
Tags Source
SHA-256 checksum
How to use checksums
ea05e2c3dc5cb8c3fed46e693389be53fb58c66f634ba3ed871a2077d7c1a1b1
BLAKE2b-256 checksum
How to use checksums
2ae20e64c69626adf123f526d37df6465ece72e2ec0bbc5bc7fd507b6ec1d15a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release files / gitcode_insight-0.1.2-py3-none-any.whl

Download URL gitcode_insight-0.1.2-py3-none-any.whl
Size 48.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fb06bca10213c7617a54a24ed11fb25c3774278eacf572c16b45459b110fe3ae
BLAKE2b-256 checksum
How to use checksums
4e2d3415ccd474d3cc237e680fee18be1cd9edf96b516f99fec97caf9728eaed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Mar 23, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.2 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page