version: Display Zulip version in About Zulip dialog.

We record Git details about the merge-base with upstream branches in
the zulip-git-version file, if the upstream repository is available.

Note that the first Git upgrade after merging the parent commit will
not include the merge-base details, since the upstream repository will
not have been available.

Co-authored-by: Tim Abbott <tabbott@zulip.com>
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
Anders Kaseorg 2021-05-12 17:50:42 -07:00 committed by Tim Abbott
parent 03420831b0
commit 668b5137b0
8 changed files with 45 additions and 66 deletions

View File

@ -335,12 +335,6 @@ on a dark background, and don't change the dark labels dark either. */
opacity: 0.2; opacity: 0.2;
} }
#about-zulip {
.about-zulip-version {
color: hsl(212, 17%, 81%);
}
}
#gear_menu_about_zulip { #gear_menu_about_zulip {
.white_zulip_icon_without_text { .white_zulip_icon_without_text {
filter: invert(10%) sepia(16%) saturate(175%) hue-rotate(194deg) filter: invert(10%) sepia(16%) saturate(175%) hue-rotate(194deg)

View File

@ -2720,41 +2720,17 @@ select.inline_select_topic_edit {
} }
.overlay-content { .overlay-content {
position: relative; width: 440px;
width: 300px;
border-radius: 4px; border-radius: 4px;
} }
.modal-body {
display: flex;
flex-direction: column;
align-items: center;
}
.about-zulip-logo { .about-zulip-logo {
padding-top: 20px; text-align: center;
height: 70px; margin: 30px;
} }
.about-zulip-title { .about-zulip-logo img {
font-weight: 600; height: 40px;
padding: 10px;
}
.about-zulip-version {
color: hsl(222, 8%, 28%);
.fa-copy {
padding-left: 3px;
}
:hover {
cursor: pointer;
.fa-copy {
color: hsl(0, 0%, 0%);
}
}
} }
} }

View File

@ -1,16 +1,30 @@
<div id="about-zulip" class="overlay flex new-style" tabindex="-1" role="dialog" data-overlay="about-zulip" <div id="about-zulip" class="overlay flex new-style" tabindex="-1" role="dialog" data-overlay="about-zulip" aria-hidden="true">
aria-labelledby="about-zulip-label" aria-hidden="true">
<div class="overlay-content modal-bg"> <div class="overlay-content modal-bg">
<button type="button" class="exit" aria-label="{{ _('Close') }}"><span aria-hidden="true">&times;</span></button> <button type="button" class="exit" aria-label="{{ _('Close') }}"><span aria-hidden="true">&times;</span></button>
<div class="modal-body"> <div class="modal-body">
<img class="about-zulip-logo" src="/static/images/logo/zulip-icon-128x128.png" alt="" /> <div class="about-zulip-logo">
<div class="about-zulip-title">Zulip</div> <img src="/static/images/logo/zulip-org-logo.svg" alt="" />
<p class="about-zulip-version"> </div>
{{zulip_version_name}} <p>
<i class="fa fa-copy tippy-zulip-tooltip" data-tippy-content="Copy version" data-tippy-placement="right" data-clipboard-text="{{zulip_version}}"></i> This is an installation of <a target="_blank" rel="noopener noreferrer"
href="https://zulip.com">Zulip</a>.
</p> </p>
<p> <p>
Zulip is <a target="_blank" rel="noopener noreferrer" href="https://github.com/zulip/zulip">open-source software</a>.</p> Zulip Server version {{zulip_version}}
<i class="fa fa-copy tippy-zulip-tooltip" data-tippy-content="Copy version" data-tippy-placement="right" data-clipboard-text="{{zulip_version}}"></i>
{% if zulip_merge_base and zulip_version != zulip_merge_base %}
<br />
Forked from upstream at {{zulip_merge_base}}
<i class="fa fa-copy tippy-zulip-tooltip" data-tippy-content="Copy version" data-tippy-placement="right" data-clipboard-text="{{zulip_merge_base}}"></i>
{% endif %}
</p>
<p>
Copyright 20122015 Dropbox, Inc., 20152021 Kandra Labs, Inc., and contributors.
</p>
<p>
Zulip is <a target="_blank" rel="noopener noreferrer" href="https://github.com/zulip/zulip#readme">open-source software</a>,
distributed under the Apache 2.0 license.
</p>
</div> </div>
</div> </div>
</div> </div>

View File

@ -1,5 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -e set -eu
cd "$(dirname "$0")/.." cd "$(dirname "$0")/.."
git describe --tags --match='[0-9]*' >zulip-git-version || true remote="$(git config zulip.zulipRemote)" || remote=upstream
{
git describe --always --tags --match='[0-9]*'
branches="$(git for-each-ref --format='%(objectname)' "refs/remotes/$remote/master" "refs/remotes/$remote/*.x")"
mapfile -t branches <<<"$branches"
if merge_base="$(git merge-base -- HEAD "${branches[@]}")"; then
git describe --always --tags --match='[0-9]*' -- "$merge_base"
fi
} >zulip-git-version

View File

@ -1,15 +1,17 @@
import os import os
ZULIP_VERSION = "4.0-rc1+git" ZULIP_VERSION = "4.0-rc1+git"
# Add information on number of commits and commit hash to version, if available # Add information on number of commits and commit hash to version, if available
zulip_git_version_file = os.path.join( zulip_git_version_file = os.path.join(
os.path.dirname(os.path.abspath(__file__)), "zulip-git-version" os.path.dirname(os.path.abspath(__file__)), "zulip-git-version"
) )
lines = [ZULIP_VERSION, ""]
if os.path.exists(zulip_git_version_file): if os.path.exists(zulip_git_version_file):
with open(zulip_git_version_file) as f: with open(zulip_git_version_file) as f:
version = f.read().strip() lines = f.readlines() + ["", ""]
if version: ZULIP_VERSION = lines.pop(0).strip()
ZULIP_VERSION = version ZULIP_MERGE_BASE = lines.pop(0).strip()
LATEST_MAJOR_VERSION = "3.0" LATEST_MAJOR_VERSION = "3.0"
LATEST_RELEASE_VERSION = "3.0" LATEST_RELEASE_VERSION = "3.0"

View File

@ -49,13 +49,6 @@ def common_context(user: UserProfile) -> Dict[str, Any]:
} }
def get_zulip_version_name(zulip_version: str) -> str:
if zulip_version.endswith("+git"):
return "Zulip " + zulip_version[:-4]
return "Zulip " + zulip_version
def get_realm_from_request(request: HttpRequest) -> Optional[Realm]: def get_realm_from_request(request: HttpRequest) -> Optional[Realm]:
if hasattr(request, "user") and hasattr(request.user, "realm"): if hasattr(request, "user") and hasattr(request.user, "realm"):
return request.user.realm return request.user.realm
@ -142,8 +135,6 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:
"request_language": get_language(), "request_language": get_language(),
} }
ZULIP_VERSION_NAME = get_zulip_version_name(ZULIP_VERSION)
context = { context = {
"root_domain_landing_page": settings.ROOT_DOMAIN_LANDING_PAGE, "root_domain_landing_page": settings.ROOT_DOMAIN_LANDING_PAGE,
"custom_logo_url": settings.CUSTOM_LOGO_URL, "custom_logo_url": settings.CUSTOM_LOGO_URL,
@ -169,7 +160,6 @@ def zulip_default_context(request: HttpRequest) -> Dict[str, Any]:
"password_min_length": settings.PASSWORD_MIN_LENGTH, "password_min_length": settings.PASSWORD_MIN_LENGTH,
"password_min_guesses": settings.PASSWORD_MIN_GUESSES, "password_min_guesses": settings.PASSWORD_MIN_GUESSES,
"zulip_version": ZULIP_VERSION, "zulip_version": ZULIP_VERSION,
"zulip_version_name": ZULIP_VERSION_NAME,
"user_is_authenticated": user_is_authenticated, "user_is_authenticated": user_is_authenticated,
"settings_path": settings_path, "settings_path": settings_path,
"secrets_path": secrets_path, "secrets_path": secrets_path,

View File

@ -1,8 +0,0 @@
from zerver.context_processors import get_zulip_version_name
from zerver.lib.test_classes import ZulipTestCase
class TestContextProcessors(ZulipTestCase):
def test_get_zulip_version_name(self) -> None:
self.assertEqual(get_zulip_version_name("4.0-dev+git"), "Zulip 4.0-dev")
self.assertEqual(get_zulip_version_name("4.0"), "Zulip 4.0")

View File

@ -8,6 +8,7 @@ from django.shortcuts import redirect, render
from django.urls import reverse from django.urls import reverse
from django.utils.cache import patch_cache_control from django.utils.cache import patch_cache_control
from version import ZULIP_MERGE_BASE, ZULIP_VERSION
from zerver.context_processors import get_valid_realm_from_request from zerver.context_processors import get_valid_realm_from_request
from zerver.decorator import web_public_view, zulip_login_required from zerver.decorator import web_public_view, zulip_login_required
from zerver.forms import ToSForm from zerver.forms import ToSForm
@ -240,6 +241,8 @@ def home_real(request: HttpRequest) -> HttpResponse:
"is_admin": user_permission_info.is_realm_admin, "is_admin": user_permission_info.is_realm_admin,
"is_guest": user_permission_info.is_guest, "is_guest": user_permission_info.is_guest,
"color_scheme": user_permission_info.color_scheme, "color_scheme": user_permission_info.color_scheme,
"zulip_version": ZULIP_VERSION,
"zulip_merge_base": ZULIP_MERGE_BASE,
"navbar_logo_url": navbar_logo_url, "navbar_logo_url": navbar_logo_url,
"show_webathena": user_permission_info.show_webathena, "show_webathena": user_permission_info.show_webathena,
"embedded": narrow_stream is not None, "embedded": narrow_stream is not None,