(connection: sqlite3.Connection, args: argparse.Namespace)
| 1412 | |
| 1413 | |
| 1414 | def set_diff_target(connection: sqlite3.Connection, args: argparse.Namespace) -> dict[str, Any]: |
| 1415 | workspace = require_workspace(connection, args.workspace_id) |
| 1416 | request_id = require_uuid(args.request_id, "request-id") |
| 1417 | if workspace["active_scan_id"]: |
| 1418 | raise SystemExit("Cannot resolve a new change set while this workspace has a scan.") |
| 1419 | if workspace["diff_resolution_id"] != request_id: |
| 1420 | raise SystemExit("This change-resolution request is no longer active.") |
| 1421 | target = require_target(workspace["target_path"]) |
| 1422 | require_scannable_target(target) |
| 1423 | diff_target = require_diff_target( |
| 1424 | target, |
| 1425 | args.diff_target_kind, |
| 1426 | args.diff_base_revision, |
| 1427 | args.diff_head_revision, |
| 1428 | args.diff_content_digest, |
| 1429 | ) |
| 1430 | timestamp = now() |
| 1431 | with connection: |
| 1432 | updated = connection.execute( |
| 1433 | """ |
| 1434 | UPDATE workspaces |
| 1435 | SET target_summary = ?, default_scope = '.', default_mode = 'diff', |
| 1436 | diff_target_kind = ?, diff_base_revision = ?, diff_head_revision = ?, |
| 1437 | diff_content_digest = ?, diff_resolution_id = NULL, |
| 1438 | submitted = 0, updated_at = ? |
| 1439 | WHERE id = ? AND diff_resolution_id = ? AND active_scan_id IS NULL |
| 1440 | """, |
| 1441 | ( |
| 1442 | optional_text(args.target_summary, maximum=2400), |
| 1443 | diff_target["kind"], |
| 1444 | diff_target["baseRevision"], |
| 1445 | diff_target["headRevision"], |
| 1446 | diff_target.get("contentDigest"), |
| 1447 | timestamp, |
| 1448 | workspace["id"], |
| 1449 | request_id, |
| 1450 | ), |
| 1451 | ) |
| 1452 | if updated.rowcount != 1: |
| 1453 | raise SystemExit("This change-resolution request is no longer active.") |
| 1454 | return workspace_state(connection, workspace["id"]) |
| 1455 | |
| 1456 | |
| 1457 | def start_scan(connection: sqlite3.Connection, args: argparse.Namespace) -> dict[str, Any]: |
no test coverage detected