sweepai / sweep

Sweep: open-source AI-powered Software Developer for small features and bug fixes.
https://sweep.dev
Other
7.43k stars 425 forks source link

Sweep: allow sweep.yaml to be read from the user/organization's .github repository. #2758

Open wwzeng1 opened 10 months ago

wwzeng1 commented 10 months ago
Checklist - [X] Modify `sweepai/config/client.py` ✓ https://github.com/sweepai/sweep/commit/e509f1c894a252fa606303a2bd3acee60a35c52c [Edit](https://github.com/sweepai/sweep/edit/sweep/allow_sweepyaml_to_be_read_from_the_user/sweepai/config/client.py#L225-L236) - [X] Running GitHub Actions for `sweepai/config/client.py` ✓ [Edit](https://github.com/sweepai/sweep/edit/sweep/allow_sweepyaml_to_be_read_from_the_user/sweepai/config/client.py#L225-L236) - [X] Modify `sweepai/config/client.py` ✓ https://github.com/sweepai/sweep/commit/d6d8df8f45aa95e51f990128808c0c8c7deb6073 [Edit](https://github.com/sweepai/sweep/edit/sweep/allow_sweepyaml_to_be_read_from_the_user/sweepai/config/client.py#L166-L176) - [X] Running GitHub Actions for `sweepai/config/client.py` ✓ [Edit](https://github.com/sweepai/sweep/edit/sweep/allow_sweepyaml_to_be_read_from_the_user/sweepai/config/client.py#L166-L176) - [X] Modify `sweepai/config/client.py` ✓ https://github.com/sweepai/sweep/commit/586ea4a559661ae44b93a1496dc7347d197e7fc8 [Edit](https://github.com/sweepai/sweep/edit/sweep/allow_sweepyaml_to_be_read_from_the_user/sweepai/config/client.py#L179-L192) - [X] Running GitHub Actions for `sweepai/config/client.py` ✓ [Edit](https://github.com/sweepai/sweep/edit/sweep/allow_sweepyaml_to_be_read_from_the_user/sweepai/config/client.py#L179-L192)
sweep-nightly[bot] commented 10 months ago

🚀 Here's the PR! #2764

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

Actions (click)

Sandbox Execution ✓

Here are the sandbox execution logs prior to making any changes:

Sandbox logs for bb084a7
Checking sweepai/config/client.py for syntax errors... ✅ sweepai/config/client.py has no syntax errors! 1/1 ✓
Checking sweepai/config/client.py for syntax errors...
✅ sweepai/config/client.py has no syntax errors!

Sandbox passed on the latest main, so sandbox checks will be enabled for this issue.


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/sweepai/sweep/blob/5d2923a600d29ac9c9042a66be9485765ed4535e/sweepai/config/client.py#L225-L236 https://github.com/sweepai/sweep/blob/5d2923a600d29ac9c9042a66be9485765ed4535e/sweepai/config/client.py#L166-L192

Step 2: ⌨️ Coding

--- 
+++ 
@@ -225,7 +225,10 @@
 @lru_cache(maxsize=None)
 def get_branch_name_config(repo: Repository):
     try:
-        contents = repo.get_contents("sweep.yaml")
+        try:
+            contents = repo.get_contents(".github/sweep.yaml")
+        except Exception:
+            contents = repo.get_contents("sweep.yaml")
         description = yaml.safe_load(contents.decoded_content.decode("utf-8")).get(
             "branch_use_underscores", False
         )

Ran GitHub Actions for e509f1c894a252fa606303a2bd3acee60a35c52c:
• black:
• Vercel Preview Comments:

--- 
+++ 
@@ -166,7 +166,10 @@
     @staticmethod
     def get_draft(repo: Repository):
         try:
-            contents = repo.get_contents("sweep.yaml")
+            try:
+                contents = repo.get_contents(".github/sweep.yaml")
+            except Exception:
+                contents = repo.get_contents("sweep.yaml")
             config = yaml.safe_load(contents.decoded_content.decode("utf-8"))
             return config.get("draft", False)
         except SystemExit:
@@ -225,7 +228,10 @@
 @lru_cache(maxsize=None)
 def get_branch_name_config(repo: Repository):
     try:
-        contents = repo.get_contents("sweep.yaml")
+        try:
+            contents = repo.get_contents(".github/sweep.yaml")
+        except Exception:
+            contents = repo.get_contents("sweep.yaml")
         description = yaml.safe_load(contents.decoded_content.decode("utf-8")).get(
             "branch_use_underscores", False
         )

Ran GitHub Actions for d6d8df8f45aa95e51f990128808c0c8c7deb6073:
• black:
• Vercel Preview Comments:

--- 
+++ 
@@ -166,7 +166,10 @@
     @staticmethod
     def get_draft(repo: Repository):
         try:
-            contents = repo.get_contents("sweep.yaml")
+            try:
+                contents = repo.get_contents(".github/sweep.yaml")
+            except Exception:
+                contents = repo.get_contents("sweep.yaml")
             config = yaml.safe_load(contents.decoded_content.decode("utf-8"))
             return config.get("draft", False)
         except SystemExit:
@@ -179,7 +182,10 @@
 @lru_cache(maxsize=None)
 def get_gha_enabled(repo: Repository) -> bool:
     try:
-        contents = repo.get_contents("sweep.yaml")
+        try:
+            contents = repo.get_contents(".github/sweep.yaml")
+        except Exception:
+            contents = repo.get_contents("sweep.yaml")
         gha_enabled = yaml.safe_load(contents.decoded_content.decode("utf-8")).get(
             "gha_enabled", True
         )
@@ -187,7 +193,7 @@
     except SystemExit:
         raise SystemExit
     except Exception as e:
-        logger.exception(
+        logger.warning(
             f"Error when getting gha enabled: {e}, traceback: {traceback.format_exc()}, falling back to True"
         )
         return True
@@ -225,7 +231,10 @@
 @lru_cache(maxsize=None)
 def get_branch_name_config(repo: Repository):
     try:
-        contents = repo.get_contents("sweep.yaml")
+        try:
+            contents = repo.get_contents(".github/sweep.yaml")
+        except Exception:
+            contents = repo.get_contents("sweep.yaml")
         description = yaml.safe_load(contents.decoded_content.decode("utf-8")).get(
             "branch_use_underscores", False
         )

Ran GitHub Actions for 586ea4a559661ae44b93a1496dc7347d197e7fc8:
• black:
• Vercel Preview Comments:


Step 3: 🔁 Code Review

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


🎉 Latest improvements to Sweep:


💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord