feat: implement optimization #2 - automated tag pushing control
Added --push/--no-push flag to release tag command for explicit control over tag pushing behavior. **Implementation**: - Added --push/--no-push flag to CLI tag command (default: --push) - Updated ReleaseManager.create_tag to accept push parameter - Updated GitManager.create_tag to conditionally push based on flag - Maintains backward compatibility (defaults to pushing) **Usage**: ```bash # Default behavior - creates and pushes tag release tag --version 0.11.0 # Explicit push (same as default) release tag --version 0.11.0 --push # Create tag but don't push (manual push later) release tag --version 0.11.0 --no-push ``` **Output when --no-push used**: ``` ✅ Tag v0.11.0 created 💡 Push tag with: git push origin v0.11.0 ``` **Benefits**: - Makes push behavior explicit and controllable - Prevents accidental pushes in some workflows - Defaults to safe behavior (automatic push) - Helpful reminder shown when --no-push used **Files Modified**: - capabilities/release-management/src/release_management/cli/main.py - capabilities/release-management/src/release_management/core/manager.py - capabilities/release-management/src/release_management/git/manager.py Optimizations completed: 2/9 (High Priority)
This commit is contained in:
@@ -62,12 +62,13 @@ class GitManager:
|
||||
except subprocess.CalledProcessError:
|
||||
return {'is_repo': False}
|
||||
|
||||
def create_tag(self, version: str, message: Optional[str] = None) -> bool:
|
||||
"""Create and push git tag.
|
||||
def create_tag(self, version: str, message: Optional[str] = None, push: bool = True) -> bool:
|
||||
"""Create and optionally push git tag.
|
||||
|
||||
Args:
|
||||
version: Version to tag (e.g., "1.0.0")
|
||||
message: Optional tag message
|
||||
push: Whether to push the tag to origin (default: True)
|
||||
|
||||
Returns:
|
||||
True if successful, False otherwise
|
||||
@@ -85,16 +86,19 @@ class GitManager:
|
||||
self._run_command(['git', 'tag', '-a', tag_name, '-m', tag_message])
|
||||
print(f"✅ Tag {tag_name} created")
|
||||
|
||||
# Push tag to origin
|
||||
try:
|
||||
print(f"📤 Pushing tag to origin...")
|
||||
self._run_command(['git', 'push', 'origin', tag_name])
|
||||
print(f"✅ Tag pushed to origin")
|
||||
return True
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"⚠️ Could not push tag to origin: {e}")
|
||||
print(f"You can push it manually with: git push origin {tag_name}")
|
||||
return True # Tag created successfully, push can be done manually
|
||||
# Push tag to origin if requested
|
||||
if push:
|
||||
try:
|
||||
print(f"📤 Pushing tag to origin...")
|
||||
self._run_command(['git', 'push', 'origin', tag_name])
|
||||
print(f"✅ Tag pushed to origin")
|
||||
return True
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"⚠️ Could not push tag to origin: {e}")
|
||||
print(f"You can push it manually with: git push origin {tag_name}")
|
||||
return True # Tag created successfully, push can be done manually
|
||||
else:
|
||||
return True # Tag created successfully, user chose not to push
|
||||
|
||||
except subprocess.CalledProcessError as e:
|
||||
print(f"❌ Failed to create tag: {e}")
|
||||
|
||||
Reference in New Issue
Block a user