LibCore: Read version information from uname() instead of /res/version

This commit is contained in:
kleines Filmröllchen 2022-08-30 12:47:44 +02:00 committed by Linus Groh
parent 83da2be8f3
commit 38bb189772
Notes: sideshowbarker 2024-07-17 18:23:22 +09:00

View file

@ -4,22 +4,22 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibCore/ConfigFile.h>
#include <AK/String.h>
#include <LibCore/System.h>
#include <LibCore/Version.h>
namespace Core::Version {
String read_long_version_string()
{
auto version_config = Core::ConfigFile::open("/res/version.ini").release_value_but_fixme_should_propagate_errors();
auto major_version = version_config->read_entry("Version", "Major", "0");
auto minor_version = version_config->read_entry("Version", "Minor", "0");
auto result = Core::System::uname();
if (result.is_error())
return {};
StringBuilder builder;
builder.appendff("Version {}.{}", major_version, minor_version);
if (auto git_version = version_config->read_entry("Version", "Git", ""); git_version != "")
builder.appendff(".g{}", git_version);
return builder.to_string();
auto version = result.value().release;
auto git_hash = result.value().version;
return String::formatted("Version {} revision {}", version, git_hash);
}
}