chore: categorize empty repo error [CM-1103]#4017
Conversation
Signed-off-by: Mouad BANI <mouad-mb@outlook.com>
|
|
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
1 similar comment
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
|
Your PR title doesn't contain a Jira issue key. Consider adding it for better traceability. Example:
Projects:
Please add a Jira issue key to your PR title. |
There was a problem hiding this comment.
Pull request overview
Adds a dedicated error classification for empty Git repositories to the git integration service so “ambiguous HEAD” failures can be surfaced with a specific error code.
Changes:
- Added
EMPTY_REPOtoErrorCode. - Introduced
EmptyRepoErroras a newCrowdGitErrortype. - Classified ambiguous
HEADstderr output to raiseEmptyRepoErrorin shell error handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| services/apps/git_integration/src/crowdgit/services/utils.py | Maps ambiguous HEAD stderr to the new EmptyRepoError. |
| services/apps/git_integration/src/crowdgit/errors.py | Adds EmptyRepoError dataclass with standardized message/code. |
| services/apps/git_integration/src/crowdgit/enums.py | Extends ErrorCode with EMPTY_REPO. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| ( | ||
| {"ambiguous argument 'HEAD': unknown revision or path not in the working tree"}, | ||
| EmptyRepoError, | ||
| ), |
This pull request adds support for handling empty repositories in the git integration service. The main changes introduce a new error type for empty repositories, update the error code enumeration, and ensure that ambiguous
HEADerrors are mapped to this new error. The most important changes are:Error handling improvements:
EMPTY_REPOto theErrorCodeenum inenums.py, representing the case when a repository is empty (no branches or commits).EmptyRepoErrordataclass inerrors.pyto encapsulate the error message and code for empty repositories.utils.pyso that ambiguousHEADerrors (which indicate an empty repository) now raiseEmptyRepoError.EmptyRepoErrorto the list of imported errors inutils.pyto enable its use in error handling logic.Note
Low Risk
Low risk: adds a new error code/exception and maps a specific git stderr pattern to it, only affecting how empty-repo failures are classified and reported.
Overview
Adds first-class classification for empty repositories in the git integration service.
Introduces
ErrorCode.EMPTY_REPOand a correspondingEmptyRepoError, and updates shell error classification so git failures containingambiguous argument 'HEAD'are surfaced asEmptyRepoErrorinstead of a generic command failure.Reviewed by Cursor Bugbot for commit 31f55dc. Bugbot is set up for automated code reviews on this repo. Configure here.