|
1 | 1 | import re
|
2 | 2 | from types import TracebackType
|
| 3 | +from enum import Enum |
3 | 4 |
|
4 | 5 | from galaxy.core.galaxy import Integration, register
|
5 | 6 | from galaxy.core.models import Config
|
|
20 | 21 | DEFAULT_BRANCH_NAME: str = "main"
|
21 | 22 |
|
22 | 23 |
|
| 24 | +class FileCheckStatus(Enum): |
| 25 | + FILE_FOUND = "FILE_FOUND" |
| 26 | + FILE_NOT_FOUND = "FILE_NOT_FOUND" |
| 27 | + FILE_FOUND_NO_MATCH = "FILE_FOUND_NO_MATCH" |
| 28 | + |
| 29 | + |
23 | 30 | class Gitlab(Integration):
|
24 | 31 | _methods = []
|
25 | 32 | # Default Group for previous members of the organization
|
@@ -117,10 +124,15 @@ async def get_repo_files(self, repo_full_path: str) -> dict:
|
117 | 124 | for file_check in self.repo_files_to_check:
|
118 | 125 | file = await self.client.get_file(repo_full_path, file_check["path"])
|
119 | 126 | if file:
|
120 |
| - result = re.search(file_check["regex"], file["content"]) if file_check["regex"] else None |
121 |
| - repo_file_checks[file_check["destination"]] = result |
| 127 | + if file_check["regex"]: |
| 128 | + result = re.search(file_check["regex"], file["content"]) if file_check["regex"] else None |
| 129 | + repo_file_checks[file_check["destination"]] = ( |
| 130 | + result.group(1) if result else FileCheckStatus.FILE_FOUND_NO_MATCH |
| 131 | + ) |
| 132 | + else: |
| 133 | + repo_file_checks[file_check["destination"]] = FileCheckStatus.FILE_FOUND |
122 | 134 | else:
|
123 |
| - repo_file_checks[file_check["destination"]] = False |
| 135 | + repo_file_checks[file_check["destination"]] = FileCheckStatus.FILE_NOT_FOUND |
124 | 136 |
|
125 | 137 | return repo_file_checks
|
126 | 138 |
|
|
0 commit comments