Register a new project in the registry. Args: name: The project name (unique identifier). path: The absolute path to the project directory. Raises: ValueError: If project name is invalid or path is not absolute. RegistryError: If a project with that nam
(name: str, path: Path)
| 258 | # ============================================================================= |
| 259 | |
| 260 | def register_project(name: str, path: Path) -> None: |
| 261 | """ |
| 262 | Register a new project in the registry. |
| 263 | |
| 264 | Args: |
| 265 | name: The project name (unique identifier). |
| 266 | path: The absolute path to the project directory. |
| 267 | |
| 268 | Raises: |
| 269 | ValueError: If project name is invalid or path is not absolute. |
| 270 | RegistryError: If a project with that name already exists. |
| 271 | """ |
| 272 | # Validate name |
| 273 | if not re.match(r'^[a-zA-Z0-9_-]{1,50}$', name): |
| 274 | raise ValueError( |
| 275 | "Invalid project name. Use only letters, numbers, hyphens, " |
| 276 | "and underscores (1-50 chars)." |
| 277 | ) |
| 278 | |
| 279 | # Ensure path is absolute |
| 280 | path = Path(path).resolve() |
| 281 | |
| 282 | with _get_session() as session: |
| 283 | existing = session.query(Project).filter(Project.name == name).first() |
| 284 | if existing: |
| 285 | logger.warning("Attempted to register duplicate project: %s", name) |
| 286 | raise RegistryError(f"Project '{name}' already exists in registry") |
| 287 | |
| 288 | project = Project( |
| 289 | name=name, |
| 290 | path=path.as_posix(), |
| 291 | created_at=datetime.now() |
| 292 | ) |
| 293 | session.add(project) |
| 294 | |
| 295 | logger.info("Registered project '%s' at path: %s", name, path) |
| 296 | |
| 297 | |
| 298 | def unregister_project(name: str) -> bool: |
no test coverage detected