feat(F-048): completed feature
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import sys
|
||||
from datetime import date
|
||||
from pathlib import Path
|
||||
|
||||
@@ -36,8 +37,55 @@ def next_id(features):
|
||||
return f"F-{(max(nums) + 1) if nums else 1:03d}"
|
||||
|
||||
|
||||
def normalize_deprecated_gates(data):
|
||||
"""Replace the legacy `review` gate key without changing feature state."""
|
||||
changed = 0
|
||||
for feature in data.get('features', []):
|
||||
gates = feature.get('gates')
|
||||
if not isinstance(gates, dict) or 'review' not in gates:
|
||||
continue
|
||||
gates.setdefault('reviewer', gates['review'])
|
||||
del gates['review']
|
||||
changed += 1
|
||||
return changed
|
||||
|
||||
|
||||
def start_feature(data, feature_id):
|
||||
"""Promote one pending feature to in_progress while enforcing exclusivity."""
|
||||
active = [
|
||||
feature.get('id')
|
||||
for feature in data.get('features', [])
|
||||
if feature.get('status') == 'in_progress' and feature.get('id') != feature_id
|
||||
]
|
||||
if active:
|
||||
raise SystemExit(f"Cannot start {feature_id}; already in progress: {', '.join(active)}")
|
||||
for feature in data.get('features', []):
|
||||
if feature.get('id') != feature_id:
|
||||
continue
|
||||
if feature.get('status') not in {'pending', 'in_progress'}:
|
||||
raise SystemExit(f"Cannot start {feature_id} from status {feature.get('status')}")
|
||||
feature['status'] = 'in_progress'
|
||||
return
|
||||
raise SystemExit(f'Feature not found: {feature_id}')
|
||||
|
||||
|
||||
def main():
|
||||
data = json.loads(BACKLOG.read_text(encoding='utf-8'))
|
||||
if '--normalize-gates' in sys.argv[1:]:
|
||||
changed = normalize_deprecated_gates(data)
|
||||
BACKLOG.write_text(json.dumps(data, indent=2, ensure_ascii=False) + '\n', encoding='utf-8')
|
||||
print(f'Normalized deprecated gates in {changed} feature(s)')
|
||||
return
|
||||
if '--start' in sys.argv[1:]:
|
||||
index = sys.argv.index('--start')
|
||||
if index + 1 >= len(sys.argv):
|
||||
raise SystemExit('Usage: new_ticket.py --start <feature_id>')
|
||||
feature_id = sys.argv[index + 1]
|
||||
start_feature(data, feature_id)
|
||||
BACKLOG.write_text(json.dumps(data, indent=2, ensure_ascii=False) + '\n', encoding='utf-8')
|
||||
print(f'Started {feature_id}')
|
||||
return
|
||||
|
||||
features = data.get('features', [])
|
||||
|
||||
print('Create ticket (English caveman style).')
|
||||
@@ -88,7 +136,7 @@ def main():
|
||||
'acceptance': acceptance,
|
||||
'status': 'pending',
|
||||
'created_at': str(date.today()),
|
||||
'gates': {'review': False, 'security': False, 'qa': False},
|
||||
'gates': {'reviewer': False, 'security': False, 'qa': False},
|
||||
})
|
||||
|
||||
data['features'] = features
|
||||
|
||||
Reference in New Issue
Block a user