Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion openevsehttp/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,9 @@ def get_awesome_version(version: str) -> AwesomeVersion:
# We use custom word boundary checks to avoid false positives like 'domain' matching 'main'
# or 'webmaster' matching 'master'.
is_dev = False
if re.search(
if re.search(r"[^/]+/[^_]+_[a-fA-F0-9]{6,40}_modified$", version, re.IGNORECASE):
is_dev = True
elif re.search(
r"(?:^|[^a-zA-Z0-9])(master|main)(?:[^a-zA-Z0-9]|$)", version, re.IGNORECASE
):
is_dev = True
Expand Down
15 changes: 14 additions & 1 deletion tests/test_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -671,14 +671,27 @@ async def test_version_check_dev_branches():
charger._config = {"version": "feature_1A2B3C"}
assert charger._version_check("2.0.0") is True

# Local dev build templates (category/branch_hash_modified) - treated as dev, returns True
charger._config = {
"version": "local_feature/gui-nightshift-default_2bcdf1d0_modified"
}
assert charger._version_check("2.0.0") is True

charger._config = {"version": "custom_branch/my-feature_abc123_modified"}
assert charger._version_check("2.0.0") is True

# False positives containing 'main' or 'master' but not at word boundaries,
# or ending in 6-char hashes without dev keywords — should fail version check
# ending in 6-char hashes without dev keywords, or other non-matching modified strings
# — should fail version check
charger._config = {"version": "domain_abc123"}
assert charger._version_check("2.0.0") is False

charger._config = {"version": "webmaster_def456"}
assert charger._version_check("2.0.0") is False

charger._config = {"version": "unmodified"}
assert charger._version_check("2.0.0") is False

# Pre-release (rc) version — should fail when checking against a newer target
charger._config = {"version": "4.1.2_rc1"}
assert charger._version_check("5.0.0") is False
Expand Down
Loading