fix(update message): multiple fixes (#6275)

- added GitPython as a dependency
- use git describe to find the branch version
- prevent version popup for prereleases
- check for update weekly instead of daily
- fixed bug in check for update which used to compare minor version even
if there was a mismatch in comparing major versions

Signed-off-by: Ameya Shenoy <shenoy.ameya@gmail.com>
This commit is contained in:
Ameya Shenoy 2018-10-18 12:33:00 +05:30 committed by Rushabh Mehta
parent e45a3660d0
commit 04d255bc5f
3 changed files with 14 additions and 5 deletions

View file

@ -171,7 +171,6 @@ scheduler_events = {
"frappe.email.doctype.auto_email_report.auto_email_report.send_daily",
"frappe.core.doctype.feedback_request.feedback_request.delete_feedback_request",
"frappe.core.doctype.activity_log.activity_log.clear_authentication_logs",
"frappe.utils.change_log.check_for_update"
],
"daily_long": [
"frappe.integrations.doctype.dropbox_settings.dropbox_settings.take_backups_daily",
@ -179,7 +178,8 @@ scheduler_events = {
],
"weekly_long": [
"frappe.integrations.doctype.dropbox_settings.dropbox_settings.take_backups_weekly",
"frappe.integrations.doctype.s3_backup_settings.s3_backup_settings.take_backups_weekly"
"frappe.integrations.doctype.s3_backup_settings.s3_backup_settings.take_backups_weekly",
"frappe.utils.change_log.check_for_update"
],
"monthly": [
"frappe.email.doctype.auto_email_report.auto_email_report.send_monthly"

View file

@ -9,8 +9,9 @@ import frappe
import requests
import subprocess # nosec
from frappe.utils import cstr
from frappe.utils.gitutils import get_app_last_commit_ref, get_app_branch
from frappe.utils.gitutils import get_app_branch
from frappe import _, safe_decode
import git
def get_change_log(user=None):
if not user: user = frappe.session.user
@ -103,7 +104,12 @@ def get_versions():
}
if versions[app]['branch'] != 'master':
branch_version = app_hooks.get('{0}_version'.format(versions[app]['branch']))
try:
app_repo = git.Repo(os.path.join('..', 'apps', '{}'.format(app)))
branch_version = '-'.join(app_repo.git.describe().split('-')[:2])
branch_version = [branch_version.strip('v')]
except:
branch_version = app_hooks.get('{0}_version'.format(versions[app]['branch']))
if branch_version:
versions[app]['branch_version'] = branch_version[0] + ' ({0})'.format(get_app_last_commit_ref(app))
@ -145,7 +151,7 @@ def check_for_update():
github_version, org_name = app_details
# Get local instance's current version or the app
instance_version = Version(apps[app]['version'])
instance_version = Version(apps[app]['branch_version'].split(' ')[0])
# Compare and popup update message
for update_type in updates:
if github_version.__dict__[update_type] > instance_version.__dict__[update_type]:
@ -157,6 +163,7 @@ def check_for_update():
title = apps[app]['title'],
))
break
if github_version.__dict__[update_type] < instance_version.__dict__[update_type]: break
add_message_to_redis(updates)
@ -218,6 +225,7 @@ def show_update_popup():
return
updates = json.loads(update_info)
current_versions = get_versions()
# Check if user is int the set of users to send update message to
update_message = ""

View file

@ -55,3 +55,4 @@ google-auth-oauthlib
faker
stripe
coverage
GitPython==2.1.11