Support instances that serve SSH from another hostname
Discovery matched a git remote's host against the instance URL's host, so a server answering SSH on a different name than its web UI resolved to nothing — and said so only in a debug log. Resolution now runs in three stages. A remote host is matched directly, then against configured aliases, and failing both the instances are asked for the repository: Gitea publishes its SSH hostname in a repository's ssh_url, so the right instance identifies itself. What that turns up is saved as a host alias, so later repositories on the same host resolve with no lookup at all, and the mapping is visible and editable rather than hidden. Each unknown host is probed at most once per session. When nothing resolves the sidebar now names the unmatched host and offers Add Host Alias, instead of showing an empty section. Aliases can also be written by hand as "remote-host = instance URL", accepting =, -> and =>, ignoring ports, and skipping # comments. List preferences now merge workspace entries onto global ones rather than letting an empty global array mask them. Adds Tests/host-aliases.test.js covering both directions: unmatched hosts reported and nothing persisted, a hand-written alias, detection from ssh_url, and a later repository resolving from the stored alias without a probe. 131 checks across three suites. Also adds CLAUDE.md, and .gitea/workflows/ci.yml running the suites, script syntax checks, manifest validation, and a generated-image check. Tools/make-icons.py gains --check, which compares decompressed pixels so a differing zlib version cannot fail it spuriously. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01MQuusXgZC2dzwpJJ1qhtti
This commit is contained in:
+66
-8
@@ -7,12 +7,15 @@ metadata.json marking it a template image so macOS tints it for light and dark
|
||||
sidebars. The shapes are drawn as unit-square coverage tests and supersampled,
|
||||
which keeps the whole thing dependency-free.
|
||||
|
||||
Run from the extension root: python3 Tools/make-icons.py
|
||||
Run from anywhere:
|
||||
python3 Tools/make-icons.py regenerate
|
||||
python3 Tools/make-icons.py --check verify without writing
|
||||
"""
|
||||
|
||||
import math
|
||||
import os
|
||||
import struct
|
||||
import sys
|
||||
import zlib
|
||||
|
||||
SS = 4 # supersamples per axis
|
||||
@@ -143,10 +146,65 @@ ICONS = {
|
||||
|
||||
ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
|
||||
for name, (shape, sizes) in ICONS.items():
|
||||
folder = os.path.join(ROOT, "Images", name)
|
||||
for index, size in enumerate(sizes):
|
||||
suffix = "" if index == 0 else "@2x"
|
||||
png(os.path.join(folder, f"{name}{suffix}.png"), size, size, render(size, shape))
|
||||
open(os.path.join(folder, "metadata.json"), "w").write('{\n "template": true\n}\n')
|
||||
print("wrote", folder)
|
||||
|
||||
def scanlines(path):
|
||||
"""The decompressed scanline bytes of a PNG.
|
||||
|
||||
Compared instead of the file bytes because zlib's output varies between
|
||||
versions, which would make a byte-for-byte check fail spuriously in CI.
|
||||
"""
|
||||
data = open(path, "rb").read()
|
||||
idat = b""
|
||||
i = 8
|
||||
while i < len(data):
|
||||
length = struct.unpack(">I", data[i:i + 4])[0]
|
||||
if data[i + 4:i + 8] == b"IDAT":
|
||||
idat += data[i + 8:i + 8 + length]
|
||||
i += 12 + length
|
||||
return zlib.decompress(idat)
|
||||
|
||||
|
||||
def targets():
|
||||
for name, (shape, sizes) in ICONS.items():
|
||||
folder = os.path.join(ROOT, "Images", name)
|
||||
for index, size in enumerate(sizes):
|
||||
suffix = "" if index == 0 else "@2x"
|
||||
yield os.path.join(folder, f"{name}{suffix}.png"), size, shape, folder
|
||||
|
||||
|
||||
def write_all():
|
||||
for path, size, shape, folder in targets():
|
||||
png(path, size, size, render(size, shape))
|
||||
for name in ICONS:
|
||||
folder = os.path.join(ROOT, "Images", name)
|
||||
with open(os.path.join(folder, "metadata.json"), "w") as handle:
|
||||
handle.write('{\n "template": true\n}\n')
|
||||
print("wrote", folder)
|
||||
|
||||
|
||||
def check_all():
|
||||
stale = []
|
||||
for path, size, shape, _ in targets():
|
||||
expected = bytes(b"".join(
|
||||
b"\x00" + bytes(render(size, shape)[y * size * 4:(y + 1) * size * 4])
|
||||
for y in range(size)
|
||||
))
|
||||
if not os.path.exists(path):
|
||||
stale.append(f"{os.path.relpath(path, ROOT)} is missing")
|
||||
elif scanlines(path) != expected:
|
||||
stale.append(f"{os.path.relpath(path, ROOT)} differs from the source shapes")
|
||||
|
||||
if stale:
|
||||
for line in stale:
|
||||
print("stale:", line)
|
||||
print("\nRun: python3 Tools/make-icons.py")
|
||||
return 1
|
||||
|
||||
print(f"all {sum(1 for _ in targets())} images match the source shapes")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if "--check" in sys.argv:
|
||||
raise SystemExit(check_all())
|
||||
write_all()
|
||||
|
||||
Reference in New Issue
Block a user