diff --git a/.bumpversion.cfg b/.bumpversion.cfg index 99ef481..6f0a902 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 1.1.2 +current_version = 1.1.6 commit = True tag = False diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 4d78026..610f6a5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -73,7 +73,7 @@ repos: stages: [pre-push] - id: commit-msg-version-check name: commit-msg-version-check - entry: python commit_msg_version_bump/main.py --log-level=INFO + entry: python commit_msg_version_bump/main.py --log-level=DEBUG always_run: true language: system pass_filenames: false diff --git a/commit_msg_version_bump/main.py b/commit_msg_version_bump/main.py index d013f03..03721d9 100644 --- a/commit_msg_version_bump/main.py +++ b/commit_msg_version_bump/main.py @@ -171,21 +171,18 @@ def get_new_version(pyproject_path: str = "pyproject.toml") -> str: sys.exit(1) -def add_icon_and_prepare_commit_message( - commit_type: str, current_version: str, new_version: str -) -> str: +def add_icon_and_prepare_commit_message(current_version: str, new_version: str) -> str: """ Prepares the new commit message with the icon and version bump. Args: - commit_type (str): The type of the commit (e.g., 'chore', 'fix'). current_version (str): The current version before bump. new_version (str): The new version after bump. Returns: str: The new commit message. """ - icon = TYPE_MAPPING.get(commit_type.lower(), "") + icon = "🔖" new_commit_msg = f"{icon} Bump version: {current_version} → {new_version}" logger.debug(f"New commit message: {new_commit_msg}") return new_commit_msg @@ -272,7 +269,6 @@ def main() -> None: commit_type = type_match.group("type") logger.debug(f"Detected commit type: {commit_type}") else: - commit_type = "chore" # Default to 'chore' if no type is found logger.debug("No commit type detected. Defaulting to 'chore'.") version_bump_part = determine_version_bump(latest_commit_msg) @@ -286,9 +282,7 @@ def main() -> None: new_version = get_new_version() - updated_commit_msg = add_icon_and_prepare_commit_message( - commit_type, current_version, new_version - ) + updated_commit_msg = add_icon_and_prepare_commit_message(current_version, new_version) # Stage the updated pyproject.toml stage_changes() @@ -313,6 +307,7 @@ def determine_version_bump(commit_msg: str) -> Optional[str]: Returns: Optional[str]: The version part to bump ('major', 'minor', 'patch') or None. """ + logger.debug(f"Detected commit message: {commit_msg}") match = VERSION_KEYWORD_REGEX.search(commit_msg) if match: keyword = match.group("keyword").lower() diff --git a/control_commit/main.py b/control_commit/main.py index 42e17e0..5fa0e9a 100644 --- a/control_commit/main.py +++ b/control_commit/main.py @@ -227,7 +227,10 @@ def main() -> None: logger.debug(f"Commit message already has icon '{icon}'.") break - if icon_present: + if commit_msg.__contains__("Bump version:"): + logger.debug("Commit message with icon is valid.") + sys.exit(0) # Valid commit message with icon; proceed + elif icon_present: # Validate the commit message without the icon if not validate_commit_message(commit_msg_without_icon): logger.error("Commit message validation failed after removing icon. Aborting commit.") diff --git a/pyproject.toml b/pyproject.toml index 196513a..692028d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "scripts" -version = "1.1.2" +version = "1.1.6" description = "CICD Core Scripts" authors = ["B <g46327wsj1.marbling129@passinbox.com>"] license = "Apache 2.0"