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
10 changes: 4 additions & 6 deletions create-jira-version/create_jira_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import argparse
import os
import re
import sys

sys.path.insert(0, os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'shared'))
Expand All @@ -18,12 +17,11 @@
def normalize_version_name(version_name):
"""
Normalizes a version name by removing .0 patch suffix.
For example: 1.2.0 -> 1.2, but 1.2.4 stays as 1.2.4
For example: 1.2.0 -> 1.2, but 1.2.4 stays as 1.2.4 and 12.0 stays as 12.0
"""
# Match versions ending in .0 (e.g., 1.2.0, 10.20.0)
match = re.match(r'^(.+)\.0$', version_name)
if match:
return match.group(1)
parts = version_name.split('.')
if len(parts) > 2 and parts[-1] == '0':
return '.'.join(parts[:-1])
return version_name
Comment thread
gitar-bot[bot] marked this conversation as resolved.
Resolved


Expand Down
2 changes: 2 additions & 0 deletions create-jira-version/test_create_jira_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ def test_keeps_non_zero_patch(self):
def test_handles_two_part_versions(self):
"""Test that two-part versions are unchanged."""
self.assertEqual(normalize_version_name('1.2'), '1.2')
self.assertEqual(normalize_version_name('12.0'), '12.0')
self.assertEqual(normalize_version_name('v12.0'), 'v12.0')

def test_handles_single_zero(self):
"""Test edge case with just 0."""
Expand Down
2 changes: 1 addition & 1 deletion get-jira-version/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ runs:
VERSION=$(echo "$RELEASE_VERSION" | cut -d '+' -f 1 | cut -d '.' -f 1-3)

# Remove trailing '.0' if it exists (to match Jira version format)
JIRA_VERSION_NAME=$(echo "$VERSION" | sed 's/\.0$//')
JIRA_VERSION_NAME=$(echo "$VERSION" | sed -E 's/^([^.]+\.[^.]+)\.0$/\1/')

echo "JIRA_VERSION_NAME: ${JIRA_VERSION_NAME}"
echo "JIRA_VERSION_NAME=${JIRA_VERSION_NAME}" >> "$GITHUB_ENV"
Expand Down
Loading