This pull request refactors the sweepai/utils/github_utils.py file to improve readability and maintainability. It includes the following changes:
Added import statements for external libraries gitlab and git.
Added a new function get_gitlab_token to retrieve a GitLab access token using client credentials.
Modified the get_gitlab_client function to use the gitlab_client variable instead of gitlab_instance.
Modified the get_project_id_from_gitlab function to use the gitlab_client variable instead of gitlab_instance.
Added exception handling for errors when accessing the GitLab project in the __post_init__ method.
Added exception handling for errors when checking out a branch in the get_num_files_from_repo method.
Summary
Added import statements for gitlab and git libraries.
Added get_gitlab_token function to retrieve GitLab access token.
Modified get_gitlab_client function to use gitlab_client variable.
Modified get_project_id_from_gitlab function to use gitlab_client variable.
Added exception handling for GitLab project access errors in __post_init__ method.
Added exception handling for branch checkout errors in get_num_files_from_repo method.
Fixes #48.
🎉 Latest improvements to Sweep:
We just released a dashboard to track Sweep's progress on your issue in real-time, showing every stage of the process – from search to planning and coding.
Sweep uses OpenAI's latest Assistant API to plan code changes and modify code! This is 3x faster and significantly more reliable as it allows Sweep to edit code and validate the changes in tight iterations, the same way as a human would.
[ ] Apply: We should use loguru for error logging. If the log is inside an exception, use logger.exception to add tracebacks, where logger is imported from loguru. Use f-strings for string formatting in logger calls.
[ ] Apply: There should be no debug log or print statements in production code.
[ ] Apply: All functions should have parameters and output annotated with type hints. Use list, tuple and dict instead of typing.List, typing.Tuple and typing.dict.
[ ] Apply: Leftover TODOs in the code should be handled.
[ ] Apply: All new business logic should have corresponding unit tests in the same directory. For example, sweepai/api_test.py tests sweepai/api.py. Use unittest and unittest.mock as required.
[ ] Apply: Any clearly inefficient or repeated code should be optimized or refactored.
[ ] Apply: Remove any comments before code that are obvious. For example # this prints hello world; print('hello world').
PR Feedback (click)
Description
This pull request refactors the
sweepai/utils/github_utils.py
file to improve readability and maintainability. It includes the following changes:gitlab
andgit
.get_gitlab_token
to retrieve a GitLab access token using client credentials.get_gitlab_client
function to use thegitlab_client
variable instead ofgitlab_instance
.get_project_id_from_gitlab
function to use thegitlab_client
variable instead ofgitlab_instance
.__post_init__
method.get_num_files_from_repo
method.Summary
gitlab
andgit
libraries.get_gitlab_token
function to retrieve GitLab access token.get_gitlab_client
function to usegitlab_client
variable.get_project_id_from_gitlab
function to usegitlab_client
variable.__post_init__
method.get_num_files_from_repo
method.Fixes #48.
🎉 Latest improvements to Sweep:
💡 To get Sweep to edit this pull request, you can: