2023-10-12 23:23:55 +02:00
|
|
|
import {$t} from "./i18n";
|
2024-02-13 02:08:24 +01:00
|
|
|
import {realm} from "./state_data";
|
2023-10-12 23:23:55 +02:00
|
|
|
|
|
|
|
export function version_display_string(): string {
|
2024-02-13 02:08:24 +01:00
|
|
|
const version = realm.zulip_version;
|
|
|
|
const is_fork = realm.zulip_merge_base && realm.zulip_merge_base !== version;
|
2023-10-12 23:23:55 +02:00
|
|
|
|
2024-02-13 02:08:24 +01:00
|
|
|
if (realm.zulip_version.endsWith("-dev+git")) {
|
2023-10-12 23:23:55 +02:00
|
|
|
// The development environment uses this version string format.
|
|
|
|
return $t({defaultMessage: "Zulip Server dev environment"});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_fork) {
|
|
|
|
// For forks, we want to describe the Zulip version this was
|
|
|
|
// forked from, and that it was modified.
|
2024-02-13 02:08:24 +01:00
|
|
|
const display_version = realm.zulip_merge_base
|
2023-10-12 23:23:55 +02:00
|
|
|
.replace(/\+git.*/, "")
|
2023-11-21 20:49:25 +01:00
|
|
|
.replace(/(-beta\d+).*/, "$1")
|
2023-10-12 23:23:55 +02:00
|
|
|
.replace(/-dev.*/, "-dev");
|
|
|
|
return $t({defaultMessage: "Zulip Server {display_version} (modified)"}, {display_version});
|
|
|
|
}
|
|
|
|
|
|
|
|
// The below cases are all for official versions; either a
|
|
|
|
// release, or Git commit from one of Zulip's official branches.
|
|
|
|
|
|
|
|
if (version.includes("+git")) {
|
|
|
|
// A version from a Zulip official maintenance branch such as 5.x.
|
|
|
|
const display_version = version.replace(/\+git.*/, "");
|
|
|
|
return $t({defaultMessage: "Zulip Server {display_version} (patched)"}, {display_version});
|
|
|
|
}
|
|
|
|
|
|
|
|
const display_version = version.replace(/\+git.*/, "").replace(/-dev.*/, "-dev");
|
|
|
|
return $t({defaultMessage: "Zulip Server {display_version}"}, {display_version});
|
|
|
|
}
|