sweepai / sweep

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

Sweep: Handle this sentry error: 409 {"message": "Git Repository is empty.", "documentation_url": "https://docs.github.com/rest/commits/commits#list-commits"} #3902

Open wwzeng1 opened 5 months ago

wwzeng1 commented 5 months ago

Details

Here is where it occurs:

        else:
            raise

    # get latest commit date
    commit_date = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=30)
    for commit in commits: <- here
        if commit.commit.author.date > commit_date:
            commit_date = commit.commit.author.date
    # since_date = datetime.datetime.now() - datetime.timedelta(days=30)
    # commits = repo.get_commits(since=since_date, author="lukejagg")
sweep-nightly[bot] commented 5 months ago

🚀 Here's the PR! #3903

💎 Sweep Pro: You have unlimited Sweep issues

Actions

Relevant files (click to expand). Mentioned files will always appear here. https://github.com/sweepai/sweep/blob/c9ba053c12e308d4e3dcbcb6693732662a086f50/sweepai/handlers/create_pr.py#L1-L362

Step 2: ⌨️ Coding

sweepai/handlers/create_pr.py

Update the
--- 
+++ 
@@ -1,6 +1,6 @@
     for repo_entity in repositories:
         repo = g.get_repo(repo_entity.full_name)
-        
+
         try:
             # instead of using total count, use the date of the latest commit
             commits = repo.get_commits(
@@ -13,9 +13,11 @@
                 continue
             else:
                 raise
-        
+
         # get latest commit date
         commit_date = datetime.datetime.now(datetime.timezone.utc) - datetime.timedelta(days=30)
         for commit in commits:
             if commit.commit.author.date > commit_date:
-                commit_date = commit.commit.author.date
+                commit_date = commit.commit.author.date
+
+        repo_activity[repo] = commit_date

Step 3: 🔄️ Validating

Your changes have been successfully made to the branch sweep/handle_this_sentry_error_409_message_git. I have validated these changes using a syntax checker and a linter.


[!TIP] To recreate the pull request, edit the issue title or description.

This is an automated message generated by Sweep AI.