-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathplugin.py
More file actions
61 lines (46 loc) · 1.59 KB
/
plugin.py
File metadata and controls
61 lines (46 loc) · 1.59 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
"""Git SCM Plugin"""
from pathlib import Path
from dulwich.errors import NotGitRepository
from dulwich.repo import Repo
from cppython.core.plugin_schema.scm import (
SCM,
SCMPluginGroupData,
SupportedSCMFeatures,
)
from cppython.core.schema import Information, SupportedFeatures
class GitSCM(SCM):
"""Git implementation hooks"""
def __init__(self, group_data: SCMPluginGroupData) -> None:
"""Initializes the plugin"""
self.group_data = group_data
@staticmethod
def features(directory: Path) -> 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
"""
is_repository = True
try:
Repo(str(directory))
except NotGitRepository:
is_repository = False
return SupportedSCMFeatures(repository=is_repository)
@staticmethod
def information() -> Information:
"""Extracts the system's version metadata
Returns:
A version
"""
return Information()
def version(self, directory: Path) -> str:
"""Extracts the system's version metadata
Returns:
The git version
"""
return ''
@staticmethod
def description() -> str | None:
"""Requests extraction of the project description"""
return None