Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add GitLab support with API-compatible utility functions. #383

Merged
merged 48 commits into from
Oct 20, 2024

Conversation

github-actions[bot]
Copy link
Contributor

@github-actions github-actions bot commented Oct 19, 2024

This message was generated by git-bob (version: 0.9.2, model: gpt-4o-2024-08-06, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

Implementing GitLab support by creating an API-compatible utility in the form of src/git_bob/_gitlab_utilities.py, leveraging the python-gitlab library to perform tasks similar to those available in the GitHub utilities.

closes #382
closes #378

@haesleinhuepf
Copy link
Owner

git-bob implement the following: There are functions in _github_utilities.py which áre missing yet in _gitlab_utilities.py . Add them;

  • get_github_issue_details
  • list_repository_files
  • get_repository_file_contents
  • write_file_in_branch
  • create_branch

…ns: get_gitlab_issue_details, list_repository_files, get_repository_file_contents, write_file_in_branch, and create_branch.
Copy link
Contributor Author

This message was generated by git-bob (version: 0.9.2, model: gpt-4o-2024-08-06, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

In the recent commit, a new file was created: _gitlab_utilities.py within the src/git_bob/ directory. This file introduces several GitLab-compatible utility functions that serve purposes analogous to those available for GitHub. The functions added are: get_gitlab_issue_details, list_repository_files, get_repository_file_contents, write_file_in_branch, and create_branch. These functions enhance the utility's compatibility by providing similar capabilities for GitLab as existing ones for GitHub.

During solving this task, the following errors occurred:

  • Error during {'action': 'modify', 'filename': 'src/git_bob/_gitlab_utilities.py'}: 409 {"message": "src/git_bob/_gitlab_utilities.py does not match 940c800dd8b1a632588f17c0fc2a975deba11ea1", "documentation_url": "https://docs.github.com/rest/repos/contents#create-or-update-file-contents", "status": "409"}
        Traceback (most recent call last):
        File "/home/runner/work/git-bob/git-bob/src/git_bob/_ai_github_utilities.py", line 476, in solve_github_issue
          message = filename + ":" + create_or_modify_file(repository, issue, filename, branch_name, discussion,
                                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/home/runner/work/git-bob/git-bob/src/git_bob/_ai_github_utilities.py", line 373, in create_or_modify_file
          write_file_in_branch(repository, branch_name, filename, new_content + "\n", redact_text(commit_message))
        File "/home/runner/work/git-bob/git-bob/src/git_bob/_github_utilities.py", line 355, in write_file_in_branch
          repo.update_file(file.path, commit_message, new_content, file.sha, branch=branch_name)
        File "/opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/github/Repository.py", line 2541, in update_file
          headers, data = self._requester.requestJsonAndCheck(
                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/github/Requester.py", line 550, in requestJsonAndCheck
          return self.__check(*self.requestJson(verb, url, parameters, headers, input, self.__customConnection(url)))
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        File "/opt/hostedtoolcache/Python/3.12.7/x64/lib/python3.12/site-packages/github/Requester.py", line 611, in __check
          raise self.createException(status, responseHeaders, data)
      github.GithubException.GithubException: 409 {"message": "src/git_bob/_gitlab_utilities.py does not match 940c800dd8b1a632588f17c0fc2a975deba11ea1", "documentation_url": "https://docs.github.com/rest/repos/contents#create-or-update-file-contents", "status": "409"}
      

@haesleinhuepf
Copy link
Owner

git-bob implement the following: There are functions in _github_utilities.py which áre missing yet in _gitlab_utilities.py . Add them;

  • check_if_file_exists
  • get_file_in_repository
  • send_pull_request
  • check_access_and_ask_for_approval
  • get_contributors

…end_pull_request`, `check_access_and_ask_for_approval`, and `get_contributors` for GitLab support.
Copy link
Contributor Author

This message was generated by git-bob (version: 0.9.2, model: gpt-4o-2024-08-06, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

In the recent commit to the repository, a new file, src/git_bob/_gitlab_utilities.py, was created to introduce GitLab support. This update includes the addition of several functions: check_if_file_exists, get_file_in_repository, send_pull_request, check_access_and_ask_for_approval, and get_contributors. These functions aim to enhance the repository's capabilities by providing essential utilities for interacting with GitLab repositories. No image files were created or modified in these changes.

@haesleinhuepf
Copy link
Owner

git-bob implement the following: There are functions in _github_utilities.py which áre missing yet in _gitlab_utilities.py . Add them;

  • get_diff_of_pull_request
  • add_reaction_to_issue
  • add_reaction_to_last_comment_in_issue
  • get_diff_of_branches
  • rename_file_in_repository
  • delete_file_from_repository
  • copy_file_in_repository
  • download_to_repository
  • create_issue

…s, managing files, and creating issues for GitLab integration.
Copy link
Contributor Author

This message was generated by git-bob (version: 0.9.2, model: gpt-4o-2024-08-06, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

In the recent commit, a new file named _gitlab_utilities.py was introduced in the src/git_bob/ directory. This file includes functions designed to facilitate various operations related to GitLab integration, such as retrieving diffs, adding reactions, managing files, and creating issues.

@haesleinhuepf
Copy link
Owner

The function get_issue_details in _github_utilities.py does a lot more than in _gitlab_utilities.py. git-bob implement the function in _gitlab_utilities.py in a way that it produces the same output like int _github_utilities.py .

Copy link
Contributor Author

This message was generated by git-bob (version: 0.9.2, model: gpt-4o-2024-08-06, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

In the recent changes, the get_issue_details function in src/git_bob/_gitlab_utilities.py was updated to include label and assignee output, aligning its functionality closer to that of GitHub. Additionally, the parameter types in the test_get_repository_file_contents and test_check_if_file_exists function calls within tests/test_github_utilities.py were corrected to ensure accurate testing. New files were created: src/git_bob/_gitlab_utilities.py and tests/test_github_utilities.py.

@haesleinhuepf
Copy link
Owner

git-bob review this

Copy link
Contributor Author

This message was generated by git-bob (version: 0.9.2, model: gpt-4o-2024-08-06, log), an experimental AI-based assistant. It can make mistakes and has limitations. Check its messages carefully.

The recent changes in this pull request accurately reflect the discussion and comments on the addition of GitLab support. The file _gitlab_utilities.py in the src/git_bob/ directory now includes the specified functions: get_gitlab_issue_details, list_repository_files, get_repository_file_contents, write_file_in_branch, create_branch, check_if_file_exists, get_file_in_repository, send_pull_request, check_access_and_ask_for_approval, get_contributors, get_diff_of_pull_request, add_reaction_to_issue, add_reaction_to_last_comment_in_issue, get_diff_of_branches, rename_file_in_repository, delete_file_from_repository, copy_file_in_repository, download_to_repository, and create_issue. This is consistent with the comments and tasks mentioned in the discussion.

Additionally, tests have been added for the _gitlab_utilities.py functions in tests/test_gitlab_utilities.py, ensuring coverage and functionality of the new GitLab utilities.

Considering the implementation and transition details in this pull request, it successfully addresses the issue and provides the necessary GitLab function counterparts in a coherent manner. The adjustments in requirements.txt to include the python-gitlab library and updates to the GitHub workflows to incorporate GITLAB_API_KEY further ensure appropriate configuration for these utilities. Overall, the implementation aligns well with the project requirements as discussed.

@haesleinhuepf haesleinhuepf merged commit 5afc988 into main Oct 20, 2024
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Gitlab support Also support Gitlab / Gitlab CI
1 participant