format version string in help the same way

develop
Myk Taylor 2023-04-23 18:20:50 -07:00
parent 33142a5dfc
commit b5459faffe
No known key found for this signature in database
4 changed files with 9 additions and 6 deletions

@ -273,7 +273,7 @@ static std::string dfhack_version_desc()
if (Version::is_release())
s << "(release)";
else
s << "(development build " << Version::git_description() << ")";
s << "(git: " << Version::git_commit(true) << ")";
s << " on " << (sizeof(void*) == 8 ? "x86_64" : "x86");
if (strlen(Version::dfhack_build_id()))
s << " [build ID: " << Version::dfhack_build_id() << "]";

@ -1,6 +1,8 @@
#define NO_DFHACK_VERSION_MACROS
#include "DFHackVersion.h"
#include "git-describe.h"
#include <string>
namespace DFHack {
namespace Version {
int dfhack_abi_version()
@ -27,9 +29,10 @@ namespace DFHack {
{
return DFHACK_GIT_DESCRIPTION;
}
const char *git_commit()
const char* git_commit(bool short_hash)
{
return DFHACK_GIT_COMMIT;
static std::string shorty(DFHACK_GIT_COMMIT, 0, 7);
return short_hash ? shorty.c_str() : DFHACK_GIT_COMMIT;
}
const char *git_xml_commit()
{

@ -8,7 +8,7 @@ namespace DFHack {
int dfhack_abi_version();
const char *git_description();
const char *git_commit();
const char* git_commit(bool short_hash = false);
const char *git_xml_commit();
const char *git_xml_expected_commit();
bool git_xml_match();

@ -571,13 +571,13 @@ TitleVersionOverlay.ATTRS{
default_pos={x=50, y=-2},
default_enabled=true,
viewscreens='title',
frame={w=30, h=3},
frame={w=35, h=3},
}
function TitleVersionOverlay:init()
local text = {}
table.insert(text, 'DFHack ' .. dfhack.getDFHackVersion() ..
(dfhack.isPrerelease() and (' (%s)'):format(dfhack.getGitCommit():sub(1,7)) or ''))
(dfhack.isPrerelease() and (' (git: %s)'):format(dfhack.getGitCommit(true)) or ''))
if #dfhack.getDFHackBuildID() > 0 then
table.insert(text, NEWLINE)
table.insert(text, 'Build ID: ' .. dfhack.getDFHackBuildID())