From 041dfc00d41ac1a2c144e25ff67c04d5fd143e60 Mon Sep 17 00:00:00 2001 From: Andrey Khrolenok Date: Tue, 2 Mar 2021 04:19:00 +0300 Subject: [PATCH] Remaster release version generation --- bin/gen_releasenotes | 10 +++------- bin/release | 4 ++-- tests/test_config_flow.py | 2 +- 3 files changed, 6 insertions(+), 10 deletions(-) diff --git a/bin/gen_releasenotes b/bin/gen_releasenotes index 5e7413b..29e078c 100755 --- a/bin/gen_releasenotes +++ b/bin/gen_releasenotes @@ -3,11 +3,11 @@ import argparse import logging import os -import re import subprocess from datetime import datetime from typing import List +from awesomeversion.match import is_pep440 from github import Github, GithubException, Repository, Tag from packaging.version import Version @@ -54,13 +54,9 @@ def get_commits(repo: Repository, since: datetime, until: datetime): def get_release_tags(repo: Repository) -> List[Tag.Tag]: """Get list of all release tags from repository.""" - reg = re.compile( - r"^v?[0-9]+\.[0-9]+(?:\.[0-9]+)?" - r"(?:[._-]?[A-Za-z]*[._-]?[0-9]*)?" - r"(?:[._-]?dev[0-9]*)?" - r"(?:-[0-9A-Za-z-]+(?:\.[0-9A-Za-z-]+)*)?(?:\+[0-9A-Za-z-]+)?$" + tags = list( + filter(lambda tag: is_pep440(tag.name.lstrip("v")), list(repo.get_tags())) ) - tags = list(filter(lambda tag: re.match(reg, tag.name), list(repo.get_tags()))) tags.sort(key=lambda x: x.name.lstrip("v"), reverse=True) _LOGGER.debug("Found tags: %s", tags) return tags diff --git a/bin/release b/bin/release index b6378cf..1ae88c2 100755 --- a/bin/release +++ b/bin/release @@ -39,6 +39,6 @@ git commit -a --no-verify -m "Bump version" git tag -a "$new" -m "v$new" log.info "Commit tagged as v$new" -log.info "Patch files to version '${new}+dev'..." -sed -i -E "s/(^VERSION = \")[^\"]*/\\1${new}+dev/" ${const_path} +log.info "Patch files to version '${new}.dev0'..." +sed -i -E "s/(^VERSION = \")[^\"]*/\\1${new}.dev0/" ${const_path} ./bin/update_manifest diff --git a/tests/test_config_flow.py b/tests/test_config_flow.py index 326eb16..cf0128b 100644 --- a/tests/test_config_flow.py +++ b/tests/test_config_flow.py @@ -1,8 +1,8 @@ """Test integration_blueprint config flow.""" from unittest.mock import patch -from homeassistant import config_entries, data_entry_flow import pytest +from homeassistant import config_entries, data_entry_flow from pytest_homeassistant_custom_component.common import MockConfigEntry from custom_components.integration_blueprint.const import (