forked from Rockachopa/Timmy-time-dashboard
Audit cleanup: security fixes, code reduction, test hygiene (#131)
This commit is contained in:
committed by
GitHub
parent
e8f1dea3ec
commit
aff3edb06a
@@ -121,67 +121,5 @@ def down():
|
||||
subprocess.run(["docker", "compose", "down"], check=True)
|
||||
|
||||
|
||||
@app.command(name="ingest-report")
|
||||
def ingest_report(
|
||||
file: Optional[str] = typer.Argument(
|
||||
None, help="Path to JSON report file (reads stdin if omitted)",
|
||||
),
|
||||
dry_run: bool = typer.Option(
|
||||
False, "--dry-run", help="Validate report and show what would be created",
|
||||
),
|
||||
):
|
||||
"""Ingest a structured test report and create bug_report tasks.
|
||||
|
||||
Reads a JSON report with an array of bugs and creates one task per bug
|
||||
in the internal task queue. The task processor will then attempt to
|
||||
create GitHub Issues for each.
|
||||
|
||||
Examples:
|
||||
timmy ingest-report report.json
|
||||
timmy ingest-report --dry-run report.json
|
||||
cat report.json | timmy ingest-report
|
||||
"""
|
||||
import json
|
||||
import sys
|
||||
|
||||
# Read input
|
||||
if file:
|
||||
try:
|
||||
with open(file) as f:
|
||||
raw = f.read()
|
||||
except FileNotFoundError:
|
||||
typer.echo(f"File not found: {file}", err=True)
|
||||
raise typer.Exit(1)
|
||||
else:
|
||||
if sys.stdin.isatty():
|
||||
typer.echo("Reading from stdin (paste JSON, then Ctrl+D)...")
|
||||
raw = sys.stdin.read()
|
||||
|
||||
# Parse JSON
|
||||
try:
|
||||
data = json.loads(raw)
|
||||
except json.JSONDecodeError as exc:
|
||||
typer.echo(f"Invalid JSON: {exc}", err=True)
|
||||
raise typer.Exit(1)
|
||||
|
||||
reporter = data.get("reporter", "unknown")
|
||||
bugs = data.get("bugs", [])
|
||||
|
||||
if not bugs:
|
||||
typer.echo("No bugs in report.", err=True)
|
||||
raise typer.Exit(1)
|
||||
|
||||
typer.echo(f"Report: {len(bugs)} bug(s) from {reporter}")
|
||||
|
||||
if dry_run:
|
||||
for bug in bugs:
|
||||
typer.echo(f" [{bug.get('severity', '?')}] {bug.get('title', '(no title)')}")
|
||||
typer.echo("(dry run — no tasks created)")
|
||||
return
|
||||
|
||||
typer.echo("Task queue not available (swarm module removed).", err=True)
|
||||
raise typer.Exit(1)
|
||||
|
||||
|
||||
def main():
|
||||
app()
|
||||
|
||||
Reference in New Issue
Block a user