(
connection: sqlite3.Connection, args: argparse.Namespace
)
| 1356 | |
| 1357 | |
| 1358 | def begin_diff_resolution( |
| 1359 | connection: sqlite3.Connection, args: argparse.Namespace |
| 1360 | ) -> dict[str, Any]: |
| 1361 | workspace = require_workspace(connection, args.workspace_id) |
| 1362 | request_id = require_uuid(args.request_id, "request-id") |
| 1363 | if workspace["active_scan_id"]: |
| 1364 | raise SystemExit("Cannot resolve a new change set while this workspace has a scan.") |
| 1365 | target = require_target(args.target_path) |
| 1366 | require_review_changes_target(target) |
| 1367 | target_title = ( |
| 1368 | workspace["target_title"] if workspace["target_path"] == str(target) else target.name |
| 1369 | ) |
| 1370 | timestamp = now() |
| 1371 | with connection: |
| 1372 | updated = connection.execute( |
| 1373 | """ |
| 1374 | UPDATE workspaces |
| 1375 | SET target_path = ?, target_title = ?, target_summary = NULL, |
| 1376 | default_scope = '.', default_mode = 'diff', |
| 1377 | user_context = ?, diff_target_kind = NULL, diff_base_revision = NULL, |
| 1378 | diff_head_revision = NULL, diff_content_digest = NULL, |
| 1379 | diff_resolution_id = ?, submitted = 0, updated_at = ? |
| 1380 | WHERE id = ? AND active_scan_id IS NULL |
| 1381 | """, |
| 1382 | ( |
| 1383 | str(target), |
| 1384 | target_title, |
| 1385 | optional_text(args.user_context), |
| 1386 | request_id, |
| 1387 | timestamp, |
| 1388 | workspace["id"], |
| 1389 | ), |
| 1390 | ) |
| 1391 | if updated.rowcount != 1: |
| 1392 | raise SystemExit("Cannot resolve a new change set while this workspace has a scan.") |
| 1393 | return workspace_state(connection, workspace["id"]) |
| 1394 | |
| 1395 | |
| 1396 | def cancel_diff_resolution( |
no test coverage detected