Skip to main content

GitCode 平台代码洞察工具

Project description

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 组织/社区名称,如 openeulerboostkit

可选参数

字段 默认值 说明
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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

gitcode_insight-0.1.2.tar.gz (55.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gitcode_insight-0.1.2-py3-none-any.whl (48.6 kB view details)

Uploaded Python 3

File details

Details for the file gitcode_insight-0.1.2.tar.gz.

File metadata

  • Download URL: gitcode_insight-0.1.2.tar.gz
  • Upload date:
  • Size: 55.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for gitcode_insight-0.1.2.tar.gz
Algorithm Hash digest
SHA256 ea05e2c3dc5cb8c3fed46e693389be53fb58c66f634ba3ed871a2077d7c1a1b1
MD5 bdd944fabb9b15592f007c3e2dc86351
BLAKE2b-256 2ae20e64c69626adf123f526d37df6465ece72e2ec0bbc5bc7fd507b6ec1d15a

See more details on using hashes here.

Provenance

The following attestation bundles were made for gitcode_insight-0.1.2.tar.gz:

Publisher: build.yml on kerer-ai/insight

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file gitcode_insight-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for gitcode_insight-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 fb06bca10213c7617a54a24ed11fb25c3774278eacf572c16b45459b110fe3ae
MD5 149ed6819e556be4e98b7bc2e5fbb488
BLAKE2b-256 4e2d3415ccd474d3cc237e680fee18be1cd9edf96b516f99fec97caf9728eaed

See more details on using hashes here.

Provenance

The following attestation bundles were made for gitcode_insight-0.1.2-py3-none-any.whl:

Publisher: build.yml on kerer-ai/insight

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page