-
Notifications
You must be signed in to change notification settings - Fork 32
Fix pr merge detection #151
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -142,15 +142,20 @@ def main(): | |
| search_data = search_response.json() | ||
| print(f"Search API Response for issue #{assigned_issue['number']}: {search_data}") | ||
|
|
||
| if search_data.get("total_count", 0) > 0: | ||
| pr_number = search_data["items"][0]["number"] | ||
| pr_merge_url = f"https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}/merge" | ||
| merge_response = requests.get(pr_merge_url, headers=headers) | ||
|
|
||
| if merge_response.status_code == 204: | ||
| print(f"PR #{pr_number} is merged for issue #{assigned_issue['number']}.") | ||
| if search_data.get("total_count", 0) > 0: | ||
| pr_number = search_data["items"][0]["number"] | ||
| pr_url = f"https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}" | ||
| pr_response = requests.get(pr_url, headers=headers) | ||
|
|
||
| if pr_response.status_code == 200: | ||
| pr_data = pr_response.json() | ||
|
|
||
| if pr_data.get("merged"): | ||
| print( | ||
| f"PR #{pr_number} is merged for issue #{assigned_issue['number']}." | ||
| ) | ||
| continue | ||
|
|
||
|
Comment on lines
+145
to
+158
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Critical: Fix indentation error. The entire block from line 145 onwards has incorrect indentation, which will cause a Python syntax error. The static analysis tool correctly flagged this issue. 🔎 Proposed fix for indentation- if search_data.get("total_count", 0) > 0:
- pr_number = search_data["items"][0]["number"]
- pr_url = f"https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}"
- pr_response = requests.get(pr_url, headers=headers)
-
- if pr_response.status_code == 200:
- pr_data = pr_response.json()
-
- if pr_data.get("merged"):
- print(
- f"PR #{pr_number} is merged for issue #{assigned_issue['number']}."
- )
+ if search_data.get("total_count", 0) > 0:
+ pr_number = search_data["items"][0]["number"]
+ pr_url = f"https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}"
+ pr_response = requests.get(pr_url, headers=headers)
+
+ if pr_response.status_code == 200:
+ pr_data = pr_response.json()
+
+ if pr_data.get("merged"):
+ print(
+ f"PR #{pr_number} is merged for issue #{assigned_issue['number']}."
+ )
continue
-
🧰 Tools🪛 Ruff (0.14.10)145-145: unindent does not match any outer indentation level (invalid-syntax) 🤖 Prompt for AI Agents |
||
| print(f"Issue #{assigned_issue.get('number')} has no merged PR") | ||
| issues_without_prs.append(assigned_issue.get("number")) | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Major: Check all PRs, not just the first one.
The code only examines the first PR from search results (
search_data["items"][0]). If multiple PRs reference the same issue and the first PR is open while a later PR is merged, the issue will be incorrectly flagged as incomplete.🔎 Proposed fix to check all PRs
if search_data.get("total_count", 0) > 0: - pr_number = search_data["items"][0]["number"] - pr_url = f"https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}" - pr_response = requests.get(pr_url, headers=headers) - - if pr_response.status_code == 200: - pr_data = pr_response.json() - - if pr_data.get("merged"): - print( - f"PR #{pr_number} is merged for issue #{assigned_issue['number']}." - ) + has_merged_pr = False + for pr_item in search_data["items"]: + pr_number = pr_item["number"] + pr_url = f"https://api.github.com/repos/{owner}/{repo}/pulls/{pr_number}" + pr_response = requests.get(pr_url, headers=headers) + + if pr_response.status_code == 200: + pr_data = pr_response.json() + + if pr_data.get("merged"): + print( + f"PR #{pr_number} is merged for issue #{assigned_issue['number']}." + ) + has_merged_pr = True + break + + if has_merged_pr: continue🤖 Prompt for AI Agents