summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibCore/Version.cpp
blob: 8a162e9d6532d4b34bf98a9c588c844e6f245e6b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
/*
 * Copyright (c) 2021, Mahmoud Mandour <ma.mandourr@gmail.com>
 *
 * SPDX-License-Identifier: BSD-2-Clause
 */

#include <LibCore/ConfigFile.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");

    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();
}

}