From 9fabdadb9b89a5d0634b896e79a0d7abe90ef64c Mon Sep 17 00:00:00 2001 From: unknown Date: Wed, 25 Dec 2024 14:17:11 +0100 Subject: [PATCH] Make sure Git SHA is for the Flixel repository --- flixel/system/macros/FlxGitSHA.hx | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/flixel/system/macros/FlxGitSHA.hx b/flixel/system/macros/FlxGitSHA.hx index 7c5c664c3b..8e58d6cc52 100644 --- a/flixel/system/macros/FlxGitSHA.hx +++ b/flixel/system/macros/FlxGitSHA.hx @@ -1,5 +1,6 @@ package flixel.system.macros; +import haxe.io.Path; import haxe.macro.Context; import haxe.macro.Expr; import sys.io.Process; @@ -58,7 +59,7 @@ class FlxGitSHA } } - return result; + return Path.normalize(result); } public static function getGitSHA(path:String):String @@ -66,9 +67,11 @@ class FlxGitSHA var oldWd = Sys.getCwd(); Sys.setCwd(path); - var sha = getProcessOutput("git", ["rev-parse", "HEAD"]); + var output = getProcessOutput("git", ["rev-parse", "HEAD", "--show-toplevel"]).split("\n"); + var sha = output[0]; + var gitPath = Path.normalize(output[1]); var shaRegex = ~/[a-f0-9]{40}/g; - if (!shaRegex.match(sha)) + if (!shaRegex.match(sha) || path != gitPath) sha = ""; Sys.setCwd(oldWd); @@ -96,4 +99,4 @@ class FlxGitSHA return ""; } } -} \ No newline at end of file +}