Refactor update_package with comprehensive error handling and integrate update scripts.
Add custom exception hierarchy (PackageUpdateError, PackageNotFoundError,
RepositoryStateError, ExternalCommandError, MissingToolError) for specific
error handling throughout package update operations.
Extract helper functions from 90-line update_package function:
- validate_package_info: Package validation
- resolve_package_directories: Path resolution
- ensure_package_checkout: Salsa checkout with error handling
- validate_repository_state: Check for uncommitted changes
- run_gbp_pq_workflow: Run gbp pq import/switch with error checks
- import_upstream_version: Import upstream using gbp
- run_command: Centralized subprocess execution with consistent errors
- check_required_tools: Validate required tools upfront
Incorporate update scripts as Python functions (replaces external shell scripts):
- update_debian_control: Update Standards-Version, remove obsolete fields
- update_debian_copyright_year: Update copyright years to current
- update_debian_watch: Upgrade watch files from version 4 to 5
- add_salsa_ci: Add debian/salsa-ci.yml if missing
- run_package_updates: Orchestrator for all update operations
Enhance network error handling in fetch_todo_list:
- Handle HTTP errors, network errors, timeouts, invalid JSON
- Add timeout parameter (default 30s)
- Graceful error messages in list_todos and update_todos
Add comprehensive test coverage:
- 67 tests for update-pkg functionality
- Tests for all helper functions and update operations
- Network error handling tests
- 125 total tests, all passing
Benefits:
- No external script dependencies
- Consistent error handling throughout
- Better error messages with actionable guidance
- All update logic in one maintainable codebase
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>