diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 21f4573b79..274216337f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -86,7 +86,7 @@ Note that automatic updates are disabled in Dev Mode. Sometimes you may need to force Dev mode OFF when running from the dev branch to debug a specific part of Path of Building (e.g. the update system). -To do so [comment out Line 54 to line 58](./src/Launch.lua#L54-L58) of the [Launch.lua](./src/Launch.lua) file: +To do so [comment out Line 65 to line 69](./src/Launch.lua#L65-L69) of the [Launch.lua](./src/Launch.lua) file: ``` --if localManXML and not self.versionBranch and not self.versionPlatform then -- -- Looks like a remote manifest, so we're probably running from a repository diff --git a/manifest.xml b/manifest.xml index 485f473f50..b65d890d4f 100644 --- a/manifest.xml +++ b/manifest.xml @@ -1,6 +1,6 @@ - + @@ -283,7 +283,7 @@ - + @@ -293,7 +293,7 @@ - + @@ -330,41 +330,41 @@ - + - + - + - + - + - + - + - + @@ -381,7 +381,7 @@ - + @@ -398,7 +398,7 @@ - + @@ -415,7 +415,7 @@ - + @@ -433,7 +433,7 @@ - + @@ -450,7 +450,7 @@ - + @@ -469,7 +469,7 @@ - + @@ -487,7 +487,7 @@ - + @@ -506,7 +506,7 @@ - + @@ -677,7 +677,7 @@ - + diff --git a/src/Launch.lua b/src/Launch.lua index 0775ec4dc2..d3793889b0 100644 --- a/src/Launch.lua +++ b/src/Launch.lua @@ -21,6 +21,7 @@ function launch:OnInit() self.versionNumber = "?" self.versionBranch = "?" self.versionPlatform = "?" + self.versionCommitHashShort = "?" self.lastUpdateCheck = GetTime() self.subScripts = { } self.startTime = startTime @@ -47,6 +48,7 @@ function launch:OnInit() if type(node) == "table" then if node.elem == "Version" then self.versionNumber = node.attrib.number + self.versionCommitHashShort = node.attrib.hash self.versionBranch = node.attrib.branch self.versionPlatform = node.attrib.platform end diff --git a/src/Modules/Main.lua b/src/Modules/Main.lua index e5b2479b83..1b9272e34f 100644 --- a/src/Modules/Main.lua +++ b/src/Modules/Main.lua @@ -209,10 +209,16 @@ function main:Init() self.controls.forkLabel.label = function() return "^8PoB Community Fork" end - self.controls.versionLabel = new("LabelControl", {"BOTTOMLEFT",self.anchorMain,"BOTTOMLEFT"}, 148, -2, 0, 16, "") + self.controls.versionLabel = new("LabelControl", {"BOTTOMLEFT",self.anchorMain,"BOTTOMLEFT"}, 148, launch.versionBranch == "beta" and -12 or -2, 0, 16, "") self.controls.versionLabel.label = function() return "^8Version: "..launch.versionNumber..(launch.versionBranch == "dev" and " (Dev)" or launch.versionBranch == "beta" and " (Beta)" or "") end + if launch.versionBranch == "beta" then + self.controls.versionHash = new("LabelControl", {"BOTTOMLEFT",self.anchorMain,"BOTTOMLEFT"}, 148, 3, 0, 16, "") + self.controls.versionHash.label = function() + return "^8Rev/Hash: "..launch.versionCommitHashShort + end + end self.controls.devMode = new("LabelControl", {"BOTTOMLEFT",self.anchorMain,"BOTTOMLEFT"}, 0, -26, 0, 20, colorCodes.NEGATIVE.."Dev Mode") self.controls.devMode.shown = function() return launch.devMode diff --git a/src/UpdateCheck.lua b/src/UpdateCheck.lua index 636473305f..9fef0b5c3f 100644 --- a/src/UpdateCheck.lua +++ b/src/UpdateCheck.lua @@ -122,7 +122,7 @@ end localSource = localSource:gsub("{branch}", localBranch) -- Download and process remote manifest -local remoteVer +local remoteVer, remoteHash local remoteFiles = { } local remoteSources = { } local remoteManText, errMsg = downloadFileText(localSource, "manifest.xml") @@ -136,6 +136,7 @@ if remoteManXML and remoteManXML[1].elem == "PoBVersion" then if type(node) == "table" then if node.elem == "Version" then remoteVer = node.attrib.number + remoteHash = node.attrib.hash elseif node.elem == "Source" then if not remoteSources[node.attrib.part] then remoteSources[node.attrib.part] = { } @@ -155,7 +156,7 @@ if remoteManXML and remoteManXML[1].elem == "PoBVersion" then end end end -if not remoteVer or not next(remoteSources) or not next(remoteFiles) then +if not remoteVer or not remoteHash or not next(remoteSources) or not next(remoteFiles) then ConPrintf("Update check failed: invalid remote manifest") return nil, "Invalid remote manifest" end @@ -264,7 +265,7 @@ end -- Create new manifest localManXML = { elem = "PoBVersion" } -table.insert(localManXML, { elem = "Version", attrib = { number = remoteVer, platform = localPlatform, branch = localBranch } }) +table.insert(localManXML, { elem = "Version", attrib = { number = remoteVer, hash = remoteHash, platform = localPlatform, branch = localBranch } }) for part, platforms in pairs(remoteSources) do for platform, url in pairs(platforms) do table.insert(localManXML, { elem = "Source", attrib = { part = part, platform = platform ~= "any" and platform, url = url } }) diff --git a/update_manifest.py b/update_manifest.py index 910ea8236f..b2b7dd0582 100644 --- a/update_manifest.py +++ b/update_manifest.py @@ -8,6 +8,7 @@ import pathlib import re import xml.etree.ElementTree as Et +import subprocess from typing import Any, Callable alphanumeric_pattern = re.compile(r"(\d+)") @@ -49,6 +50,8 @@ def _alphanumeric(key: str) -> list[int | str]: for character in re.split(alphanumeric_pattern, key) ] +def _get_latest_commit_hash_short() -> str: + return subprocess.check_output(['git', 'rev-parse', '--short', 'HEAD']).decode('ascii').strip() def create_manifest(version: str | None = None, replace: bool = False) -> None: """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: logging.critical(f"Manifest configuration file not found in path '{base_path}'") return + versions = {"number":new_version, "hash":_get_latest_commit_hash_short()} base_url = "https://raw.githubusercontent.com/PathOfBuildingCommunity/PathOfBuilding/{branch}/" parts: list[dict[str, str]] = [] for part in config.sections(): @@ -120,7 +124,7 @@ def create_manifest(version: str | None = None, replace: bool = False) -> None: files.sort(key=lambda attr: (attr["part"], _alphanumeric(attr["name"]))) root = Et.Element("PoBVersion") - Et.SubElement(root, "Version", number=new_version) + Et.SubElement(root, "Version", versions) for attributes in parts: Et.SubElement(root, "Source", attributes) for attributes in files: