feat(models): add configuration and lock models for patch management
- Introduce models for managing upstream and patch configurations. - Add lock models to track the last processed upstream commit. - Enable structured data validation using Pydantic.
This commit is contained in:
16
src/patchman/models/config.py
Normal file
16
src/patchman/models/config.py
Normal file
@@ -0,0 +1,16 @@
|
||||
from typing import Optional
|
||||
from pydantic import BaseModel, Field, HttpUrl
|
||||
|
||||
|
||||
class UpstreamConfig(BaseModel):
|
||||
url: HttpUrl = Field(..., description="Git URL of the upstream repository")
|
||||
branch: str = Field(default="main", description="Upstream branch to track (default: 'main')")
|
||||
|
||||
|
||||
class PatchesConfig(BaseModel):
|
||||
directory: str = Field(default="./patches", description="Path to patch directory")
|
||||
|
||||
|
||||
class PatchmanConfig(BaseModel):
|
||||
upstream: UpstreamConfig
|
||||
patches: PatchesConfig
|
11
src/patchman/models/lock.py
Normal file
11
src/patchman/models/lock.py
Normal file
@@ -0,0 +1,11 @@
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Literal
|
||||
|
||||
|
||||
class UpstreamLock(BaseModel):
|
||||
last_commit: str = Field(..., min_length=40, max_length=40, pattern="^[0-9a-f]{40}$",
|
||||
description="Commit hash of the last processed upstream repository")
|
||||
|
||||
|
||||
class PatchmanLock(BaseModel):
|
||||
upstream: UpstreamLock
|
Reference in New Issue
Block a user