1
0
mirror of https://github.com/esphome/esphome.git synced 2025-10-20 18:53:47 +01:00
This commit is contained in:
J. Nick Koston
2025-10-14 13:43:58 -10:00
parent 354f46f7c0
commit 8e6ee2bed1

View File

@@ -111,31 +111,31 @@ def find_existing_comment(pr_number: str) -> str | None:
pr_number: PR number pr_number: PR number
Returns: Returns:
Comment numeric ID (databaseId) if found, None otherwise Comment numeric ID if found, None otherwise
""" """
try: try:
print( print(
f"DEBUG: Looking for existing comment on PR #{pr_number}", file=sys.stderr f"DEBUG: Looking for existing comment on PR #{pr_number}", file=sys.stderr
) )
# List all comments on the PR with both id (node ID) and databaseId (numeric ID) # Use gh api to get comments directly - this returns the numeric id field
result = subprocess.run( result = subprocess.run(
[ [
"gh", "gh",
"pr", "api",
"view", f"/repos/{{owner}}/{{repo}}/issues/{pr_number}/comments",
pr_number,
"--json",
"comments",
"--jq", "--jq",
".comments[] | {id, databaseId, body}", ".[] | {id, body}",
], ],
capture_output=True, capture_output=True,
text=True, text=True,
check=True, check=True,
) )
print(f"DEBUG: gh pr view output:\n{result.stdout}", file=sys.stderr) print(
f"DEBUG: gh api comments output (first 500 chars):\n{result.stdout[:500]}",
file=sys.stderr,
)
# Parse comments and look for our marker # Parse comments and look for our marker
comment_count = 0 comment_count = 0
@@ -146,20 +146,20 @@ def find_existing_comment(pr_number: str) -> str | None:
try: try:
comment = json.loads(line) comment = json.loads(line)
comment_count += 1 comment_count += 1
comment_id = comment.get("id")
print( print(
f"DEBUG: Checking comment {comment_count}: id={comment.get('id')}, databaseId={comment.get('databaseId')}", f"DEBUG: Checking comment {comment_count}: id={comment_id}",
file=sys.stderr, file=sys.stderr,
) )
body = comment.get("body", "") body = comment.get("body", "")
if COMMENT_MARKER in body: if COMMENT_MARKER in body:
database_id = str(comment["databaseId"])
print( print(
f"DEBUG: Found existing comment with databaseId={database_id}", f"DEBUG: Found existing comment with id={comment_id}",
file=sys.stderr, file=sys.stderr,
) )
# Return the numeric databaseId, not the node ID # Return the numeric id
return database_id return str(comment_id)
print("DEBUG: Comment does not contain marker", file=sys.stderr) print("DEBUG: Comment does not contain marker", file=sys.stderr)
except json.JSONDecodeError as e: except json.JSONDecodeError as e:
print(f"DEBUG: JSON decode error: {e}", file=sys.stderr) print(f"DEBUG: JSON decode error: {e}", file=sys.stderr)