Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔖 From test → Bump version: v1.1.6-test into prod #34

Merged
merged 6 commits into from
Oct 27, 2024
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
2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = 1.1.2
current_version = 1.1.6
commit = True
tag = False

Expand Down
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 4 additions & 9 deletions commit_msg_version_bump/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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()
Expand All @@ -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()
Expand Down
5 changes: 4 additions & 1 deletion control_commit/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -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"
Expand Down
Loading