一、问题(本轮实测)
`draw-ui` 与 `oil-motion` 目录里**各自带一个内嵌 `.git`** ⇒ 上一次提交把它们记成了 **gitlink(子模块指针)**
⇒ 仓库里只存了一个不属于任何远端的 commit id,**别人克隆下来这两份是空的** ✗(`git status` 显示 ` m draw-ui` / ` m oil-motion` = 子模块内容有改动)。
二、处置(可回退)
· 把两处的 `.git` **挪走**(⛔ 不是删除)⇒ `归档/内嵌git-20261008/{draw-ui,oil-motion}.git`;
· `git rm --cached` 掉那两个 gitlink,再 `git add` 两个目录 ⇒ **按正常文件入库**(内容才真的进仓库)。
三、副作用(如实记)
挪走 `.git` 后,这两个技能**不能再原地 `git pull` 取上游更新**(要更新得重新拉一份覆盖);
如需恢复其本地仓库,把 `归档/内嵌git-20261008/` 里的 `.git` 挪回原处即可。
43 lines
1.8 KiB
Python
43 lines
1.8 KiB
Python
"""从命令行入口验证透明素材检查,使用合成文件,不调用生图服务。"""
|
|
import json
|
|
from pathlib import Path
|
|
import subprocess
|
|
import sys
|
|
import tempfile
|
|
import unittest
|
|
|
|
from PIL import Image
|
|
|
|
|
|
class AlphaCheckTest(unittest.TestCase):
|
|
def test_file_formats_and_alpha(self):
|
|
rgb = Image.new("RGB", (2, 2), "white")
|
|
rgb.putpixel((0, 0), (128, 128, 128))
|
|
rgba = Image.new("RGBA", (2, 2), (0, 0, 0, 255))
|
|
valid = rgba.copy()
|
|
valid.putpixel((0, 0), (0, 0, 0, 0))
|
|
partial = rgba.copy()
|
|
partial.putpixel((0, 0), (0, 0, 0, 128))
|
|
palette = Image.new("P", (2, 2), 1)
|
|
palette.putpalette([0, 0, 0, 255, 255, 255] + [0] * 762)
|
|
palette.putpixel((0, 0), 0)
|
|
palette.info["transparency"] = 0
|
|
cases = [("checker-rgb", rgb, False), ("opaque-rgba", rgba, False),
|
|
("transparent-rgba", valid, True), ("partial-alpha", partial, True),
|
|
("palette-transparency", palette, True),
|
|
("empty", Image.new("RGBA", (2, 2), (0, 0, 0, 0)), False)]
|
|
script = Path(__file__).resolve().parents[1] / "scripts/check_asset_alpha.py"
|
|
with tempfile.TemporaryDirectory() as directory:
|
|
for name, im, expected in cases:
|
|
with self.subTest(name=name):
|
|
path = Path(directory) / (name + ".png")
|
|
im.save(path)
|
|
result = subprocess.run([sys.executable, str(script), str(path),
|
|
"--require-transparency"], capture_output=True, text=True)
|
|
self.assertEqual(result.returncode, 0 if expected else 2, result.stderr)
|
|
self.assertEqual(json.loads(result.stdout)["transparency_check_passed"], expected)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|