1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-27 22:47:44 +00:00

LibCore+LibGUI+About: Use String in Core::Version and GUI::AboutDialog

The Core::Version API now returns ErrorOr<String>, and the
GUI::AboutDialog API was adjusted to accommodate this.
This commit is contained in:
Andreas Kling 2023-02-28 16:39:41 +01:00
parent ad4b4046f4
commit d0977ac566
7 changed files with 40 additions and 33 deletions

View file

@ -8,7 +8,7 @@
#include <AK/Format.h>
#include <AK/JsonObject.h>
#include <AK/OptionParser.h>
#include <AK/StringBuilder.h>
#include <AK/String.h>
#include <LibCore/ArgsParser.h>
#include <LibCore/Version.h>
#include <limits.h>
@ -364,7 +364,7 @@ void ArgsParser::print_usage_markdown(FILE* file, StringView argv0)
void ArgsParser::print_version(FILE* file)
{
outln(file, Core::Version::read_long_version_string());
outln(file, Core::Version::read_long_version_string().release_value_but_fixme_should_propagate_errors());
}
void ArgsParser::add_option(Option&& option)

View file

@ -4,22 +4,20 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/DeprecatedString.h>
#include <AK/String.h>
#include <LibCore/System.h>
#include <LibCore/Version.h>
namespace Core::Version {
DeprecatedString read_long_version_string()
ErrorOr<String> read_long_version_string()
{
auto result = Core::System::uname();
if (result.is_error())
return {};
auto uname = TRY(Core::System::uname());
auto version = result.value().release;
auto git_hash = result.value().version;
auto const* version = uname.release;
auto const* git_hash = uname.version;
return DeprecatedString::formatted("Version {} revision {}", version, git_hash);
return String::formatted("Version {} revision {}", version, git_hash);
}
}

View file

@ -1,15 +1,16 @@
/*
* Copyright (c) 2021, Mahmoud Mandour <ma.mandourr@gmail.com>
* Copyright (c) 2023, Andreas Kling <kling@serenityos.org>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <AK/StringView.h>
#include <AK/Forward.h>
namespace Core::Version {
DeprecatedString read_long_version_string();
ErrorOr<String> read_long_version_string();
}