fix tag
This commit is contained in:
parent
32379dcc50
commit
ff8b84e462
@ -1475,6 +1475,73 @@ class GitSvnSyncApp:
|
|||||||
context_dict={"context": "refresh_tags", "status_msg": "Refreshing tags"},
|
context_dict={"context": "refresh_tags", "status_msg": "Refreshing tags"},
|
||||||
)
|
)
|
||||||
# ... e tutti gli altri metodi launcher invariati...
|
# ... e tutti gli altri metodi launcher invariati...
|
||||||
|
|
||||||
|
def _generate_next_tag_suggestion(self, svn_path: str) -> str:
|
||||||
|
"""
|
||||||
|
Analyzes existing tags and suggests the next logical tag name based on
|
||||||
|
a 'v.X.X.X.X' pattern. Increments the last number.
|
||||||
|
"""
|
||||||
|
func_name: str = "_generate_next_tag_suggestion"
|
||||||
|
log_handler.log_debug("Generating next tag suggestion...", func_name=func_name)
|
||||||
|
|
||||||
|
# Default suggestion if no matching tags are found
|
||||||
|
default_suggestion: str = "v.0.0.0.1"
|
||||||
|
|
||||||
|
# Regex to find tags matching the specific version pattern
|
||||||
|
tag_pattern = re.compile(r"^v\.(\d+)\.(\d+)\.(\d+)\.(\d+)$")
|
||||||
|
|
||||||
|
try:
|
||||||
|
# Get all tags sorted by creation date (newest first)
|
||||||
|
tags_data: list[tuple[str, str]] = self.git_commands.list_tags(svn_path)
|
||||||
|
|
||||||
|
if not tags_data:
|
||||||
|
log_handler.log_debug("No existing tags found. Suggesting default.", func_name=func_name)
|
||||||
|
return default_suggestion
|
||||||
|
|
||||||
|
# Find the latest tag that matches the pattern
|
||||||
|
latest_valid_tag: Optional[str] = None
|
||||||
|
for tag_name, _ in tags_data:
|
||||||
|
match = tag_pattern.match(tag_name)
|
||||||
|
if match:
|
||||||
|
latest_valid_tag = tag_name
|
||||||
|
log_handler.log_debug(
|
||||||
|
f"Found latest tag matching pattern: {latest_valid_tag}",
|
||||||
|
func_name=func_name,
|
||||||
|
)
|
||||||
|
break # Stop at the first (newest) match
|
||||||
|
|
||||||
|
if not latest_valid_tag:
|
||||||
|
log_handler.log_debug("No tags matched the pattern. Suggesting default.", func_name=func_name)
|
||||||
|
return default_suggestion
|
||||||
|
|
||||||
|
# Increment the version number
|
||||||
|
match = tag_pattern.match(latest_valid_tag)
|
||||||
|
if not match:
|
||||||
|
# This should be unreachable if latest_valid_tag was set, but for safety:
|
||||||
|
log_handler.log_error(f"Internal error: Could not re-match tag {latest_valid_tag}", func_name=func_name)
|
||||||
|
return default_suggestion
|
||||||
|
|
||||||
|
v1, v2, v3, v4 = map(int, match.groups())
|
||||||
|
|
||||||
|
limit: int = 99 # Your versioning limit
|
||||||
|
v4 += 1
|
||||||
|
if v4 > limit:
|
||||||
|
v4 = 0
|
||||||
|
v3 += 1
|
||||||
|
if v3 > limit:
|
||||||
|
v3 = 0
|
||||||
|
v2 += 1
|
||||||
|
if v2 > limit:
|
||||||
|
v2 = 0
|
||||||
|
v1 += 1
|
||||||
|
|
||||||
|
next_tag: str = f"v.{v1}.{v2}.{v3}.{v4}"
|
||||||
|
log_handler.log_debug(f"Generated suggestion: {next_tag}", func_name=func_name)
|
||||||
|
return next_tag
|
||||||
|
|
||||||
|
except Exception as e:
|
||||||
|
log_handler.log_exception(f"Error generating tag suggestion: {e}", func_name=func_name)
|
||||||
|
return default_suggestion
|
||||||
|
|
||||||
# --- NUOVI METODI PER LA PULIZIA DELLA STORIA ---
|
# --- NUOVI METODI PER LA PULIZIA DELLA STORIA ---
|
||||||
def analyze_and_clean_history(self):
|
def analyze_and_clean_history(self):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user