Skip to content

Commit f3b5635

Browse files
committed
update manifest generation script to include latest commit hash
1 parent cb1faaf commit f3b5635

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

update_manifest.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import pathlib
99
import re
1010
import xml.etree.ElementTree as Et
11+
import subprocess
1112
from typing import Any, Callable
1213

1314
alphanumeric_pattern = re.compile(r"(\d+)")
@@ -49,6 +50,8 @@ def _alphanumeric(key: str) -> list[int | str]:
4950
for character in re.split(alphanumeric_pattern, key)
5051
]
5152

53+
def _get_latest_commit_hash_short() -> str:
54+
return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip()
5255

5356
def create_manifest(version: str | None = None, replace: bool = False) -> None:
5457
"""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:
7881
logging.critical(f"Manifest configuration file not found in path '{base_path}'")
7982
return
8083

84+
versions = {"number":new_version, "hash":_get_latest_commit_hash_short()}
8185
base_url = "https://raw.githubusercontent.com/PathOfBuildingCommunity/PathOfBuilding/{branch}/"
8286
parts: list[dict[str, str]] = []
8387
for part in config.sections():
@@ -120,7 +124,7 @@ def create_manifest(version: str | None = None, replace: bool = False) -> None:
120124
files.sort(key=lambda attr: (attr["part"], _alphanumeric(attr["name"])))
121125

122126
root = Et.Element("PoBVersion")
123-
Et.SubElement(root, "Version", number=new_version)
127+
Et.SubElement(root, "Version", versions)
124128
for attributes in parts:
125129
Et.SubElement(root, "Source", attributes)
126130
for attributes in files:

0 commit comments

Comments
 (0)