LibCore: Read version information from uname() instead of /res/version
This commit is contained in:
parent
83da2be8f3
commit
38bb189772
Notes:
sideshowbarker
2024-07-17 18:23:22 +09:00
Author: https://github.com/kleinesfilmroellchen Commit: https://github.com/SerenityOS/serenity/commit/38bb189772 Pull-request: https://github.com/SerenityOS/serenity/pull/15068 Issue: https://github.com/SerenityOS/serenity/issues/15071 Reviewed-by: https://github.com/ADKaster Reviewed-by: https://github.com/Hendiadyoin1 Reviewed-by: https://github.com/gmta Reviewed-by: https://github.com/linusg
1 changed files with 9 additions and 9 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue