Skip to content

fix(issue-sync): find_closing_pr() reads pr:#NNN format from TODO.md (t291)#1129

Merged
marcusquinn merged 1 commit intomainfrom
bugfix/t291-find-closing-pr-format
Feb 11, 2026
Merged

fix(issue-sync): find_closing_pr() reads pr:#NNN format from TODO.md (t291)#1129
marcusquinn merged 1 commit intomainfrom
bugfix/t291-find-closing-pr-format

Conversation

@marcusquinn
Copy link
Copy Markdown
Owner

Summary

  • Fixes find_closing_pr() to read the pr:#NNN format from TODO.md task lines — the most reliable PR source
  • Adds parent task ID fallback search for subtask PRs (e.g., t214.6 -> searches t214)
  • Retroactively added PR reference comments to 36 closed issues that were missing them

Root Cause

find_closing_pr() had two checks:

  1. Check 1: Regex PR #[0-9]+ — didn't match the actual pr:#963 format (lowercase, no space)
  2. Check 2: GitHub search for task ID in PR title — subtask IDs like t214.6 don't match parent PR titles like (t214)

This meant close comments said "Completed. Task tXXX marked done in TODO.md." without citing the PR, even when pr:#NNN existed in TODO.md.

Changes

File Change
.agents/scripts/issue-sync-helper.sh Add Check 1 (pr:#NNN extraction), Check 3b (parent ID fallback)

Testing

  • bash -n syntax check: pass
  • shellcheck -S warning: zero violations
  • Verified regex matches pr:#963 from real TODO.md task line
  • Verified parent ID extraction: t214.6 -> t214
  • Retroactively commented 36/36 closed issues successfully

Ref #895

….md (t291)

The function used regex 'PR #[0-9]+' which didn't match the actual
'pr:#NNN' format in TODO.md, so close comments never cited the PR
even when it existed. Also: subtask IDs (t214.6) didn't match parent
PR titles (t214), so GitHub search failed as a fallback.

Changes:
- Add Check 1: extract pr:#NNN directly from task line (most reliable)
- Add Check 3b: search by parent task ID for subtask PRs
- Renumber existing checks for clarity

Retroactive: added PR reference comments to 36 closed issues that
were missing them due to this bug.

Ref #895
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai bot commented Feb 11, 2026

Warning

Rate limit exceeded

@marcusquinn has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 0 minutes and 10 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch bugfix/t291-find-closing-pr-format

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@gemini-code-assist
Copy link
Copy Markdown

Summary of Changes

Hello @marcusquinn, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly improves the issue-sync script's ability to accurately link closed GitHub issues to their corresponding pull requests. The changes address previous limitations in PR detection logic, ensuring that issues are correctly associated with the work that resolved them, particularly when PRs are referenced in TODO.md or when dealing with subtasks.

Highlights

  • Enhanced PR Detection: The find_closing_pr() function now correctly identifies pull requests referenced with the pr:#NNN format within TODO.md task lines, which is considered the most reliable source.
  • Subtask Parent ID Fallback: A new fallback mechanism has been implemented for subtask IDs (e.g., t214.6), allowing the system to search for the parent task ID (e.g., t214) in PR titles if a direct match for the subtask is not found.
  • Retroactive Issue Updates: PR reference comments were retroactively added to 36 closed issues that were previously missing this information, improving historical data accuracy.
Changelog
  • .agents/scripts/issue-sync-helper.sh
    • Added a new check to find_closing_pr to extract PR numbers from the pr:#NNN format in task lines.
    • Introduced a fallback search logic within find_closing_pr to look for parent task IDs when a subtask ID is provided.
    • Reordered the existing PR detection checks to prioritize the most reliable sources.
Activity
  • The find_closing_pr() function was updated to correctly parse pr:#NNN from TODO.md task lines.
  • A parent task ID fallback search was added for subtask PRs (e.g., t214.6 now searches t214).
  • Retroactively added PR reference comments to 36 closed issues that were missing them.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

@github-actions
Copy link
Copy Markdown
Contributor

🔍 Code Quality Report

�[0;35m[MONITOR]�[0m Code Review Monitoring Report

�[0;34m[INFO]�[0m Latest Quality Status:
SonarCloud: 0 bugs, 0 vulnerabilities, 47 code smells

�[0;34m[INFO]�[0m Recent monitoring activity:
Wed Feb 11 14:35:58 UTC 2026: Code review monitoring started
Wed Feb 11 14:35:58 UTC 2026: SonarCloud - Bugs: 0, Vulnerabilities: 0, Code Smells: 47

📈 Current Quality Metrics

  • BUGS: 0
  • CODE SMELLS: 47
  • VULNERABILITIES: 0

Generated on: Wed Feb 11 14:36:01 UTC 2026


Generated by AI DevOps Framework Code Review Monitoring

@sonarqubecloud
Copy link
Copy Markdown

@marcusquinn marcusquinn merged commit 8ab799f into main Feb 11, 2026
10 checks passed
@marcusquinn marcusquinn deleted the bugfix/t291-find-closing-pr-format branch February 11, 2026 14:37
Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes an issue where the closing pull request was not being properly identified from TODO.md task lines. The changes introduce a new check for the pr:#NNN format and add a fallback search for parent task IDs, which effectively addresses the root cause. My review includes a few suggestions to improve shell scripting quality by simplifying command pipelines and refactoring duplicated logic, aligning with the repository's focus on high-quality shell scripting.

# Check 1: Extract PR number from task line notes (e.g., "PR #123 merged")
# Check 1 (t291): Extract pr:#NNN from TODO.md task line — most reliable source
local todo_pr
todo_pr=$(echo "$task_line" | grep -oE 'pr:#[0-9]+' | head -1 | grep -oE '[0-9]+' || echo "")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This command pipeline can be simplified and made more efficient by using a single sed command to both find and extract the pull request number. This reduces the number of piped commands and sub-processes, improving performance and readability.

Suggested change
todo_pr=$(echo "$task_line" | grep -oE 'pr:#[0-9]+' | head -1 | grep -oE '[0-9]+' || echo "")
todo_pr=$(echo "$task_line" | sed -E -n 's/.*pr:#([0-9]+).*/\1/p' | head -1 || echo "")


# Check 2: Extract PR number from task line notes (e.g., "PR #123 merged")
local inline_pr
inline_pr=$(echo "$task_line" | grep -oiE 'PR #[0-9]+' | head -1 | grep -oE '[0-9]+' || echo "")
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

Similar to the todo_pr extraction, this command pipeline can be made more efficient. Using sed to strip non-numeric characters after the initial grep is more performant than invoking a second grep process.

Suggested change
inline_pr=$(echo "$task_line" | grep -oiE 'PR #[0-9]+' | head -1 | grep -oE '[0-9]+' || echo "")
inline_pr=$(echo "$task_line" | grep -oiE 'PR #[0-9]+' | head -1 | sed 's/[^0-9]*//g' || echo "")

Comment on lines +1270 to +1281
# Check 3b (t291): For subtask IDs (e.g., t214.6), also search by parent ID (t214)
local parent_id
parent_id=$(echo "$task_id" | grep -oE '^t[0-9]+' || echo "")
if [[ -n "$parent_id" && "$parent_id" != "$task_id" ]]; then
pr_json=$(gh pr list --repo "$repo_slug" --state merged --search "$parent_id in:title" --limit 1 --json number,url 2>/dev/null || echo "[]")
pr_number=$(echo "$pr_json" | jq -r '.[0].number // empty' 2>/dev/null || echo "")
pr_url=$(echo "$pr_json" | jq -r '.[0].url // empty' 2>/dev/null || echo "")
if [[ -n "$pr_number" && "$pr_number" != "null" ]]; then
echo "${pr_number}|${pr_url}"
return 0
fi
fi
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

This block of code is nearly identical to the preceding block (lines 1259-1268) that searches for a PR using task_id. To improve maintainability and avoid code duplication, consider extracting this logic into a local helper function. The function could take the search term (task_id or parent_id) as an argument and return the PR information if found.

For example:

_find_gh_pr_by_search_term() {
    local search_term="$1"
    local repo_slug="$2"
    local pr_json
    pr_json=$(gh pr list --repo "$repo_slug" --state merged --search "$search_term in:title" --limit 1 --json number,url 2>/dev/null || echo "[]")
    local pr_number
    pr_number=$(echo "$pr_json" | jq -r '.[0].number // empty' 2>/dev/null || echo "")
    local pr_url
    pr_url=$(echo "$pr_json" | jq -r '.[0].url // empty' 2>/dev/null || echo "")

    if [[ -n "$pr_number" && "$pr_number" != "null" ]]; then
        echo "${pr_number}|${pr_url}"
        return 0
    fi
    return 1
}

You could then call this function for both task_id and parent_id to reduce the duplicated code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

code-reviews-actioned All review feedback has been actioned

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant