Skip to content

Commit 0f0de60

Browse files
authored
chore: categorize empty repo error [CM-1103] (#4017)
Signed-off-by: Mouad BANI <[email protected]>
1 parent cc7266a commit 0f0de60

3 files changed

Lines changed: 12 additions & 0 deletions

File tree

services/apps/git_integration/src/crowdgit/enums.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ class ErrorCode(str, Enum):
2626
RATE_LIMITED = "rate-limited"
2727
ACCESS_FORBIDDEN = "access-forbidden"
2828
SERVER_ERROR = "server-error-remote"
29+
EMPTY_REPO = "empty-repo"
2930

3031

3132
class RepositoryState(str, Enum):

services/apps/git_integration/src/crowdgit/errors.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,3 +144,9 @@ class ForbiddenError(CrowdGitError):
144144
class RemoteServerError(CrowdGitError):
145145
error_message: str = "Remote server returned an internal error"
146146
error_code: ErrorCode = ErrorCode.SERVER_ERROR
147+
148+
149+
@dataclass
150+
class EmptyRepoError(CrowdGitError):
151+
error_message: str = "Repository is empty (no branches or commits)"
152+
error_code: ErrorCode = ErrorCode.EMPTY_REPO

services/apps/git_integration/src/crowdgit/services/utils.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
CommandExecutionError,
77
CommandTimeoutError,
88
DiskSpaceError,
9+
EmptyRepoError,
910
ForbiddenError,
1011
NetworkError,
1112
PermissionError,
@@ -183,6 +184,10 @@ async def get_default_branch(repo_path: str) -> str:
183184
},
184185
RepoAuthRequiredError,
185186
),
187+
(
188+
{"ambiguous argument 'HEAD': unknown revision or path not in the working tree"},
189+
EmptyRepoError,
190+
),
186191
]
187192

188193

0 commit comments

Comments
 (0)