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",
    "repo_whitelist": ["repo1", "repo2"],
    "repo_blacklist": ["repo3", "repo4"]
}
字段 说明
access_token GitCode API 访问令牌(必填)
owner 组织/社区名称(必填)
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.1.tar.gz (55.3 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.1-py3-none-any.whl (48.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: gitcode_insight-0.1.1.tar.gz
  • Upload date:
  • Size: 55.3 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.1.tar.gz
Algorithm Hash digest
SHA256 86c40bad0074a95e19643a0691a33ef54b4b2e8400508f16e7e4704ff159117a
MD5 59ea6656ab76d10689ac56276b37d722
BLAKE2b-256 ddd5f8e89c488daedff49526b18221a9dd6d4b84e8f6f2f306f0647ab13b26df

See more details on using hashes here.

Provenance

The following attestation bundles were made for gitcode_insight-0.1.1.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.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gitcode_insight-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c02160b1c58e5a0a57fdeb29e18c2e9d8d9e52826b2679a41457aa2137cadfc6
MD5 ae42e3db123244539fa1a637171a22b9
BLAKE2b-256 083b73211b41f0837b94bb00bafc368ee602d9449b75b21ae4df5d671772499c

See more details on using hashes here.

Provenance

The following attestation bundles were made for gitcode_insight-0.1.1-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