blob: 32b13e81a1edcff4c2d0aeb136ee6646a34ff1fe [file] [log] [blame]
Peter Pentchevb91fc932023-01-19 15:27:13 +02001# SPDX-FileCopyrightText: StorPool <support@storpool.com>
2# SPDX-License-Identifier: BSD-2-Clause
3"""Common definitions for the gifn-apply routines."""
4
5from __future__ import annotations
6
7import dataclasses
8
9from typing import TYPE_CHECKING
10
11if TYPE_CHECKING:
12 import logging
13 import pathlib
14 import urllib.parse as uparse
15
16
17VERSION = "0.1.0"
18
19
20class GApplyError(Exception):
21 """The base class for errors that occurred during the gifn-apply operation."""
22
23
24@dataclasses.dataclass(frozen=True, order=True)
25class Repo:
26 """A repository split into the origin fragment and the name/path within."""
27
28 origin: str
29 repo: str
30
31 @property
32 def path(self) -> str:
33 """Combine the origin and the repo path."""
34 return f"{self.origin}/{self.repo}"
35
36
37@dataclasses.dataclass(frozen=True)
38class RepoURL:
39 """A parsed URL for a repo base."""
40
41 url: uparse.ParseResult
42
43
44@dataclasses.dataclass(frozen=True)
45class Config:
46 """Runtime configuration for the gifn-apply tool."""
47
48 log: logging.Logger
49 program: pathlib.Path
50 patches: pathlib.Path
51 series: pathlib.Path
52 repo_urls: dict[str, RepoURL]