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
46 changes: 37 additions & 9 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,49 @@
# Changelog

All notable changes to the Git Integration plugin are documented in this file. The format follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## 0.1.4

### Fixed

- **The panel crashed in every project that was not a Git repository.** 0.1.3 announced a "Create Git Repository" view, but the render path behind it was never implemented, so opening a project outside a repository raised `AttributeError`. The view now exists and `git init` runs from it.
- **The panel operated on the wrong folder.** `repo_path` was the Editor process working directory, even though the code comment claimed it preferred the Editor's project root. It now resolves `project_context.get_project_root()` and falls back to the working directory only when no project is loaded.
- **The Window-menu label rendered a raw translation key.** The panel declared a title key that was never present in the translation catalog. The Editor resolves panel titles with `t(title_key)`, which returns the key unchanged when it is missing, so the menu showed the literal key name.
- **Clicking the manual refresh ran an extra unthrottled `git status`.** The refresh button stored a `time.monotonic()` timestamp while the throttle compared against `time.time()`, so the next frame always looked stale.
- **Collapsing headers lost their open state.** The file count was part of the ImGui widget ID, so staging a file reopened the section.

### Changed

- The panel UI is localized in English and Simplified Chinese through `package/editor/translations.json`. Every visible string was previously hardcoded English, while the Chinese usage page implied a Chinese UI.
- The commit button reads "Commit", and the menu path is documented as `Extensions/Git Integration`.
- `runtime/` no longer ships the placeholder `Null` component. The plugin is editor-only and exposes no gameplay components.
- The package summary now describes the feature set, and has a localized Chinese variant.

### Removed

- The unused `files_status_list` state left over from the status refactor.

### Documentation

- The README, changelog, and in-editor usage pages were rewritten to match the code. The Chinese README no longer carried the "plugin template" title.
- Added `ROADMAP.md`, `CONTRIBUTING.md`, and `RELEASING.md`.

## 0.1.3

> The "Create Git Repository" view announced below was not wired up in this version. It was completed in 0.1.4.

### Added
- Repository detection via `git rev-parse --is-inside-work-tree`; the panel now renders a dedicated "Create Git Repository" view when the project is not yet a Git repository.

- Repository detection via `git rev-parse --is-inside-work-tree`; the panel renders a dedicated "Create Git Repository" view when the project is not yet a Git repository.
- One-click repository initialization (`git init`) directly from the panel.
- VS Code-style staging: a per-file `+` button in the Changes list, plus a "Stage all" action.
- Unstaging via a per-file `-` button, including support for repositories with no commits yet.
- Commit workflow with a persistent message buffer, empty-message validation, and immediate status refresh after commit.
- Manual refresh button to force `git status` without waiting for the throttle interval.
- Files with dual status (e.g. `AM`) are now shown in both "Staged Changes" and "Changes", matching `git status` behavior.
### Planned
- Branch display and switching.
- File status coloring (Modified / Added / Deleted / Untracked).
- Discard changes action for unstaged files.
- Push / Pull controls.
- Diff preview for tracked files.
- Asynchronous `git status` execution to keep the editor responsive on large repositories.

### Fixed

- Engine crash caused by calling `subprocess` synchronously from `on_enable`; Git detection is now performed lazily during the first render.
- `exit status 128` when `git status` was executed outside a repository or in the wrong working directory.
- Duplicate ImGui item IDs (`duplicate visible item ID`) caused by repeated `+` / `-` button labels inside loops.
Expand All @@ -27,11 +52,14 @@
- "Stage all" button not responding due to overlapping with the collapsing header's hit area.

### Changed

- Working directory is now always passed explicitly via `cwd=` to every Git subprocess.
- `files_status_list` replaced with three independent collections (`staged_files`, `unstaged_files`, `untracked_files`), allowing a single file to appear in multiple states simultaneously.
- Status parsing now uses `git status --porcelain` and updates the lists atomically, preserving the last known state on transient failures.
- `git status` refresh is throttled to once per second to avoid spawning a subprocess every frame.

## 0.1.2

- Refactor example plugin name.
### Changed

- Replaced the example plugin name with the real name.
44 changes: 36 additions & 8 deletions CHANGELOG.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,49 @@
# 更新日志

Git 集成插件的所有重要变更都记录在本文件中。格式遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循[语义化版本](https://semver.org/lang/zh-CN/)。

## 0.1.4

### 修复

- **项目文件夹不是 Git 仓库时面板直接崩溃。** 0.1.3 声称加入了「创建 Git 仓库」界面,但背后的渲染路径从未实现,打开非仓库项目会抛出 `AttributeError`。现在该界面已实现,并可在其中执行 `git init`。
- **面板作用在了错误的目录上。** `repo_path` 之前是 Editor 进程的工作目录,尽管代码注释写着「优先从引擎获取项目根」。现在改为解析 `project_context.get_project_root()`,只有在没有打开项目时才回退到工作目录。
- **窗口菜单里显示的是原始翻译键名。** 面板声明了一个翻译目录里根本不存在的标题键,而编辑器用 `t(title_key)` 解析面板标题,查不到时原样返回键名,于是菜单里直接显示了键名字符串。
- **点击手动刷新会多跑一次未节流的 `git status`。** 刷新按钮记录的是 `time.monotonic()` 时间戳,而节流比较用的是 `time.time()`,导致下一帧总是判定为「已过期」。
- **折叠标题会丢失展开状态。** 文件数量被编进了 ImGui 控件 ID,暂存一个文件就会让该区块重新展开。

### 变更

- 面板界面通过 `package/editor/translations.json` 支持英文与简体中文。此前所有可见文案都是硬编码英文,而中文使用页却暗示有中文界面。
- 提交按钮文案为「提交」,菜单路径文档统一为 `Extensions/Git Integration`。
- `runtime/` 不再附带占位的 `Null` 组件。本插件仅在编辑器中使用,不提供任何游戏运行时组件。
- 包简介改为描述实际功能集,并新增了中文本地化简介。

### 移除

- 状态重构后遗留的未使用状态 `files_status_list`。

### 文档

- README、更新日志与编辑器内使用页全部重写,与代码保持一致。中文 README 不再使用「插件模板」这一标题。
- 新增 `ROADMAP.md`、`CONTRIBUTING.md` 与 `RELEASING.md`。

## 0.1.3

> 下方提到的「创建 Git 仓库」界面在本版本中并未接通,实际是在 0.1.4 才完成的。

### 新增

- 使用 `git rev-parse --is-inside-work-tree` 检测仓库;项目尚未初始化 Git 时,面板会显示独立的「创建 Git 仓库」界面。
- 可在面板中一键初始化仓库(`git init`)。
- 仿 VS Code 的暂存操作:Changes 列表每个文件右侧提供 `+` 按钮,并提供「Stage all」整体暂存。
- 支持逐个文件取消暂存(`-` 按钮),兼容尚无任何提交的仓库。
- 提交流程:持久化提交消息缓冲区、空消息校验,以及提交后立即刷新状态。
- 手动刷新按钮,可绕过节流间隔强制执行 `git status`。
- 双状态文件(如 `AM`)现在会同时出现在「Staged Changes」与「Changes」中,与 `git status` 的行为一致。
### 计划
- 分支显示与切换。
- 文件状态着色(Modified / Added / Deleted / Untracked)。
- 未暂存文件的「放弃更改」(Discard changes)操作。
- Push / Pull 控制。
- 已跟踪文件的 Diff 预览。
- 异步执行 `git status`,在大仓库中保持编辑器响应。

### 修复

- 在 `on_enable` 中同步调用 `subprocess` 导致引擎崩溃;Git 探测改为首次渲染时惰性执行。
- 在仓库外或错误工作目录中执行 `git status` 时返回 `exit status 128`。
- 循环内 `+` / `-` 按钮标签重复导致的 ImGui ID 冲突(`duplicate visible item ID`)。
Expand All @@ -27,11 +52,14 @@
- 「Stage all」按钮与折叠标题点击区域重叠导致无响应。

### 变更

- 所有 Git 子进程调用现在都通过 `cwd=` 显式指定工作目录。
- 以 `staged_files`、`unstaged_files`、`untracked_files` 三个独立集合取代 `files_status_list`,允许同一文件同时处于多个状态。
- 状态解析改用 `git status --porcelain`,并以原子方式更新列表;临时失败时保留上一次的已知状态。
- `git status` 刷新节流为每秒最多一次,避免每帧启动子进程。

## 0.1.2

- 重建插件引擎实例名称。
### 变更

- 将示例名称替换为真实名称。
55 changes: 55 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# Contributing

Thanks for helping improve the Git Integration plugin.

## Getting set up

The project has no third-party dependencies — the Python standard library is enough.

```bash
git clone git@github.com:Wokrlie/InxGitIntegration.git
cd InxGitIntegration
python .infernux-dev/validate.py
python -m unittest discover -s tests
```

## Branches

- `main` — released code. Every commit here has passed CI.
- `dev` — the integration branch. Feature work lands here through a pull request.

## Commit messages

Use a short imperative subject line, optionally with a conventional-commit prefix:

```
feat: add branch switching to the panel
fix: keep the commit message buffer across renders
docs: align the usage page with the panel layout
```

The prefix set is `feat`, `fix`, `docs`, `refactor`, `test`, `chore`, `build`, `ci`.

## Before you open a pull request

Run the checks that CI runs:

```bash
python .infernux-dev/validate.py
python -m unittest discover -s tests
python package.py build dist/plugin.inxpkg && python package.py verify dist/plugin.inxpkg
```

## Documentation rules

- Every English page under `package/plugin_pages/` needs a matching `.zh-CN.md` file. The validator rejects the package otherwise.
- Keep the two languages in sync — a change to `usage.md` needs the same change to `usage.zh-CN.md`.
- User-visible strings belong in `package/editor/translations.json`, not inline in the panel. Both locales must declare the same key set, and every key must be namespaced under `wokrlie.git_integration.`.
- Record new work under an `## Unreleased` heading in both `CHANGELOG.md` and `CHANGELOG.zh-CN.md`.

## Code conventions

- The Editor half of the plugin lives in `package/editor/`, the player-facing half in `package/runtime/`. Runtime code must not import Editor modules; the validator enforces that boundary.
- Every `git` call must pass `cwd=` explicitly so the panel always operates on the folder open in the Editor.
- Use `subprocess.run` with a timeout. The render thread must never block indefinitely.
- Panel state that survives a render lives on the instance; it is never stored in a module-level global.
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2026 Plugin Authors
Copyright (c) 2026 Wokrlie

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
85 changes: 83 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,89 @@
# Infernux Git Integration

This repository for integrating git managing for Infernux Engine.
A source control panel for the [Infernux Engine](https://github.com/ChenlizheMe/Infernux). Stage, unstage, and commit straight from the editor — no terminal required.

[简体中文](README.zh-CN.md) · [Infernux Engine](https://github.com/ChenlizheMe/Infernux)
[简体中文](README.zh-CN.md) · [Infernux Engine](https://github.com/ChenlizheMe/Infernux) · [Plugin development docs](https://github.com/ChenlizheMe/Infernux/tree/master/docs)

[![Validate and Release Plugin](https://github.com/Wokrlie/InxGitIntegration/actions/workflows/validate.yml/badge.svg)](https://github.com/Wokrlie/InxGitIntegration/actions/workflows/validate.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

## Features

- One-click `git init` when the open project folder is not a repository yet.
- VS Code-style staging: a `+` button per file, plus **Stage all** (equivalent to `git add -A`).
- Unstaging with a `−` button per file, including in repositories that have no commits yet.
- Commit flow with a persistent message buffer and empty-message validation.
- Automatic refresh of the file lists, plus a manual refresh button.
- Files with a dual status (for example `AM`) appear in both lists, matching `git status`.
- Localized panel UI in English and Simplified Chinese.

## Requirements

| Requirement | Version |
| --- | --- |
| Infernux Engine | `>=0.4.1,<0.5` |
| Git | A recent version available on your `PATH` |

Git is a **runtime requirement**. The panel shells out to the `git` executable; when it is missing, the panel shows a short notice instead of the file lists.

## Installation

### From a release

1. Download `wokrlie.git_integration.inxpkg` from the [Releases page](https://github.com/Wokrlie/InxGitIntegration/releases).
2. In the Editor, open `Extensions/Plugins` and install the downloaded archive.

The Editor checks the archive against the engine version declared in `package/inx_package.json` and refuses to install an incompatible build.

### From source

```bash
python package.py build dist/wokrlie.git_integration.inxpkg
```

The build is deterministic — two runs over the same source produce byte-identical archives.

## Usage

Open `Extensions/Git Integration` in the menu bar. The panel acts on the project folder currently open in the editor.

The full walkthrough lives in [`package/plugin_pages/usage.md`](package/plugin_pages/usage.md), which also ships inside the package as the in-editor usage page.

## Troubleshooting

**The panel reports that Git is not usable.** Git is not installed, or the Editor was started with a `PATH` that does not include it. Install Git and restart the Editor.

**Commit does nothing.** The commit message box is empty. Enter a message first.

**`git commit` fails asking who you are.** Git has no identity configured. Run:

```bash
git config --global user.name "Your Name"
git config --global user.email "you@example.com"
```

**The panel shows files you did not expect.** The panel follows the folder open in the Editor, not the folder the Editor binary lives in.

## Development

```bash
python .infernux-dev/validate.py # package layout and Python sources
python -m unittest discover -s tests # validation and release contracts
python package.py build dist/plugin.inxpkg # deterministic build
python package.py verify dist/plugin.inxpkg # verify a built archive
```

The Editor-only code lives in `package/editor/`, and the runtime surface in `package/runtime/`. `package/plugin_pages/` holds the in-editor documentation, and every English page must have a matching `.zh-CN.md` sibling — the validator enforces this.

## Documentation

| Document | Purpose |
| --- | --- |
| [package/plugin_pages/usage.md](package/plugin_pages/usage.md) | In-editor usage guide (English) |
| [package/plugin_pages/usage.zh-CN.md](package/plugin_pages/usage.zh-CN.md) | In-editor usage guide (Simplified Chinese) |
| [ROADMAP.md](ROADMAP.md) | Planned features |
| [CONTRIBUTING.md](CONTRIBUTING.md) | Contribution and commit conventions |
| [RELEASING.md](RELEASING.md) | Release procedure |

## License

Expand Down
85 changes: 83 additions & 2 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,90 @@
# Infernux 插件模板
# Infernux Git 集成

这是 [Infernux](https://github.com/ChenlizheMe/Infernux) 引擎的一个版本管理简单集成。
[Infernux 引擎](https://github.com/ChenlizheMe/Infernux)的版本管理面板。直接在编辑器里完成暂存、取消暂存和提交——不用切到终端。

[English](README.md) · [Infernux 引擎](https://github.com/ChenlizheMe/Infernux) · [插件开发文档](https://github.com/ChenlizheMe/Infernux/tree/master/docs) · [官方插件](https://github.com/ChenlizheMe/Infernux#plugins)

[![Validate and Release Plugin](https://github.com/Wokrlie/InxGitIntegration/actions/workflows/validate.yml/badge.svg)](https://github.com/Wokrlie/InxGitIntegration/actions/workflows/validate.yml)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)

## 功能

- 项目文件夹还不是仓库时,可一键执行 `git init`。
- 仿 VS Code 的暂存操作:每个文件右侧一个 `+` 按钮,外加**暂存全部**(等价于 `git add -A`)。
- 逐个文件取消暂存(`−` 按钮),仓库还没有任何提交时同样可用。
- 提交流程:消息缓冲区持久保留,空消息会被拦截。
- 文件列表自动刷新,并提供手动刷新按钮。
- 双状态文件(例如 `AM`)会同时出现在两个列表中,与 `git status` 的行为一致。
- 面板界面支持英文与简体中文。

## 环境要求

| 依赖 | 版本 |
| --- | --- |
| Infernux 引擎 | `>=0.4.1,<0.5` |
| Git | `PATH` 中可用的较新版本 |

Git 是**运行时依赖**。面板通过 `git` 可执行文件完成所有操作;Git 缺失时,面板会显示一条简短提示而不是文件列表。

## 安装

### 从发布页安装

1. 从 [Releases 页面](https://github.com/Wokrlie/InxGitIntegration/releases)下载 `wokrlie.git_integration.inxpkg`。
2. 在编辑器中打开 `扩展/插件`,安装下载的归档文件。

编辑器会对照 `package/inx_package.json` 中声明的引擎版本检查归档文件,并拒绝安装不兼容的版本。

### 从源码构建

```bash
python package.py build dist/wokrlie.git_integration.inxpkg
```

构建是确定性的——同一份源码构建两次会得到字节完全相同的归档文件。

## 使用

在菜单栏打开 `扩展/Git 集成`。面板作用于编辑器中当前打开的项目文件夹。

完整说明见 [`package/plugin_pages/usage.zh-CN.md`](package/plugin_pages/usage.zh-CN.md),该文件也会随包发布,成为编辑器内的使用页。

## 故障排查

**面板提示当前环境无法使用 Git。** 系统没有安装 Git,或者 Editor 启动时的 `PATH` 里找不到它。安装 Git 后重启 Editor。

**点击提交没有任何反应。** 提交信息为空,需要先填写。

**`git commit` 报错询问你的身份。** Git 还没有配置用户信息,执行:

```bash
git config --global user.name "你的名字"
git config --global user.email "you@example.com"
```

**面板显示了预期之外的文件。** 面板跟随的是编辑器中打开的文件夹,而不是 Editor 程序所在的目录。

## 本地开发

```bash
python .infernux-dev/validate.py # 检查包布局与 Python 源码
python -m unittest discover -s tests # 校验与发布相关的契约测试
python package.py build dist/plugin.inxpkg # 确定性构建
python package.py verify dist/plugin.inxpkg # 校验构建产物
```

仅编辑器使用的代码位于 `package/editor/`,运行时接口位于 `package/runtime/`。`package/plugin_pages/` 存放编辑器内文档,每个英文页面都必须有对应的 `.zh-CN.md`——校验器会强制检查这一点。

## 文档

| 文档 | 用途 |
| --- | --- |
| [package/plugin_pages/usage.md](package/plugin_pages/usage.md) | 编辑器内使用说明(英文) |
| [package/plugin_pages/usage.zh-CN.md](package/plugin_pages/usage.zh-CN.md) | 编辑器内使用说明(简体中文) |
| [ROADMAP.md](ROADMAP.md) | 后续计划 |
| [CONTRIBUTING.md](CONTRIBUTING.md) | 贡献与提交规范 |
| [RELEASING.md](RELEASING.md) | 发布流程 |

## 许可证

[MIT](LICENSE)。
Loading
Loading