Parse without regex and change 'let' to 'const'

This commit is contained in:
Ben Muthalaly 2023-11-30 19:57:46 -06:00
parent 4ae35c86f2
commit 25d7f3ed1c
2 changed files with 10 additions and 8 deletions

View file

@ -426,7 +426,7 @@ def get_version_releases(config):
# find upgrade version
upgrade_version = None
smallest_version_diff = parse_tag_name(releases[0]["tag_name"])[1]
for i, release in enumerate(releases):
for release in releases:
release_parts = parse_tag_name(release["tag_name"])
major_version_diff = release_parts[1] - installed_version_parts[1]
if major_version_diff < smallest_version_diff:
@ -750,9 +750,9 @@ def load_config(defaults: ConfigDefaultDict,
def parse_tag_name(v):
"""parses a version tag string formatted like 'vx.x.x'"""
v = re.sub(r"\+.*$", "", v) # in case version string ends with '+editable'
parts = re.sub(r"^v", "", v).split(".")
return [int(p) for p in parts]
base = v.split('+')[0].split('v')[-1] # remove 'v' prefix and '+editable' suffix
int_parts = [int(part) for part in base.split('.')]
return int_parts
def compare_versions(v1, v2):

View file

@ -142,11 +142,12 @@
</div>
<script>
if ("{{CAN_UPGRADE}}" === "True" && !localStorage.getItem("bannerDismissed")) {
let upgradeVersionTag = "{{VERSION_RELEASES.upgrade_version.tag_name}}"
{% if user.is_authenticated and CAN_UPGRADE %}
if (!localStorage.getItem("bannerDismissed")) {
const upgradeVersionTag = "{{VERSION_RELEASES.upgrade_version.tag_name}}"
const upgradeVersionURL = "{{VERSION_RELEASES.upgrade_version.html_url}}"
let currentVersionTag = "{{VERSION}}"
let currentVersionURL = "{{VERSION_RELEASES.current_version.html_url}}"
const currentVersionTag = "{{VERSION}}"
const currentVersionURL = "{{VERSION_RELEASES.current_version.html_url}}"
createBanner(currentVersionTag, currentVersionURL, upgradeVersionTag, upgradeVersionURL)
}
@ -174,6 +175,7 @@
banner.style.display = "none"
localStorage.setItem("bannerDismissed", "true")
}
{% endif %}
$ = django.jQuery;
$.fn.reverse = [].reverse;