|
8 | 8 | import pathlib
|
9 | 9 | import re
|
10 | 10 | import xml.etree.ElementTree as Et
|
| 11 | +import subprocess |
11 | 12 | from typing import Any, Callable
|
12 | 13 |
|
13 | 14 | alphanumeric_pattern = re.compile(r"(\d+)")
|
@@ -49,6 +50,8 @@ def _alphanumeric(key: str) -> list[int | str]:
|
49 | 50 | for character in re.split(alphanumeric_pattern, key)
|
50 | 51 | ]
|
51 | 52 |
|
| 53 | +def _get_latest_commit_hash_short() -> str: |
| 54 | + return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip() |
52 | 55 |
|
53 | 56 | def create_manifest(version: str | None = None, replace: bool = False) -> None:
|
54 | 57 | """Generate new SHA1 hashes and version number for Path of Building's manifest file.
|
@@ -78,6 +81,7 @@ def create_manifest(version: str | None = None, replace: bool = False) -> None:
|
78 | 81 | logging.critical(f"Manifest configuration file not found in path '{base_path}'")
|
79 | 82 | return
|
80 | 83 |
|
| 84 | + versions = {"number":new_version, "hash":_get_latest_commit_hash_short()} |
81 | 85 | base_url = "https://raw.githubusercontent.com/PathOfBuildingCommunity/PathOfBuilding/{branch}/"
|
82 | 86 | parts: list[dict[str, str]] = []
|
83 | 87 | for part in config.sections():
|
@@ -120,7 +124,7 @@ def create_manifest(version: str | None = None, replace: bool = False) -> None:
|
120 | 124 | files.sort(key=lambda attr: (attr["part"], _alphanumeric(attr["name"])))
|
121 | 125 |
|
122 | 126 | root = Et.Element("PoBVersion")
|
123 |
| - Et.SubElement(root, "Version", number=new_version) |
| 127 | + Et.SubElement(root, "Version", versions) |
124 | 128 | for attributes in parts:
|
125 | 129 | Et.SubElement(root, "Source", attributes)
|
126 | 130 | for attributes in files:
|
|
0 commit comments