From c90fa6e39f2c457f3b1c05167e56385024f3ac5e Mon Sep 17 00:00:00 2001 From: "Max P." Date: Wed, 23 Jul 2025 13:33:45 +0200 Subject: [PATCH] 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. --- src/patchman/models/config.py | 16 ++++++++++++++++ src/patchman/models/lock.py | 11 +++++++++++ 2 files changed, 27 insertions(+) create mode 100644 src/patchman/models/config.py create mode 100644 src/patchman/models/lock.py diff --git a/src/patchman/models/config.py b/src/patchman/models/config.py new file mode 100644 index 0000000..7b85027 --- /dev/null +++ b/src/patchman/models/config.py @@ -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 diff --git a/src/patchman/models/lock.py b/src/patchman/models/lock.py new file mode 100644 index 0000000..b9d069d --- /dev/null +++ b/src/patchman/models/lock.py @@ -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