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:
2026-01-06 17:27:55 +01:00
parent 587d2f5889
commit 0d276e8589
3 changed files with 25 additions and 16 deletions

View File

@@ -113,8 +113,10 @@ def validate(ctx):
@main.command()
@click.option('--version', required=True, help='Version to tag (e.g., 0.8.0)')
@click.option('--message', help='Tag message')
@click.option('--push/--no-push', default=True,
help='Automatically push tag to origin (default: --push)')
@click.pass_context
def tag(ctx, version: str, message: Optional[str]):
def tag(ctx, version: str, message: Optional[str], push: bool):
"""Create git tag for version."""
manager = ReleaseManager(
project_root=ctx.obj['project_root'],
@@ -122,8 +124,10 @@ def tag(ctx, version: str, message: Optional[str]):
force=ctx.obj['force']
)
if manager.create_tag(version, message):
if manager.create_tag(version, message, push=push):
print(f"✅ Successfully created tag for version {version}")
if not push:
print(f"💡 Push tag with: git push origin v{version}")
else:
print(f"❌ Failed to create tag for version {version}")
sys.exit(1)