F4MP/codigos originales/tiltedcode/Tools/modules/version.lua
2026-01-06 18:53:59 +01:00

36 lines
No EOL
684 B
Lua

function main (target)
local host = os.host()
local subhost = os.subhost()
local system
if (host ~= subhost) then
system = host .. "/" .. subhost
else
system = host
end
local branch = "unknown-branch"
local commitHash = "unknown-commit"
try
{
function ()
import("detect.tools.find_git")
local git = find_git()
if (git) then
branch = os.iorunv(git, {"rev-parse", "--abbrev-ref", "HEAD"}):trim()
commitHash = os.iorunv(git, {"describe", "--tags"}):trim()
else
error("git not found")
end
end,
catch
{
function (err)
print(string.format("Failed to retrieve git data: %s", err))
end
}
}
return branch, commitHash
end