forked from Rockachopa/Timmy-time-dashboard
Compare commits
1 Commits
main
...
kimi/issue
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
9acc0150f1 |
@@ -44,6 +44,8 @@ from __future__ import annotations
|
|||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
import json
|
import json
|
||||||
|
import re
|
||||||
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
from datetime import datetime, timezone
|
from datetime import datetime, timezone
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
@@ -97,6 +99,27 @@ def _epoch_tag(now: datetime | None = None) -> tuple[str, dict]:
|
|||||||
return tag, parts
|
return tag, parts
|
||||||
|
|
||||||
|
|
||||||
|
BRANCH_ISSUE_RE = re.compile(r"issue-(\d+)")
|
||||||
|
|
||||||
|
|
||||||
|
def _detect_issue_from_branch() -> int | None:
|
||||||
|
"""Try to extract an issue number from the current git branch name.
|
||||||
|
|
||||||
|
Matches branch patterns like ``kimi/issue-492`` or ``fix/issue-17``.
|
||||||
|
Returns ``None`` when not on a matching branch or git is unavailable.
|
||||||
|
"""
|
||||||
|
try:
|
||||||
|
branch = subprocess.check_output(
|
||||||
|
["git", "rev-parse", "--abbrev-ref", "HEAD"],
|
||||||
|
stderr=subprocess.DEVNULL,
|
||||||
|
text=True,
|
||||||
|
).strip()
|
||||||
|
except (subprocess.CalledProcessError, FileNotFoundError):
|
||||||
|
return None
|
||||||
|
m = BRANCH_ISSUE_RE.search(branch)
|
||||||
|
return int(m.group(1)) if m else None
|
||||||
|
|
||||||
|
|
||||||
def parse_args() -> argparse.Namespace:
|
def parse_args() -> argparse.Namespace:
|
||||||
p = argparse.ArgumentParser(description="Log a cycle retrospective")
|
p = argparse.ArgumentParser(description="Log a cycle retrospective")
|
||||||
p.add_argument("--cycle", type=int, required=True)
|
p.add_argument("--cycle", type=int, required=True)
|
||||||
@@ -230,6 +253,13 @@ def update_summary() -> None:
|
|||||||
def main() -> None:
|
def main() -> None:
|
||||||
args = parse_args()
|
args = parse_args()
|
||||||
|
|
||||||
|
# Auto-detect issue from branch name when not explicitly provided
|
||||||
|
if args.issue is None:
|
||||||
|
detected = _detect_issue_from_branch()
|
||||||
|
if detected is not None:
|
||||||
|
args.issue = detected
|
||||||
|
print(f"[retro] Auto-detected issue #{detected} from branch name")
|
||||||
|
|
||||||
# Reject idle cycles — no issue and no duration means nothing happened
|
# Reject idle cycles — no issue and no duration means nothing happened
|
||||||
if not args.issue and args.duration == 0:
|
if not args.issue and args.duration == 0:
|
||||||
print(f"[retro] Cycle {args.cycle} skipped — idle (no issue, no duration)")
|
print(f"[retro] Cycle {args.cycle} skipped — idle (no issue, no duration)")
|
||||||
|
|||||||
Reference in New Issue
Block a user