From 7a83686bdcb4423180128c280471ed1c03a818f2 Mon Sep 17 00:00:00 2001 From: Wokrlie Date: Sat, 31 Oct 2026 22:16:44 +0800 Subject: [PATCH 1/2] feat: draw the panel with vector icons and coloured file status The stage and unstage controls were text characters, and the Git status code of every file was drawn in the default text colour, so a list of changes read as an undifferentiated wall of paths. Icons come from Lucide, which is free for commercial use under the ISC License. The geometry is embedded in the plugin and rasterized at runtime through the Engine's LunaSVG backend, so the package stays a single deterministic archive and one vector asset can be drawn in any colour. The status code is now drawn in the colour of its change, and the leading icon repeats that meaning as a shape. The code keeps its Git spelling, so a dual state such as AM stays readable. The icon buttons and the status code carry tooltips. An icon button is skipped while its texture is still uploading, which also keeps its tooltip attached to the right widget instead of drifting onto the previous one. THIRD_PARTY_NOTICES.md records the licence of the artwork. --- CHANGELOG.md | 14 ++ CHANGELOG.zh-CN.md | 14 ++ CONTRIBUTING.md | 7 + README.md | 2 + README.zh-CN.md | 2 + RELEASING.md | 8 +- ROADMAP.md | 1 - THIRD_PARTY_NOTICES.md | 65 ++++++ package/editor/translations.json | 26 ++- .../editor/wokrlie/git_integration/icons.py | 197 ++++++++++++++++++ .../editor/wokrlie/git_integration/panel.py | 138 +++++++++--- package/inx_package.json | 2 +- package/plugin_pages/usage.md | 22 +- package/plugin_pages/usage.zh-CN.md | 29 ++- tests/test_icon_assets.py | 99 +++++++++ tests/test_translation_contracts.py | 59 ++++++ 16 files changed, 641 insertions(+), 44 deletions(-) create mode 100644 THIRD_PARTY_NOTICES.md create mode 100644 package/editor/wokrlie/git_integration/icons.py create mode 100644 tests/test_icon_assets.py diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b67933..dadf563 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,20 @@ 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.5 + +### Added + +- Vector icons across the panel. The stage, unstage, stage-all, and refresh controls are now Lucide icons instead of the `+`, `-`, and `⟳` characters, and every file row leads with an icon for its kind of change. +- Coloured file status. The Git status code of each file is now drawn in the colour of that change — added is green, modified is yellow, deleted is red, untracked is cyan, renamed is blue, and a conflict is orange. +- Tooltips on the icon controls and on the status code, naming the action and the kind of change. +- `THIRD_PARTY_NOTICES.md` records the licence of the icon artwork. + +### Changed + +- The icon artwork is embedded in the plugin and rasterized at runtime through the Engine's LunaSVG backend. The package stays a single deterministic archive, and one vector asset can be drawn in any colour. +- The status code keeps its Git spelling, so a dual state such as `AM` stays readable next to its icon. + ## 0.1.4 ### Fixed diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index 82e5156..0898c39 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -2,6 +2,20 @@ Git 集成插件的所有重要变更都记录在本文件中。格式遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/),版本号遵循[语义化版本](https://semver.org/lang/zh-CN/)。 +## 0.1.5 + +### 新增 + +- 面板全面使用矢量图标。暂存、取消暂存、暂存全部和刷新按钮改用 Lucide 图标,不再是 `+`、`-`、`⟳` 这几个字符;每个文件行前也会显示一个表示变更类型的图标。 +- 文件状态着色。每个文件的 Git 状态码现在按变更类型着色——新增为绿色,修改为黄色,删除为红色,未跟踪为青色,重命名为蓝色,冲突为橙色。 +- 图标按钮和状态码上增加了悬浮提示,说明该操作和该变更类型。 +- 新增 `THIRD_PARTY_NOTICES.md`,记录图标素材的许可证。 + +### 变更 + +- 图标素材内嵌在插件中,并在运行时通过引擎的 LunaSVG 后端光栅化。插件包仍然是一个确定性的归档,同一份矢量素材可以以任意颜色绘制。 +- 状态码保留 Git 原本的写法,因此像 `AM` 这样的双状态在图标旁边依然可读。 + ## 0.1.4 ### 修复 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 108eef5..950e583 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -53,3 +53,10 @@ python package.py build dist/plugin.inxpkg && python package.py verify dist/plug - 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. + +## Icons and artwork + +- Icons come from [Lucide](https://lucide.dev), which is free for commercial use under the ISC License. The geometry lives in `package/editor/wokrlie/git_integration/icons.py`. +- Icons are embedded in the module rather than shipped as files, so the plugin never depends on where its package is unpacked and the build stays byte-for-byte deterministic. +- Any new artwork must come from a permissive licence and be recorded in `THIRD_PARTY_NOTICES.md` before it ships. +- The icons are rasterized at runtime through the Engine's LunaSVG backend. ImGui itself cannot draw SVG, so do not expect the vector source to reach the renderer. diff --git a/README.md b/README.md index 4b2808c..4a7c67e 100644 --- a/README.md +++ b/README.md @@ -15,6 +15,7 @@ A source control panel for the [Infernux Engine](https://github.com/ChenlizheMe/ - 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`. +- Vector icons for the stage, unstage, stage-all, and refresh controls, plus a status icon and a coloured status code on every file row. - Localized panel UI in English and Simplified Chinese. ## Requirements @@ -84,6 +85,7 @@ The Editor-only code lives in `package/editor/`, and the runtime surface in `pac | [ROADMAP.md](ROADMAP.md) | Planned features | | [CONTRIBUTING.md](CONTRIBUTING.md) | Contribution and commit conventions | | [RELEASING.md](RELEASING.md) | Release procedure | +| [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) | Licences of the bundled icon artwork | ## License diff --git a/README.zh-CN.md b/README.zh-CN.md index 0231ea5..5d969ba 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -15,6 +15,7 @@ - 提交流程:消息缓冲区持久保留,空消息会被拦截。 - 文件列表自动刷新,并提供手动刷新按钮。 - 双状态文件(例如 `AM`)会同时出现在两个列表中,与 `git status` 的行为一致。 +- 暂存、取消暂存、暂存全部和刷新按钮使用矢量图标;每个文件行还带有状态图标和带颜色的状态码。 - 面板界面支持英文与简体中文。 ## 环境要求 @@ -84,6 +85,7 @@ python package.py verify dist/plugin.inxpkg # 校验构建产物 | [ROADMAP.md](ROADMAP.md) | 后续计划 | | [CONTRIBUTING.md](CONTRIBUTING.md) | 贡献与提交规范 | | [RELEASING.md](RELEASING.md) | 发布流程 | +| [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) | 内置图标素材的许可证 | ## 许可证 diff --git a/RELEASING.md b/RELEASING.md index e909cf9..ea55ac2 100644 --- a/RELEASING.md +++ b/RELEASING.md @@ -10,7 +10,7 @@ Releases are produced by GitHub Actions. No artifact is uploaded by hand. | Engine compatibility | `package/inx_package.json` → `engine` | | Release notes | `CHANGELOG.md` and `CHANGELOG.zh-CN.md` | -The release tag must match the manifest version exactly — `v0.1.4` for version `0.1.4`. `package.py release-manifest` fails on any mismatch, so a mistyped tag stops the release instead of publishing a mislabelled archive. +The release tag must match the manifest version exactly — `v0.1.5` for version `0.1.5`. `package.py release-manifest` fails on any mismatch, so a mistyped tag stops the release instead of publishing a mislabelled archive. ## Procedure @@ -19,8 +19,8 @@ The release tag must match the manifest version exactly — `v0.1.4` for version 3. Tag the merge commit and push the tag: ```bash - git tag v0.1.4 - git push origin v0.1.4 + git tag v0.1.5 + git push origin v0.1.5 ``` 4. The `release` job runs on the tag. It builds the archive, verifies it, checks that two independent builds are byte-identical, generates `infernux-plugin-release.json`, and publishes both files as GitHub Release assets. @@ -44,7 +44,7 @@ Because of this, a fix for a published version needs a **new** version number. N python package.py build dist/wokrlie.git_integration.inxpkg python package.py verify dist/wokrlie.git_integration.inxpkg python package.py release-manifest dist/wokrlie.git_integration.inxpkg \ - --tag v0.1.4 --output dist/infernux-plugin-release.json + --tag v0.1.5 --output dist/infernux-plugin-release.json ``` The build is deterministic: running it twice over the same source must produce byte-identical archives, which is what CI asserts before it publishes anything. diff --git a/ROADMAP.md b/ROADMAP.md index a7b7d34..a52c6a1 100644 --- a/ROADMAP.md +++ b/ROADMAP.md @@ -5,7 +5,6 @@ Planned work for the Git Integration plugin. Delivered changes are recorded in [ ## Next - **Branch display and switching** — show the current branch, and let the user switch or create branches from the panel. -- **File status coloring** — distinguish Modified / Added / Deleted / Untracked entries in both file lists. - **Discard changes** — revert the unstaged modifications of a single file. - **Push / Pull controls** — fetch, pull, and push without leaving the Editor. - **Diff preview** — show the content diff of a tracked file. diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md new file mode 100644 index 0000000..d8d72a0 --- /dev/null +++ b/THIRD_PARTY_NOTICES.md @@ -0,0 +1,65 @@ +# Third-Party Notices + +The Git Integration plugin ships artwork that comes from third-party open +source projects. The notices below reproduce the licenses those projects +require. + +## Lucide + +The icon geometry in `package/editor/wokrlie/git_integration/icons.py` is +taken from [Lucide](https://lucide.dev) (release 0.544.0), licensed under the +ISC License. + +``` +ISC License + +Copyright (c) 2026 Lucide Icons and Contributors + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +``` + +## Feather Icons + +Two of the icons used here — `plus` and `minus` — are derived from the +Feather project and are covered by the MIT License reproduced below. Every +other icon is original Lucide artwork under the ISC License above. + +``` +The MIT License (MIT) + +Copyright (c) 2013-present Cole Bemis + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +## Infernux Engine + +The plugin runs inside the Infernux Engine and uses its LuaSVG-based texture +rasterizer to turn the vector artwork above into ImGui textures at runtime. +The Engine is licensed separately by its authors. diff --git a/package/editor/translations.json b/package/editor/translations.json index afe35ad..580099d 100644 --- a/package/editor/translations.json +++ b/package/editor/translations.json @@ -14,7 +14,18 @@ "wokrlie.git_integration.create_repository": "Create Git Repository", "wokrlie.git_integration.not_a_repository": "This folder is not a Git repository yet.", "wokrlie.git_integration.repository_folder": "Repository folder", - "wokrlie.git_integration.git_unavailable": "Git is not usable in the current environment." + "wokrlie.git_integration.git_unavailable": "Git is not usable in the current environment.", + "wokrlie.git_integration.refresh": "Refresh now", + "wokrlie.git_integration.stage_file": "Stage this file", + "wokrlie.git_integration.unstage_file": "Unstage this file", + "wokrlie.git_integration.status_added": "Added", + "wokrlie.git_integration.status_modified": "Modified", + "wokrlie.git_integration.status_deleted": "Deleted", + "wokrlie.git_integration.status_renamed": "Renamed", + "wokrlie.git_integration.status_copied": "Copied", + "wokrlie.git_integration.status_conflicted": "Conflicted", + "wokrlie.git_integration.status_untracked": "Untracked", + "wokrlie.git_integration.status_ignored": "Ignored" }, "zh": { "wokrlie.git_integration.menu_root": "Git 集成", @@ -29,7 +40,18 @@ "wokrlie.git_integration.create_repository": "创建 Git 仓库", "wokrlie.git_integration.not_a_repository": "当前文件夹还不是 Git 仓库。", "wokrlie.git_integration.repository_folder": "仓库目录", - "wokrlie.git_integration.git_unavailable": "当前环境无法使用 Git。" + "wokrlie.git_integration.git_unavailable": "当前环境无法使用 Git。", + "wokrlie.git_integration.refresh": "立即刷新", + "wokrlie.git_integration.stage_file": "暂存此文件", + "wokrlie.git_integration.unstage_file": "取消暂存此文件", + "wokrlie.git_integration.status_added": "已添加", + "wokrlie.git_integration.status_modified": "已修改", + "wokrlie.git_integration.status_deleted": "已删除", + "wokrlie.git_integration.status_renamed": "已重命名", + "wokrlie.git_integration.status_copied": "已复制", + "wokrlie.git_integration.status_conflicted": "存在冲突", + "wokrlie.git_integration.status_untracked": "未跟踪", + "wokrlie.git_integration.status_ignored": "已忽略" } } } diff --git a/package/editor/wokrlie/git_integration/icons.py b/package/editor/wokrlie/git_integration/icons.py new file mode 100644 index 0000000..83929ec --- /dev/null +++ b/package/editor/wokrlie/git_integration/icons.py @@ -0,0 +1,197 @@ +"""Vector icons for the Git panel. + +The icon geometry comes from Lucide (https://lucide.dev), which is released +under the ISC License and is free for commercial use. The ISC license asks +that the copyright notice travels with redistributed copies, so it is +reproduced in ``THIRD_PARTY_NOTICES.md`` at the repository root. + +Every icon is stored as the inner markup of a 24x24 Lucide SVG. They are +rasterized at runtime through the Engine's LunaSVG backend and uploaded as +pinned ImGui textures, so one vector asset can be drawn in any colour without +shipping a pre-rendered PNG per colour. + +Icons are embedded in the module rather than shipped as files so that the +plugin never depends on where its package happens to be unpacked, and so the +build stays byte-for-byte deterministic. +""" + +from __future__ import annotations + +from infernux import Debug +from infernux.lib import TextureLoader + + +#: Version of the Lucide release the geometry below was taken from. +LUCIDE_VERSION = "0.544.0" + +#: Inner markup of each 24x24 Lucide SVG, keyed by the name used here. +ICON_PATHS: dict[str, str] = { + # -- action buttons ------------------------------------------------- + "stage": '', + "unstage": '', + "stage-all": ( + '' + '' + ), + "refresh": ( + '' + '' + '' + '' + ), + # -- file status ---------------------------------------------------- + "added": ( + '' + '' + '' + ), + "modified": ( + '' + '' + '' + ), + "deleted": ( + '' + '' + '' + ), + "renamed": ( + '' + '' + '' + ), + "copied": ( + '' + '' + ), + "conflicted": ( + '' + '' + ), + "untracked": ( + '' + '' + '' + ), + "ignored": ( + '' + '' + '' + '' + ), +} + +#: Git porcelain status code -> icon name. +STATUS_ICONS: dict[str, str] = { + "A": "added", + "M": "modified", + "D": "deleted", + "R": "renamed", + "C": "copied", + "U": "conflicted", + "?": "untracked", + "!": "ignored", +} + +#: Git porcelain status code -> RGBA colour. +STATUS_COLORS: dict[str, tuple[float, float, float, float]] = { + "A": (0.30, 0.76, 0.45, 1.0), # green + "M": (0.89, 0.71, 0.30, 1.0), # yellow + "D": (0.92, 0.34, 0.34, 1.0), # red + "R": (0.45, 0.65, 0.95, 1.0), # blue + "C": (0.45, 0.65, 0.95, 1.0), # blue + "U": (0.95, 0.55, 0.20, 1.0), # orange + "?": (0.40, 0.72, 0.88, 1.0), # cyan + "!": (0.55, 0.55, 0.55, 1.0), # grey +} + +#: Git porcelain status code -> translation key naming that status. +STATUS_LABELS: dict[str, str] = { + "A": "wokrlie.git_integration.status_added", + "M": "wokrlie.git_integration.status_modified", + "D": "wokrlie.git_integration.status_deleted", + "R": "wokrlie.git_integration.status_renamed", + "C": "wokrlie.git_integration.status_copied", + "U": "wokrlie.git_integration.status_conflicted", + "?": "wokrlie.git_integration.status_untracked", + "!": "wokrlie.git_integration.status_ignored", +} + +#: Neutral colour for the action buttons, matching the Engine text tone. +NEUTRAL_COLOR = (0.84, 0.84, 0.84, 1.0) + + +def _to_hex(color: tuple[float, float, float, float]) -> str: + """Convert an RGBA float tuple into an ``#rrggbb`` string.""" + r, g, b = (max(0.0, min(1.0, channel)) for channel in color[:3]) + return "#{:02x}{:02x}{:02x}".format( + int(round(r * 255.0)), int(round(g * 255.0)), int(round(b * 255.0)) + ) + + +def _svg_document(body: str, color: str, edge: int) -> bytes: + """Build a standalone SVG document for one Lucide icon.""" + return ( + '{body}' + ).format(edge=edge, color=color, body=body).encode("utf-8") + + +class IconCache: + """Rasterize Lucide icons and publish them as pinned ImGui textures. + + The Engine uploads textures asynchronously, so an icon can report a + texture id of ``0`` for the first frames while it is still in flight. + Nothing is cached in that case, and the next render retries. + """ + + def __init__(self, native_engine, edge: int = 32) -> None: + self._native = native_engine + self._edge = max(8, int(edge)) + self._textures: dict[tuple[str, str], int] = {} + + def get(self, name: str, color: tuple[float, float, float, float] = NEUTRAL_COLOR) -> int: + """Return the ImGui texture id for *name* in *color*, or ``0``.""" + body = ICON_PATHS.get(name) + if body is None or self._native is None: + return 0 + + hex_color = _to_hex(color) + key = (name, hex_color) + cached = self._textures.get(key) + if cached: + return cached + + texture_name = f"wokrlie.git_integration.icon.{name}.{hex_color[1:]}" + try: + if not self._native.has_imgui_texture(texture_name): + image = TextureLoader.load_from_memory( + _svg_document(body, hex_color, self._edge), + svg_max_size=self._edge, + ) + if image is None or not image.is_valid(): + return 0 + self._native.submit_imgui_texture( + texture_name, + image.get_pixels(), + int(image.width), + int(image.height), + False, + True, + ) + texture_id = int(self._native.get_imgui_texture_id(texture_name) or 0) + except RuntimeError as exc: + Debug.log_suppressed("GitIntegrationPanel.icon", exc) + return 0 + + if texture_id: + self._textures[key] = texture_id + return texture_id + + def status_icon(self, status: str) -> int: + """Return the texture id for a git porcelain status code.""" + name = STATUS_ICONS.get(status) + if name is None: + return 0 + return self.get(name, STATUS_COLORS.get(status, NEUTRAL_COLOR)) diff --git a/package/editor/wokrlie/git_integration/panel.py b/package/editor/wokrlie/git_integration/panel.py index d731e71..82f8a79 100644 --- a/package/editor/wokrlie/git_integration/panel.py +++ b/package/editor/wokrlie/git_integration/panel.py @@ -12,6 +12,9 @@ from infernux.engine.project_context import get_project_root from infernux.engine.ui.editor_panel import EditorPanel from infernux.engine.ui.panel_registry import editor_panel +from infernux.engine.ui.theme import ImGuiCol + +from .icons import IconCache, NEUTRAL_COLOR, STATUS_COLORS, STATUS_LABELS @editor_panel( @@ -46,6 +49,10 @@ def __init__(self) -> None: self._refresh_interval: float = 1.0 self._git_checked: bool = False + self._icons: IconCache | None = None + self._icon_size: float = 16.0 + self._button_size: float = 18.0 + # ------------------------------------------------------------------ # # 生命周期(保持惰性初始化,避免 on_enable 崩溃) # ------------------------------------------------------------------ # @@ -67,6 +74,56 @@ def repo_path(self) -> str: """ return get_project_root() or os.getcwd() + # ------------------------------------------------------------------ # + # 图标(Lucide SVG → 运行时光栅化 → ImGui 纹理) + # ------------------------------------------------------------------ # + def _icon_cache(self) -> IconCache | None: + """Return the icon cache, creating it once the renderer is reachable.""" + if self._icons is None: + try: + services = self.services + native = services.native_engine if services is not None else None + except Exception: # noqa: BLE001 - the panel must never fail to open + native = None + if native is None: + return None + self._icons = IconCache(native) + return self._icons + + def _icon(self, name: str, color=NEUTRAL_COLOR) -> int: + """Return the ImGui texture id for one icon, or ``0`` when unavailable.""" + cache = self._icon_cache() + if cache is None: + return 0 + return cache.get(name, color) + + def _status_icon(self, status: str) -> int: + """Return the ImGui texture id for a git porcelain status code.""" + cache = self._icon_cache() + if cache is None: + return 0 + return cache.status_icon(status) + + def _tooltip(self, ctx, text: str) -> None: + """Show *text* as a tooltip for the widget that was just rendered.""" + if ctx.is_item_hovered(): + ctx.set_tooltip(text) + + def _icon_button(self, ctx, widget_id: str, icon: str, tooltip: str, on_click) -> None: + """Render one icon button, with a tooltip, when its texture exists. + + ``image_button`` silently does nothing while the texture is still + uploading, so the button and its tooltip are skipped together. That + keeps the tooltip attached to the right widget instead of drifting + onto the previous one. + """ + texture = self._icon(icon) + if not texture: + return + if ctx.image_button(widget_id, texture, self._button_size, self._button_size): + on_click() + self._tooltip(ctx, tooltip) + def on_render_content(self, ctx) -> None: if not self._git_checked: self._check_git_availability() @@ -104,7 +161,13 @@ def _render_no_repo_ui(self, ctx) -> None: def _render_git_ui(self, ctx) -> None: ctx.label(t("wokrlie.git_integration.source_control")) ctx.same_line() - ctx.button("⟳##refresh_git", self._manual_refresh, 28.0, 20.0) + self._icon_button( + ctx, + "##refresh_git", + "refresh", + t("wokrlie.git_integration.refresh"), + self._manual_refresh, + ) ctx.begin_group("Changes") try: @@ -130,6 +193,48 @@ def _render_git_ui(self, ctx) -> None: finally: ctx.end_group() + def _render_file_row(self, ctx, path: str, status: str, staged: bool) -> None: + """Render one file row: status icon, path, coloured code, action button. + + The status code keeps its Git spelling so that a dual state such as + ``AM`` stays readable, and it is coloured by the kind of change. The + leading icon repeats that meaning as a shape, which is what carries + the meaning when the code is hard to spot in a dense list. + """ + icon = self._status_icon(status) + if icon: + ctx.image(icon, self._icon_size, self._icon_size) + ctx.same_line() + + ctx.label(path) + ctx.same_line() + + color = STATUS_COLORS.get(status, NEUTRAL_COLOR) + ctx.push_style_color(ImGuiCol.Text, *color) + ctx.label(status) + ctx.pop_style_color() + label_key = STATUS_LABELS.get(status) + if label_key: + self._tooltip(ctx, t(label_key)) + ctx.same_line() + + if staged: + self._icon_button( + ctx, + f"##unstage_{path}", + "unstage", + t("wokrlie.git_integration.unstage_file"), + lambda p=path: self.unstage_file(p), + ) + else: + self._icon_button( + ctx, + f"##stage_{path}", + "stage", + t("wokrlie.git_integration.stage_file"), + lambda p=path: self.stage_file(p), + ) + def _render_staged_section(self, ctx) -> None: expanded = ctx.collapsing_header( f"{t('wokrlie.git_integration.staged_changes')} " @@ -143,14 +248,7 @@ def _render_staged_section(self, ctx) -> None: return for path, status in sorted(self.staged_files.items()): - ctx.label(f" {status} {path}") - ctx.same_line() - ctx.button( - f"-##unstage_{path}", - lambda p=path: self.unstage_file(p), - 20.0, - 18.0, - ) + self._render_file_row(ctx, path, status, staged=True) def _render_changes_section(self, ctx) -> None: total = len(self.unstaged_files) + len(self.untracked_files) @@ -160,6 +258,10 @@ def _render_changes_section(self, ctx) -> None: # Stage all 放到 header 下一行,避免 same_line 遮挡点击区域 if total > 0: + stage_all_icon = self._icon("stage-all") + if stage_all_icon: + ctx.image(stage_all_icon, self._icon_size, self._icon_size) + ctx.same_line() ctx.button( f"{t('wokrlie.git_integration.stage_all')}##stage_all", self.stage_all, @@ -175,24 +277,10 @@ def _render_changes_section(self, ctx) -> None: return for path, status in sorted(self.unstaged_files.items()): - ctx.label(f" {status} {path}") - ctx.same_line() - ctx.button( - f"+##stage_{path}", - lambda p=path: self.stage_file(p), - 20.0, - 18.0, - ) + self._render_file_row(ctx, path, status, staged=False) for path in sorted(self.untracked_files): - ctx.label(f" ? {path}") - ctx.same_line() - ctx.button( - f"+##stage_{path}", - lambda p=path: self.stage_file(p), - 20.0, - 18.0, - ) + self._render_file_row(ctx, path, "?", staged=False) # ------------------------------------------------------------------ # # Git 可用性检测(与仓库检测分离) diff --git a/package/inx_package.json b/package/inx_package.json index b0d98b4..372ec08 100644 --- a/package/inx_package.json +++ b/package/inx_package.json @@ -2,7 +2,7 @@ "$schema": "infernux.inxpackage.source", "reference": "wokrlie/git_integration", "name": "Git Integration", - "version": "0.1.4", + "version": "0.1.5", "engine": ">=0.4.1,<0.5", "intro": "Git source control for the Infernux Engine: stage, unstage, and commit straight from the editor.", "intros": { diff --git a/package/plugin_pages/usage.md b/package/plugin_pages/usage.md index de048c0..8b2f6aa 100644 --- a/package/plugin_pages/usage.md +++ b/package/plugin_pages/usage.md @@ -16,18 +16,28 @@ Git must be installed and reachable on your `PATH`. When it is not, the panel sh The normal view has four parts, from top to bottom: -- **Source Control** — the header. The `⟳` button on the right forces an immediate `git status`, skipping the refresh interval. +- **Source Control** — the header. The refresh icon on the right forces an immediate `git status`, skipping the refresh interval. - **Staged Changes** — files that will be included in the next commit. - **Changes** — files that have been modified or deleted but are not staged yet, plus untracked files. - **Commit area** — a message box and a **Commit** button. A file can appear in both lists at once. For example, a file that was staged and then modified again shows up under Staged Changes and under Changes, so you can tell it has both staged and unstaged content. +## Reading a file row + +Each file row carries three pieces of information: + +- **A status icon** for the kind of change: added, modified, deleted, renamed, copied, conflicted, untracked, or ignored. +- **The file path.** +- **The Git status code**, in the colour of that change — added is green, modified is yellow, deleted is red, untracked is cyan, renamed is blue, and a conflict is orange. The code keeps its Git spelling, so a dual state such as `AM` stays readable. Hover it for the name of the change. + +At the end of the row sits the action button for that file. + ## Staging and unstaging -- To stage a single file, click the `+` button on its row in **Changes**. +- To stage a single file, click the `+` icon on its row in **Changes**. - To stage everything in **Changes** at once, click **Stage all**. -- To unstage a file, click the `−` button on its row in **Staged Changes**. This also works in a repository that has no commits yet. +- To unstage a file, click the `−` icon on its row in **Staged Changes**. This also works in a repository that has no commits yet. **Stage all** is equivalent to `git add -A`: it stages modifications, additions, and deletions. @@ -39,7 +49,7 @@ A file can appear in both lists at once. For example, a file that was staged and ## Refreshing the file lists -The panel updates the file lists automatically, at most once per second. If you want to see the current state immediately — for example after running Git commands in a terminal — click the `⟳` button in the header. +The panel updates the file lists automatically, at most once per second. If you want to see the current state immediately — for example after running Git commands in a terminal — click the refresh icon in the header. ## Troubleshooting @@ -51,6 +61,8 @@ The panel updates the file lists automatically, at most once per second. If you **A new file never leaves Changes.** Untracked files are marked `?` until they are staged. +**The icons are missing.** The icons are vector artwork that the Editor rasterizes when the panel first opens. If the Editor was started without GPU support, or the textures could not be uploaded, the panel falls back to text-only controls and the status codes still work. + ## Upcoming features -Branch display and switching, file status coloring, discard-changes for unstaged files, Push/Pull controls, diff preview, and asynchronous `git status` execution are planned for future versions. +Branch display and switching, discard-changes for unstaged files, Push/Pull controls, diff preview, and asynchronous `git status` execution are planned for future versions. diff --git a/package/plugin_pages/usage.zh-CN.md b/package/plugin_pages/usage.zh-CN.md index d4bec36..ac09b7a 100644 --- a/package/plugin_pages/usage.zh-CN.md +++ b/package/plugin_pages/usage.zh-CN.md @@ -16,18 +16,28 @@ Git 面板让你直接在 Infernux 编辑器里完成暂存、取消暂存和提 正常界面从上到下分四部分: -- **源代码管理** —— 标题栏。右侧的 `⟳` 按钮会立即执行一次 `git status`,跳过刷新间隔。 +- **源代码管理** —— 标题栏。右侧的刷新图标会立即执行一次 `git status`,跳过刷新间隔。 - **已暂存的更改** —— 下次提交会包含的文件。 - **更改** —— 已修改或删除、但还没暂存的文件,以及未跟踪的文件。 - **提交区** —— 消息输入框和**提交**按钮。 一个文件可以同时出现在两个列表里。例如某个文件暂存之后又被修改,它会同时显示在「已暂存的更改」和「更改」中,这样你能看出它既有已暂存的内容,也有未暂存的改动。 +## 怎么读一行文件 + +每一行文件包含三部分信息: + +- **状态图标**,表示变更类型:新增、修改、删除、重命名、复制、冲突、未跟踪或已忽略。 +- **文件路径。** +- **Git 状态码**,并按变更类型着色——新增为绿色,修改为黄色,删除为红色,未跟踪为青色,重命名为蓝色,冲突为橙色。状态码保留 Git 原本的写法,因此像 `AM` 这样的双状态依然可读。悬停在状态码上可以看到该变更的名称。 + +行尾是这个文件对应的操作按钮。 + ## 暂存与取消暂存 -- 暂存单个文件:点击「更改」中该文件右侧的 `+` 按钮。 +- 暂存单个文件:点击「更改」中该文件右侧的 `+` 图标。 - 一次性暂存「更改」里的全部文件:点击**暂存全部**。 -- 取消暂存:点击「已暂存的更改」中该文件右侧的 `−` 按钮。仓库还没有任何提交时,这个操作同样可用。 +- 取消暂存:点击「已暂存的更改」中该文件右侧的 `−` 图标。仓库还没有任何提交时,这个操作同样可用。 **暂存全部**等价于 `git add -A`:修改、新增和删除都会被暂存。 @@ -39,7 +49,7 @@ Git 面板让你直接在 Infernux 编辑器里完成暂存、取消暂存和提 ## 刷新文件列表 -面板会自动更新文件列表,最多每秒一次。如果你想立刻看到当前状态——比如刚在终端里执行过 Git 命令——点击标题栏右侧的 `⟳` 按钮。 +面板会自动更新文件列表,最多每秒一次。如果你想立刻看到当前状态——比如刚在终端里执行过 Git 命令——点击标题栏右侧的刷新图标。 ## 故障排查 @@ -47,10 +57,17 @@ Git 面板让你直接在 Infernux 编辑器里完成暂存、取消暂存和提 **点击提交没有任何反应。** 消息输入框是空的,需要先填写提交信息。 -**`git commit` 报错询问你的身份。** Git 还没有配置用户信息。执行 `git config --global user.name "你的名字"` 和 `git config --global user.email "you@example.com"`。 +**`git commit` 报错询问你的身份。** Git 还没有配置用户信息,执行: + +```bash +git config --global user.name "你的名字" +git config --global user.email "you@example.com" +``` **新建的文件一直留在「更改」里。** 未跟踪的文件会标记为 `?`,直到被暂存。 +**图标没有显示。** 图标是矢量素材,由编辑器在面板首次打开时完成光栅化。如果 Editor 启动时没有 GPU 支持,或者纹理上传失败,面板会退回到纯文字控件,状态码仍然正常工作。 + ## 后续计划 -后续版本将支持分支显示与切换、文件状态着色、未暂存文件的丢弃改动、Push / Pull 控制、diff 预览,以及异步执行 `git status`。 +后续版本将支持分支显示与切换、未暂存文件的丢弃改动、Push / Pull 控制、diff 预览,以及异步执行 `git status`。 diff --git a/tests/test_icon_assets.py b/tests/test_icon_assets.py new file mode 100644 index 0000000..5739ed1 --- /dev/null +++ b/tests/test_icon_assets.py @@ -0,0 +1,99 @@ +"""The bundled icon artwork must stay renderable by the Engine's SVG backend. + +The Engine rasterizes these documents through LunaSVG at runtime, so a +malformed document only fails once the panel is open in the Editor. These +checks keep that failure out of the repository. +""" + +from pathlib import Path +import ast +import unittest +import xml.etree.ElementTree as ET + + +ROOT = Path(__file__).resolve().parents[1] +ICONS = ROOT / "package" / "editor" / "wokrlie" / "git_integration" / "icons.py" + +SVG_NS = "{http://www.w3.org/2000/svg}" + + +def _load_module() -> dict: + """Import ``icons.py`` with the Engine modules stubbed out.""" + import sys + import types + + infernux = types.ModuleType("infernux") + + class Debug: + @staticmethod + def log_suppressed(*args, **kwargs): + pass + + infernux.Debug = Debug + lib = types.ModuleType("infernux.lib") + lib.TextureLoader = object() + previous = {name: sys.modules.get(name) for name in ("infernux", "infernux.lib")} + sys.modules["infernux"] = infernux + sys.modules["infernux.lib"] = lib + try: + tree = ast.parse(ICONS.read_text(encoding="utf-8"), filename=str(ICONS)) + namespace = {"__name__": "icons_under_test"} + exec(compile(tree, str(ICONS), "exec"), namespace) + return namespace + finally: + for name, module in previous.items(): + if module is None: + sys.modules.pop(name, None) + else: + sys.modules[name] = module + + +class IconAssetTests(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.module = _load_module() + cls.paths = cls.module["ICON_PATHS"] + cls.status_icons = cls.module["STATUS_ICONS"] + + def test_every_icon_is_a_well_formed_svg_document(self): + for name, body in self.paths.items(): + with self.subTest(icon=name): + document = self.module["_svg_document"](body, "#d6d6d6", 32) + root = ET.fromstring(document.decode("utf-8")) + self.assertEqual(root.tag, SVG_NS + "svg") + self.assertEqual(root.get("viewBox"), "0 0 24 24") + self.assertEqual(root.get("stroke"), "#d6d6d6") + self.assertTrue(list(root), "icon has no drawable content") + + def test_icons_use_the_lucide_stroke_conventions(self): + """LunaSVG needs a concrete stroke colour, not ``currentColor``.""" + for name, body in self.paths.items(): + with self.subTest(icon=name): + self.assertNotIn("currentColor", body) + root = ET.fromstring( + self.module["_svg_document"](body, "#d6d6d6", 32).decode("utf-8") + ) + self.assertEqual(root.get("fill"), "none") + self.assertEqual(root.get("stroke-width"), "2") + + def test_every_status_icon_exists(self): + for status, icon in self.status_icons.items(): + with self.subTest(status=status): + self.assertIn(icon, self.paths) + + def test_action_icons_exist(self): + for icon in ("stage", "unstage", "stage-all", "refresh"): + with self.subTest(icon=icon): + self.assertIn(icon, self.paths) + + def test_colour_conversion_produces_valid_hex(self): + to_hex = self.module["_to_hex"] + self.assertEqual(to_hex((0.0, 0.0, 0.0, 1.0)), "#000000") + self.assertEqual(to_hex((1.0, 1.0, 1.0, 1.0)), "#ffffff") + self.assertEqual(to_hex((0.5, 0.25, 0.75, 1.0)), "#8040bf") + # Out-of-range channels are clamped instead of producing invalid hex. + self.assertEqual(to_hex((2.0, -1.0, 0.5, 1.0)), "#ff0080") + + +if __name__ == "__main__": + unittest.main() diff --git a/tests/test_translation_contracts.py b/tests/test_translation_contracts.py index 5be57e4..5488f51 100644 --- a/tests/test_translation_contracts.py +++ b/tests/test_translation_contracts.py @@ -15,6 +15,7 @@ PACKAGE = ROOT / "package" EDITOR = PACKAGE / "editor" PANEL = EDITOR / "wokrlie" / "git_integration" / "panel.py" +ICONS = EDITOR / "wokrlie" / "git_integration" / "icons.py" CATALOG = EDITOR / "translations.json" LOCALES = ("en", "zh") @@ -40,6 +41,48 @@ def _requested_keys() -> set[str]: return keys +def _status_label_keys() -> set[str]: + """Every translation key the status table points at. + + These are resolved through a variable rather than a literal, so the panel + scan above cannot see them. + """ + return _table_values("STATUS_LABELS") + + +def _table_keys(name: str) -> set[str]: + """Read the keys of one module-level table in ``icons.py``.""" + return _table(name, values=False) + + +def _table_values(name: str) -> set[str]: + """Read the string values of one module-level table in ``icons.py``.""" + return _table(name, values=True) + + +def _table(name: str, *, values: bool) -> set[str]: + tree = ast.parse(ICONS.read_text(encoding="utf-8"), filename=str(ICONS)) + found: set[str] = set() + for node in ast.walk(tree): + if isinstance(node, ast.AnnAssign): + target, value = node.target, node.value + elif isinstance(node, ast.Assign): + if len(node.targets) != 1: + continue + target, value = node.targets[0], node.value + else: + continue + if not isinstance(target, ast.Name) or target.id != name: + continue + if not isinstance(value, ast.Dict): + continue + entries = value.values if values else value.keys + for entry in entries: + if isinstance(entry, ast.Constant) and isinstance(entry.value, str): + found.add(entry.value) + return found + + def _declared_title_key() -> str: """The ``title_key`` passed to the ``@editor_panel`` decorator.""" tree = ast.parse(PANEL.read_text(encoding="utf-8"), filename=str(PANEL)) @@ -85,6 +128,22 @@ def test_every_requested_key_is_declared_in_every_locale(self): with self.subTest(key=key, locale=locale): self.assertIn(key, locales[locale]) + def test_every_status_label_is_declared_in_every_locale(self): + locales = _catalog()["locales"] + for key in sorted(_status_label_keys()): + for locale in LOCALES: + with self.subTest(key=key, locale=locale): + self.assertIn(key, locales[locale]) + + def test_status_table_covers_every_icon(self): + """Every status that has a colour must also have a label and an icon.""" + icons = _table_keys("STATUS_ICONS") + colors = _table_keys("STATUS_COLORS") + labels = _table_keys("STATUS_LABELS") + self.assertTrue(icons) + self.assertEqual(icons, colors) + self.assertEqual(icons, labels) + def test_panel_title_key_is_declared(self): locales = _catalog()["locales"] title_key = _declared_title_key() From 0e824a3b40d93e5ab81648cfa14deab906c5af87 Mon Sep 17 00:00:00 2001 From: Wokrlie Date: Sun, 1 Nov 2026 07:34:30 +0800 Subject: [PATCH 2/2] feat: ship the plugin licence and icon notices inside the archive ISC and MIT both ask for their notice to travel with every copy of the artwork, so the notices cannot live in the repository root alone: the repository is not what the Editor installs. The licence file and the notices now sit in the plugin package, next to the plugin code, and the Engine renders them as the plugin's License page, so no extra UI is needed to reach them. The usage page also points at the online copy, written out as plain URLs because the Editor draws plugin pages as plain text. --- CHANGELOG.md | 9 +- CHANGELOG.zh-CN.md | 9 +- CONTRIBUTING.md | 2 +- README.md | 7 +- README.zh-CN.md | 5 +- THIRD_PARTY_NOTICES.md | 65 --------- .../editor/wokrlie/git_integration/icons.py | 3 +- package/plugin_pages/LICENSE | 21 +++ package/plugin_pages/license.md | 93 ++++++++++++ package/plugin_pages/license.zh-CN.md | 95 +++++++++++++ package/plugin_pages/usage.md | 12 ++ package/plugin_pages/usage.zh-CN.md | 12 ++ tests/test_package_licenses.py | 134 ++++++++++++++++++ 13 files changed, 396 insertions(+), 71 deletions(-) delete mode 100644 THIRD_PARTY_NOTICES.md create mode 100644 package/plugin_pages/LICENSE create mode 100644 package/plugin_pages/license.md create mode 100644 package/plugin_pages/license.zh-CN.md create mode 100644 tests/test_package_licenses.py diff --git a/CHANGELOG.md b/CHANGELOG.md index dadf563..9ae54f9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,13 +9,20 @@ All notable changes to the Git Integration plugin are documented in this file. T - Vector icons across the panel. The stage, unstage, stage-all, and refresh controls are now Lucide icons instead of the `+`, `-`, and `⟳` characters, and every file row leads with an icon for its kind of change. - Coloured file status. The Git status code of each file is now drawn in the colour of that change — added is green, modified is yellow, deleted is red, untracked is cyan, renamed is blue, and a conflict is orange. - Tooltips on the icon controls and on the status code, naming the action and the kind of change. -- `THIRD_PARTY_NOTICES.md` records the licence of the icon artwork. +- A **License** page in the plugin information, which carries the plugin's own MIT licence and the notices for the bundled icon artwork. +- `package/plugin_pages/LICENSE` ships the plugin's licence inside the archive, and `package/plugin_pages/license.md` reproduces that licence together with the third-party notices as the plugin's License page. ISC and MIT both require their notice to travel with every copy, so a notice that only lived in the repository would not satisfy them. ### Changed - The icon artwork is embedded in the plugin and rasterized at runtime through the Engine's LunaSVG backend. The package stays a single deterministic archive, and one vector asset can be drawn in any colour. - The status code keeps its Git spelling, so a dual state such as `AM` stays readable next to its icon. +### Dependencies + +- **The panel now depends on an undocumented Engine capability.** The icons are rasterized at runtime through the Engine's LunaSVG-backed texture loader, which is not part of the documented plugin API. Vector artwork could not previously be shipped inside a plugin at all, because ImGui only draws raster textures. +- If that capability is removed or changed in a future Engine release, the icons stop rendering and the panel falls back to text-only controls. Everything else in the panel keeps working, and the status codes stay readable. +- The plugin needs no build-time conversion step and no pre-rendered PNG per colour, but it does need an Engine release that still ships the SVG rasterizer. + ## 0.1.4 ### Fixed diff --git a/CHANGELOG.zh-CN.md b/CHANGELOG.zh-CN.md index 0898c39..b85cc06 100644 --- a/CHANGELOG.zh-CN.md +++ b/CHANGELOG.zh-CN.md @@ -9,13 +9,20 @@ Git 集成插件的所有重要变更都记录在本文件中。格式遵循 [Ke - 面板全面使用矢量图标。暂存、取消暂存、暂存全部和刷新按钮改用 Lucide 图标,不再是 `+`、`-`、`⟳` 这几个字符;每个文件行前也会显示一个表示变更类型的图标。 - 文件状态着色。每个文件的 Git 状态码现在按变更类型着色——新增为绿色,修改为黄色,删除为红色,未跟踪为青色,重命名为蓝色,冲突为橙色。 - 图标按钮和状态码上增加了悬浮提示,说明该操作和该变更类型。 -- 新增 `THIRD_PARTY_NOTICES.md`,记录图标素材的许可证。 +- 插件信息里新增**许可证**页面,承载插件自身的 MIT 许可证和内置图标素材的第三方声明。 +- `package/plugin_pages/LICENSE` 让插件的许可证随归档分发,`package/plugin_pages/license.md` 则在同一页里复现该许可证和第三方声明。ISC 与 MIT 都要求声明必须跟在素材的每一份副本里,只放在仓库里的声明无法满足这一条。 ### 变更 - 图标素材内嵌在插件中,并在运行时通过引擎的 LunaSVG 后端光栅化。插件包仍然是一个确定性的归档,同一份矢量素材可以以任意颜色绘制。 - 状态码保留 Git 原本的写法,因此像 `AM` 这样的双状态在图标旁边依然可读。 +### 依赖 + +- **面板现在依赖一项未公开的引擎能力。** 图标在运行时通过引擎基于 LunaSVG 的纹理加载器光栅化,这项能力并不属于已公开的插件 API。在此之前,插件根本无法内嵌矢量素材——ImGui 只能绘制光栅纹理。 +- 如果未来的引擎版本移除或改动了这项能力,图标将无法渲染,面板会退回到纯文字控件。面板的其余功能不受影响,状态码依然可读。 +- 插件不需要任何构建期转换步骤,也不需要为每种颜色预渲染 PNG,但需要引擎仍随附 SVG 光栅化器。 + ## 0.1.4 ### 修复 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 950e583..423cec3 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -58,5 +58,5 @@ python package.py build dist/plugin.inxpkg && python package.py verify dist/plug - Icons come from [Lucide](https://lucide.dev), which is free for commercial use under the ISC License. The geometry lives in `package/editor/wokrlie/git_integration/icons.py`. - Icons are embedded in the module rather than shipped as files, so the plugin never depends on where its package is unpacked and the build stays byte-for-byte deterministic. -- Any new artwork must come from a permissive licence and be recorded in `THIRD_PARTY_NOTICES.md` before it ships. +- Any new artwork must come from a permissive licence and be recorded in `package/plugin_pages/license.md` before it ships. That page is the plugin's License page in the editor, so the notice travels with every installed copy. - The icons are rasterized at runtime through the Engine's LunaSVG backend. ImGui itself cannot draw SVG, so do not expect the vector source to reach the renderer. diff --git a/README.md b/README.md index 4a7c67e..97abb1f 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,7 @@ A source control panel for the [Infernux Engine](https://github.com/ChenlizheMe/ - Files with a dual status (for example `AM`) appear in both lists, matching `git status`. - Vector icons for the stage, unstage, stage-all, and refresh controls, plus a status icon and a coloured status code on every file row. - Localized panel UI in English and Simplified Chinese. +- The plugin's own licence and the notices for the bundled icon artwork ship with the plugin and are shown on the **License** page of the plugin information. ## Requirements @@ -27,6 +28,8 @@ A source control panel for the [Infernux Engine](https://github.com/ChenlizheMe/ 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. +The icons are vector artwork that the Editor rasterizes at runtime. That relies on the Engine's LunaSVG-backed texture loader, which is not part of the documented plugin API — if a future Engine release drops it, the panel falls back to text-only controls and everything else keeps working. + ## Installation ### From a release @@ -85,8 +88,10 @@ The Editor-only code lives in `package/editor/`, and the runtime surface in `pac | [ROADMAP.md](ROADMAP.md) | Planned features | | [CONTRIBUTING.md](CONTRIBUTING.md) | Contribution and commit conventions | | [RELEASING.md](RELEASING.md) | Release procedure | -| [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) | Licences of the bundled icon artwork | +| [package/plugin_pages/license.md](package/plugin_pages/license.md) | Plugin licence and third-party notices for the bundled artwork | ## License [MIT](LICENSE). + +The same licence text and the notices for the bundled icon artwork ship inside the plugin archive, on the **License** page of the plugin information. diff --git a/README.zh-CN.md b/README.zh-CN.md index 5d969ba..acf503b 100644 --- a/README.zh-CN.md +++ b/README.zh-CN.md @@ -17,6 +17,7 @@ - 双状态文件(例如 `AM`)会同时出现在两个列表中,与 `git status` 的行为一致。 - 暂存、取消暂存、暂存全部和刷新按钮使用矢量图标;每个文件行还带有状态图标和带颜色的状态码。 - 面板界面支持英文与简体中文。 +- 插件自身的许可证和内置图标素材的第三方声明随插件一起分发,可在插件信息的**许可证**页面查看。 ## 环境要求 @@ -85,8 +86,10 @@ python package.py verify dist/plugin.inxpkg # 校验构建产物 | [ROADMAP.md](ROADMAP.md) | 后续计划 | | [CONTRIBUTING.md](CONTRIBUTING.md) | 贡献与提交规范 | | [RELEASING.md](RELEASING.md) | 发布流程 | -| [THIRD_PARTY_NOTICES.md](THIRD_PARTY_NOTICES.md) | 内置图标素材的许可证 | +| [package/plugin_pages/license.md](package/plugin_pages/license.md) | 插件许可证与内置素材的第三方声明 | ## 许可证 [MIT](LICENSE)。 + +同一份许可证文本和内置图标素材的第三方声明也随插件归档一起分发,可在插件信息的**许可证**页面查看。 diff --git a/THIRD_PARTY_NOTICES.md b/THIRD_PARTY_NOTICES.md deleted file mode 100644 index d8d72a0..0000000 --- a/THIRD_PARTY_NOTICES.md +++ /dev/null @@ -1,65 +0,0 @@ -# Third-Party Notices - -The Git Integration plugin ships artwork that comes from third-party open -source projects. The notices below reproduce the licenses those projects -require. - -## Lucide - -The icon geometry in `package/editor/wokrlie/git_integration/icons.py` is -taken from [Lucide](https://lucide.dev) (release 0.544.0), licensed under the -ISC License. - -``` -ISC License - -Copyright (c) 2026 Lucide Icons and Contributors - -Permission to use, copy, modify, and/or distribute this software for any -purpose with or without fee is hereby granted, provided that the above -copyright notice and this permission notice appear in all copies. - -THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES -WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF -MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR -ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES -WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN -ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF -OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -``` - -## Feather Icons - -Two of the icons used here — `plus` and `minus` — are derived from the -Feather project and are covered by the MIT License reproduced below. Every -other icon is original Lucide artwork under the ISC License above. - -``` -The MIT License (MIT) - -Copyright (c) 2013-present Cole Bemis - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. -``` - -## Infernux Engine - -The plugin runs inside the Infernux Engine and uses its LuaSVG-based texture -rasterizer to turn the vector artwork above into ImGui textures at runtime. -The Engine is licensed separately by its authors. diff --git a/package/editor/wokrlie/git_integration/icons.py b/package/editor/wokrlie/git_integration/icons.py index 83929ec..6596146 100644 --- a/package/editor/wokrlie/git_integration/icons.py +++ b/package/editor/wokrlie/git_integration/icons.py @@ -3,7 +3,8 @@ The icon geometry comes from Lucide (https://lucide.dev), which is released under the ISC License and is free for commercial use. The ISC license asks that the copyright notice travels with redistributed copies, so it is -reproduced in ``THIRD_PARTY_NOTICES.md`` at the repository root. +reproduced in ``package/plugin_pages/license.md``, which ships inside the +plugin archive as the plugin's License page. Every icon is stored as the inner markup of a 24x24 Lucide SVG. They are rasterized at runtime through the Engine's LunaSVG backend and uploaded as diff --git a/package/plugin_pages/LICENSE b/package/plugin_pages/LICENSE new file mode 100644 index 0000000..a74e507 --- /dev/null +++ b/package/plugin_pages/LICENSE @@ -0,0 +1,21 @@ +MIT License + +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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/package/plugin_pages/license.md b/package/plugin_pages/license.md new file mode 100644 index 0000000..6d0552f --- /dev/null +++ b/package/plugin_pages/license.md @@ -0,0 +1,93 @@ +# License + +The Git Integration plugin is distributed under the MIT License. The same text ships as a plain `LICENSE` file inside the plugin archive. + +``` +MIT License + +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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +## Third-party notices + +The panel draws its icons from the Lucide icon set, which is free for commercial use. Lucide asks for its notice to travel with every redistributed copy, so the notices below are reproduced in full and ship with the plugin. + +### Lucide + +The icon geometry in the plugin comes from Lucide (https://lucide.dev), release 0.544.0, under the ISC License. + +``` +ISC License + +Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2023 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2025. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +``` + +### Feather Icons + +Two of the icons used by the panel — `plus` and `minus` — are derived from the Feather project and are covered by the MIT License reproduced below. Every other icon is original Lucide artwork under the ISC License above. + +``` +The MIT License (MIT) + +Copyright (c) 2013-present Cole Bemis + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +### Infernux Engine + +The plugin runs inside the Infernux Engine and uses its LunaSVG-based texture rasterizer to turn the vector artwork above into ImGui textures at runtime. The Engine is licensed separately by its authors. + +## Read these notices online + +The editor draws plugin pages as plain text, so the links below are written out in full: + +https://github.com/Wokrlie/InxGitIntegration/blob/main/package/plugin_pages/license.md + +https://github.com/Wokrlie/InxGitIntegration/blob/main/LICENSE diff --git a/package/plugin_pages/license.zh-CN.md b/package/plugin_pages/license.zh-CN.md new file mode 100644 index 0000000..2532082 --- /dev/null +++ b/package/plugin_pages/license.zh-CN.md @@ -0,0 +1,95 @@ +# 许可证 + +Infernux Git 集成插件以 MIT License 发布。同一份文本也以独立的 `LICENSE` 文件随插件归档一起分发。 + +许可证条款保留原始英文表述,以免改变其法律含义。 + +``` +MIT License + +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 +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +## 第三方声明 + +面板的图标取自 Lucide 图标集,可免费用于商业用途。Lucide 要求声明随素材的每一份副本一同分发,因此下面完整复现这些声明,并随插件一起分发。 + +### Lucide + +插件中的图标几何数据来自 Lucide (https://lucide.dev) 0.544.0 版本,采用 ISC License。 + +``` +ISC License + +Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2023 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2025. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. +``` + +### Feather Icons + +面板用到的两个图标 —— `plus` 和 `minus` —— 派生自 Feather 项目,采用下面的 MIT License。其余图标均为 Lucide 原创作品,采用上面的 ISC License。 + +``` +The MIT License (MIT) + +Copyright (c) 2013-present Cole Bemis + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +``` + +### Infernux 引擎 + +插件运行在 Infernux 引擎内部,使用引擎基于 LunaSVG 的纹理光栅化器,在运行时把上述矢量素材转成 ImGui 纹理。引擎由其作者单独授权。 + +## 在线阅读 + +编辑器里的插件页面以纯文本显示,因此下面的链接以完整形式写出: + +https://github.com/Wokrlie/InxGitIntegration/blob/main/package/plugin_pages/license.zh-CN.md + +https://github.com/Wokrlie/InxGitIntegration/blob/main/LICENSE diff --git a/package/plugin_pages/usage.md b/package/plugin_pages/usage.md index 8b2f6aa..a8f4519 100644 --- a/package/plugin_pages/usage.md +++ b/package/plugin_pages/usage.md @@ -63,6 +63,18 @@ The panel updates the file lists automatically, at most once per second. If you **The icons are missing.** The icons are vector artwork that the Editor rasterizes when the panel first opens. If the Editor was started without GPU support, or the textures could not be uploaded, the panel falls back to text-only controls and the status codes still work. +## Licences + +The plugin ships its own licence and the notices for the icon artwork with the plugin itself. Open the **License** tab of this plugin to read them. + +The panel icons come from Lucide, which is free for commercial use. The editor draws plugin pages as plain text, so the links below are written out in full: + +https://github.com/Wokrlie/InxGitIntegration/blob/main/package/plugin_pages/license.md + +The plugin's own MIT licence: + +https://github.com/Wokrlie/InxGitIntegration/blob/main/LICENSE + ## Upcoming features Branch display and switching, discard-changes for unstaged files, Push/Pull controls, diff preview, and asynchronous `git status` execution are planned for future versions. diff --git a/package/plugin_pages/usage.zh-CN.md b/package/plugin_pages/usage.zh-CN.md index ac09b7a..84c5e3f 100644 --- a/package/plugin_pages/usage.zh-CN.md +++ b/package/plugin_pages/usage.zh-CN.md @@ -68,6 +68,18 @@ git config --global user.email "you@example.com" **图标没有显示。** 图标是矢量素材,由编辑器在面板首次打开时完成光栅化。如果 Editor 启动时没有 GPU 支持,或者纹理上传失败,面板会退回到纯文字控件,状态码仍然正常工作。 +## 许可证 + +插件自身的许可证和图标素材的第三方声明都随插件一起分发。在本插件的**许可证**标签页里可以读到它们。 + +面板图标来自 Lucide,可免费用于商业用途。编辑器里的插件页面以纯文本显示,因此下面的链接以完整形式写出: + +https://github.com/Wokrlie/InxGitIntegration/blob/main/package/plugin_pages/license.zh-CN.md + +插件自身的 MIT 许可证: + +https://github.com/Wokrlie/InxGitIntegration/blob/main/LICENSE + ## 后续计划 后续版本将支持分支显示与切换、未暂存文件的丢弃改动、Push / Pull 控制、diff 预览,以及异步执行 `git status`。 diff --git a/tests/test_package_licenses.py b/tests/test_package_licenses.py new file mode 100644 index 0000000..891edc3 --- /dev/null +++ b/tests/test_package_licenses.py @@ -0,0 +1,134 @@ +"""The plugin archive must carry its licence and the third-party notices. + +ISC and MIT both require their notice to travel with every copy of the +artwork, so a notice that only lives in the repository root does not +satisfy them once the plugin is distributed as an archive. +""" + +from pathlib import Path +import contextlib +import io +import sys +import tempfile +import unittest + + +ROOT = Path(__file__).resolve().parents[1] +PAGES = ROOT / "package" / "plugin_pages" +sys.path.insert(0, str(ROOT)) + +import package as packager # noqa: E402 + + +LUCIDE_NOTICE = """ISC License + +Copyright (c) for portions of Lucide are held by Cole Bemis 2013-2023 as part of Feather (MIT). All other copyright (c) for Lucide are held by Lucide Contributors 2025. + +Permission to use, copy, modify, and/or distribute this software for any +purpose with or without fee is hereby granted, provided that the above +copyright notice and this permission notice appear in all copies. + +THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES +WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR +ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES +WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF +OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.""" + +FEATHER_NOTICE = """The MIT License (MIT) + +Copyright (c) 2013-present Cole Bemis""" + + +def read_entries(path: Path) -> dict[str, bytes]: + """Return every stored payload of an InxPack archive, keyed by path.""" + data = bytearray(path.read_bytes()) + values = packager.HEADER.unpack_from(data) + toc_offset, _toc_bytes, payload_start, _payload_bytes, count, _strings = values[5:11] + records = toc_offset + packager.TOC_PREFIX.size + strings = records + count * packager.ENTRY.size + entries: dict[str, bytes] = {} + for index in range(count): + entry = packager.ENTRY.unpack_from(data, records + index * packager.ENTRY.size) + name = bytes(data[strings + entry[0]:strings + entry[0] + entry[1]]).decode("utf-8") + start = payload_start + entry[3] + entries[name] = bytes(data[start:start + entry[5]]) + return entries + + +class PackageLicenceTests(unittest.TestCase): + @classmethod + def setUpClass(cls): + cls.workspace = tempfile.TemporaryDirectory() + cls.archive = Path(cls.workspace.name) / "licence.inxpkg" + with contextlib.redirect_stdout(io.StringIO()): + packager.build(cls.archive) + cls.entries = read_entries(cls.archive) + cls.metadata = packager._read_metadata(cls.archive) + cls.licence = (ROOT / "LICENSE").read_text(encoding="utf-8").strip() + + @classmethod + def tearDownClass(cls): + cls.workspace.cleanup() + + def test_package_licence_file_matches_the_repository_licence(self): + self.assertEqual( + (PAGES / "LICENSE").read_bytes(), + (ROOT / "LICENSE").read_bytes(), + ) + + def test_licence_pages_reproduce_the_licence_and_the_notices(self): + for name in ("license.md", "license.zh-CN.md"): + with self.subTest(page=name): + text = (PAGES / name).read_text(encoding="utf-8") + self.assertIn(self.licence, text) + self.assertIn(LUCIDE_NOTICE, text) + self.assertIn(FEATHER_NOTICE, text) + + def test_archive_carries_the_licence_and_the_notices(self): + self.assertEqual( + self.entries["package/plugin_pages/LICENSE"], + (ROOT / "LICENSE").read_bytes(), + ) + for name in ("license.md", "license.zh-CN.md"): + with self.subTest(page=name): + self.assertEqual( + self.entries[f"package/plugin_pages/{name}"], + (PAGES / name).read_bytes(), + ) + + def test_archive_has_no_superseded_notice_copy(self): + self.assertNotIn("package/THIRD_PARTY_NOTICES.md", self.entries) + self.assertNotIn("THIRD_PARTY_NOTICES.md", self.entries) + + def test_archive_carries_exactly_one_licence_file(self): + # A second copy at the archive root would install into the project's + # asset tree instead of next to the plugin it belongs to. + self.assertNotIn("package/LICENSE", self.entries) + self.assertIn("package/plugin_pages/LICENSE", self.entries) + + def test_licence_page_uses_the_engine_licence_tab_id(self): + pages = [ + page for page in self.metadata["pages"] + if str(page.get("id")) == "license" + ] + self.assertEqual(len(pages), 2) + self.assertEqual( + {str(page.get("locale", "")) for page in pages}, + {"", "zh-CN"}, + ) + + def test_usage_pages_point_at_the_licence_page_and_the_web_copy(self): + for name in ("usage.md", "usage.zh-CN.md"): + with self.subTest(page=name): + text = (PAGES / name).read_text(encoding="utf-8") + self.assertIn("package/plugin_pages/license", text) + self.assertIn( + "https://github.com/Wokrlie/InxGitIntegration/blob/main/LICENSE", + text, + ) + + +if __name__ == "__main__": + unittest.main()