bartbot / sweep

Sweep: AI-powered Junior Developer for small features and bug fixes.
https://sweep.dev
GNU Affero General Public License v3.0
0 stars 0 forks source link

Sweep: Replace GitHub PR Creation with GitLab equivalent using python-gitlab library #78

Closed bartbot closed 5 months ago

bartbot commented 5 months ago

Details

Pull Requests Creation GitHub Integration:

GitHub's Pull Requests API allows for the creation and management of PRs. GitLab Equivalent:

In GitLab, Merge Requests (MRs) serve a similar purpose. You would use the Merge Requests API. Docs here: https://python-gitlab.readthedocs.io/en/stable/api/gitlab.v4.html#gitlab.v4.objects.MergeRequestManager

Example Replacement:

python Copy code

Example Python snippet to create a merge request in GitLab

def create_gitlab_mr(token, project_id, source_branch, target_branch, title): url = f"https://gitlab.com/api/v4/projects/{project_id}/merge_requests" headers = {"Authorization": f"Bearer {token}"} data = {"source_branch": source_branch, "target_branch": target_branch, "title": title} response = requests.post(url, headers=headers, data=data) if response.status_code == 201: print("Merge request created successfully.") else: print("Failed to create merge request.")

Branch

No response

Checklist - [X] Create `sweepai/utils/gitlab_utils.py` ✓ https://github.com/bartbot/sweep/commit/add54b3636c9fdb446900daf774ba1934860fd33 [Edit](https://github.com/bartbot/sweep/edit/sweep/replace_github_pr_creation_with_gitlab_e/sweepai/utils/gitlab_utils.py) - [X] Running GitHub Actions for `sweepai/utils/gitlab_utils.py` ✓ [Edit](https://github.com/bartbot/sweep/edit/sweep/replace_github_pr_creation_with_gitlab_e/sweepai/utils/gitlab_utils.py) - [X] Modify `sweepai/handlers/create_pr.py` ✓ https://github.com/bartbot/sweep/commit/d7889e339d63b42fe39aedf236efa23ea41a29df [Edit](https://github.com/bartbot/sweep/edit/sweep/replace_github_pr_creation_with_gitlab_e/sweepai/handlers/create_pr.py) - [X] Running GitHub Actions for `sweepai/handlers/create_pr.py` ✓ [Edit](https://github.com/bartbot/sweep/edit/sweep/replace_github_pr_creation_with_gitlab_e/sweepai/handlers/create_pr.py)
sweep-ai[bot] commented 5 months ago

🚀 Here's the PR! #82

See Sweep's progress at the progress dashboard!
💎 Sweep Pro: I'm using GPT-4. You have unlimited GPT-4 tickets. (tracking ID: 8d955b42b1)

[!TIP] I can email you next time I complete a pull request if you set up your email here!


Actions (click)


Step 1: 🔎 Searching

I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.

Some code snippets I think are relevant in decreasing order of relevance (click to expand). If some file is missing from here, you can mention the path in the ticket description. https://github.com/bartbot/sweep/blob/3ef84fdc933da6062c3840a1071f1b06368da3c4/sweepai/handlers/create_pr.py#L1-L457 https://github.com/bartbot/sweep/blob/3ef84fdc933da6062c3840a1071f1b06368da3c4/sweepai/handlers/on_merge_conflict.py#L1-L375 https://github.com/bartbot/sweep/blob/3ef84fdc933da6062c3840a1071f1b06368da3c4/sweepai/utils/github_utils.py#L1-L451 https://github.com/bartbot/sweep/blob/3ef84fdc933da6062c3840a1071f1b06368da3c4/sweepai/utils/github_utils.py#L1-L451

Step 2: ⌨️ Coding

Ran GitHub Actions for add54b3636c9fdb446900daf774ba1934860fd33:

--- 
+++ 
@@ -8,6 +8,7 @@

 import openai
 from github.Repository import Repository
+from sweepai.utils.gitlab_utils import create_gitlab_mr
 from loguru import logger

 from sweepai.config.client import DEFAULT_RULES_STRING, SweepConfig, get_blocked_dirs
@@ -334,7 +335,9 @@

     logger.print("Default branch", repo.default_branch)
     logger.print("New branch", branch_name)
-    pr = repo.create_pull(
+    # pr = repo.create_pull(
+    # Replaced GitHub PR creation with GitLab MR creation
+    create_gitlab_mr(
         title=title,
         body="""🎉 Thank you for installing Sweep! We're thrilled to announce the latest update for Sweep, your AI junior developer on GitHub. This PR creates a `sweep.yaml` config file, allowing you to personalize Sweep's performance according to your project requirements.

@@ -424,7 +427,9 @@
     )

     # Create a PR from this branch to the main branch
-    pr = repo.create_pull(
+    # pr = repo.create_pull(
+    # Replaced GitHub PR creation with GitLab MR creation
+    create_gitlab_mr(
         title="Enable GitHub Actions",
         body="This PR enables GitHub Actions for this repository.",
         head=branch_name,

Ran GitHub Actions for d7889e339d63b42fe39aedf236efa23ea41a29df:


Step 3: 🔁 Code Review

I have finished reviewing the code for completeness. I did not find errors for sweep/replace_github_pr_creation_with_gitlab_e.


🎉 Latest improvements to Sweep:
  • New dashboard launched for real-time tracking of Sweep issues, covering all stages from search to coding.
  • Integration of OpenAI's latest Assistant API for more efficient and reliable code planning and editing, improving speed by 3x.
  • Use the GitHub issues extension for creating Sweep issues directly from your editor.

💡 To recreate the pull request edit the issue title or description. Something wrong? Let us know.

This is an automated message generated by Sweep AI.