mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-01 15:18:06 +00:00
Meta+LibCore: Include git hash in version string
If the `LADYBIRD_GIT_VERSION` environment variable is set, then use it to set the version number printed by the `--version` argument.
This commit is contained in:
parent
e815847f86
commit
472d5e87e9
Notes:
github-actions[bot]
2024-10-29 13:31:21 +00:00
Author: https://github.com/tcl3
Commit: 472d5e87e9
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/1940
Reviewed-by: https://github.com/trflynn89 ✅
1 changed files with 15 additions and 0 deletions
|
@ -5,12 +5,27 @@
|
|||
*/
|
||||
|
||||
#include <AK/String.h>
|
||||
#include <LibCore/Environment.h>
|
||||
#include <LibCore/Version.h>
|
||||
|
||||
namespace Core::Version {
|
||||
|
||||
ErrorOr<String> read_long_version_string()
|
||||
{
|
||||
auto validate_git_hash = [](auto hash) {
|
||||
if (hash.length() < 4 || hash.length() > 40)
|
||||
return false;
|
||||
for (auto ch : hash) {
|
||||
if (!is_ascii_hex_digit(ch))
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
|
||||
auto maybe_git_hash = Core::Environment::get("LADYBIRD_GIT_VERSION"sv);
|
||||
|
||||
if (maybe_git_hash.has_value() && validate_git_hash(maybe_git_hash.value()))
|
||||
return MUST(String::formatted("Version 1.0-{}", maybe_git_hash.value()));
|
||||
return "Version 1.0"_string;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue