Skip to content
Open
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
4 changes: 3 additions & 1 deletion i18n/ru/.hashes.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,7 @@
"git/templates/.github/ISSUE_TEMPLATE/experimental.md": "88dde5d2feaaa95ccca48bdd595b9f32314a3d1ef14892ff92f445691cc2b8de",
"git/templates/.github/ISSUE_TEMPLATE/config.yml": "b795747dcc0f3f6e7f7c99b87f06f56c6a4718c6dcd7c4031befc25438b59055",
"git/templates/.github/ISSUE_TEMPLATE/refactor.md": "64d05da46ea4eb34bddef9057eb2be131ba5c9c103f1bfd44650ac420b1ed580",
"git/templates/.github/ISSUE_TEMPLATE/epic.md": "75ae9437ead05d9a8a6289e6af43ec6a720272e0fe3c2c39be134ea2ff66ad55"
"git/templates/.github/ISSUE_TEMPLATE/epic.md": "75ae9437ead05d9a8a6289e6af43ec6a720272e0fe3c2c39be134ea2ff66ad55",
"git/rules/issue.md": "9b4efe2c2d29290d1426b5344c19a66585e88f292993a099c7b239cc8c4f453d",
"git/rules/branch.md": "522b95758f55b7ed4c1dbb6ab9bb1e778d20795139ffa5b1836baecc6cddb5e2"
}
32 changes: 20 additions & 12 deletions release/src/builder/Scriptgen.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,25 +75,33 @@ def generate_script_header(self) -> bytes:
cp -r "$TMPDIR/wiki"/* "$TMPDIR/wiki-repo/"

cd "$TMPDIR/wiki-repo"
git add .
git commit -m "Update wiki from release bundle"
git push
git add -A
if ! git diff --cached --quiet; then
git commit -m "Update wiki from release bundle"
git push
else
echo "Wiki: no changes to commit"
fi

echo "--- Templates ---"
git clone "$BASE_URL.git" "$TMPDIR/main-repo"
cd "$TMPDIR/main-repo"
git checkout "$TEMPLATE_BRANCH" || git checkout -b "$TEMPLATE_BRANCH"

TEMPLATE_ROOT="$TMPDIR/templates"
find "$TEMPLATE_ROOT" -type f | while read src; do
rel="${{src#$TEMPLATE_ROOT/}}"
mkdir -p "$(dirname "$rel")"
cp "$src" "$rel"
done

git add .
git commit -m "Add templates from release bundle"
git push -u origin "$TEMPLATE_BRANCH"
if [ -d "$TEMPLATE_ROOT" ]; then
rsync -a "$TEMPLATE_ROOT"/ ./
else
echo "Templates: directory not found: $TEMPLATE_ROOT"
fi

git add -A
if ! git diff --cached --quiet; then
git commit -m "Add templates from release bundle"
git push -u origin "$TEMPLATE_BRANCH"
else
echo "Templates: no changes to commit"
fi

echo "Done"
exit 0
Expand Down
97 changes: 70 additions & 27 deletions release/src/preparer/ListLoader.py
Original file line number Diff line number Diff line change
@@ -1,40 +1,83 @@
from pathlib import Path
from release.src.utils.ConsoleIO import print_status

class BaseLineParser:
comment_marker = "#"
mapping_marker = "->"
root_prefix = "@root "

@classmethod
def _commentoff(cls, raw: str) -> str:
raw = raw.strip()
if raw.startswith(cls.comment_marker): return None
if cls.comment_marker in raw:
raw = raw.split(cls.comment_marker, 1)[0].strip()
return raw or None

@classmethod
def _split_mapping(cls, raw: str) -> tuple[str, str]:
if cls.mapping_marker in raw:
left, right = raw.split(cls.mapping_marker, 1)
else:
left, right = raw, raw
return left.strip(), right.strip()

@classmethod
def _root_detect(cls, raw: str) -> tuple[str, bool]:
if raw.startswith(cls.root_prefix):
return raw[len(cls.root_prefix):].strip(), True
return raw, False

@classmethod
def parse(cls, raw: str) -> tuple[Path, Path, bool] | None:
raw_clean = cls._commentoff(raw)
if raw_clean is None: return None

raw_clean, root = cls._root_detect(raw)

source_raw, dest_raw = cls._split_mapping(raw_clean)

return Path(source_raw), Path(dest_raw), root


class ListLoader:
def __init__(self, source_dir: Path, dest_dir: Path):
self.source_dir = source_dir.resolve()
self.dest_dir = dest_dir.resolve()

def _parse_line(self, raw: str) -> tuple[Path, Path | None] | None:
raw = raw.strip()
if not raw or raw.startswith("#"):
return None
if "#" in raw:
raw = raw.split("#", 1)[0].strip()
if not raw:
return None

if "->" in raw:
source_raw, dest_raw = map(str.strip, raw.split("->", 1))
source = (self.source_dir / source_raw).resolve()
dest = (self.dest_dir / dest_raw).resolve()
else:
source = (self.source_dir / raw).resolve()
dest = (self.dest_dir / source.relative_to(self.source_dir)).resolve()
if self.dest_dir == self.source_dir:
raise ValueError(f"[ERR] destination must differ from source")

def _recursive_load(self, source_raw : Path, dest_raw : Path, root : bool) -> list[tuple[Path, Path]]:
result: list[tuple[Path, Path]] = []
src = (self.source_dir / source_raw).resolve()
dest = (self.dest_dir / dest_raw ).resolve()

if not src.exists():
raise FileNotFoundError(f"[ERR] Missing list file: {src}")

if src.is_file():
if root:
result.append((src, self.dest_dir / dest.name))
else:
result.append((src, dest))
elif src.is_dir():
for path in src.rglob("*"):
if path.is_file():
if root:
result.append((path, self.dest_dir / path.name))
else:
rel = path.relative_to(src)
new_dest = dest / rel if dest else None
result.append((path, new_dest))
return result

return (source, dest)

def load(self, list_path: Path) -> list[tuple[Path, Path | None]]:
result = []
def load(self, list_path: Path) -> list[tuple[Path, Path]]:
result: list[tuple[Path, Path]] = []
if not list_path.exists():
raise FileNotFoundError(f"[ERROR] Missing list file: {list_path}")
raise FileNotFoundError(f"[ERR] Missing list file: {list_path}")
for line in list_path.read_text(encoding="utf-8").splitlines():
parsed = self._parse_line(line)
if parsed is None:
continue
source, dest = parsed
if not source.exists():
print_status("WRN", f"Missing: {source}")
result.append((source, dest))
src, dst, is_root = BaseLineParser.parse(line)
result.extend(self._recursive_load(src, dst, is_root))
return result
17 changes: 3 additions & 14 deletions release/src/preparer/Units.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,9 @@ def __init__(self, name : str, manifest: Manifest, ppath : ProjectPath):
def prepare(self):
self._ensure_clean(self.dest_dir)

raw_entries = self.list_loader.load(self.list_path)
expanded_entries = []
for src, dst in raw_entries:
if src.is_file():
expanded_entries.append((src, dst))
elif src.is_dir():
for path in src.rglob("*"):
if path.is_file():
rel = path.relative_to(src)
new_dest = dst / rel if dst else None
expanded_entries.append((path, new_dest))


sources, destinations = zip(*expanded_entries)
entries = self.list_loader.load(self.list_path)

sources, destinations = zip(*entries)
translated_sources = self.translator.ensure_all(list(sources))
final_entries = list(zip(translated_sources, destinations))

Expand Down