-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathscm.py
More file actions
62 lines (43 loc) · 1.75 KB
/
Copy pathscm.py
File metadata and controls
62 lines (43 loc) · 1.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
"""Version control data plugin definitions"""
from abc import abstractmethod
from typing import Annotated, Protocol, runtime_checkable
from pydantic import DirectoryPath, Field
from cppython.core.schema import Plugin, PluginGroupData, SupportedFeatures
class SCMPluginGroupData(PluginGroupData):
"""SCM plugin input data"""
class SupportedSCMFeatures(SupportedFeatures):
"""SCM plugin feature support"""
repository: Annotated[
bool, Field(description='True if the directory is a repository for the SCM. False, otherwise')
]
@runtime_checkable
class SCM(Plugin, Protocol):
"""Base class for version control systems"""
@abstractmethod
def __init__(self, group_data: SCMPluginGroupData) -> None:
"""Initializes the SCM plugin"""
raise NotImplementedError
@staticmethod
@abstractmethod
def features(directory: DirectoryPath) -> SupportedFeatures:
"""Broadcasts the shared features of the SCM plugin to CPPython
Args:
directory: The root directory where features are evaluated
Returns:
The supported features - `SupportedSCMFeatures`. Cast to this type to help us avoid generic typing
"""
raise NotImplementedError
@abstractmethod
def version(self, directory: DirectoryPath) -> str:
"""Extracts the system's version metadata
Args:
directory: The input directory
Returns:
A version string
"""
raise NotImplementedError
def description(self) -> str | None:
"""Requests extraction of the project description
Returns:
Returns the project description, or none if unavailable
"""