feat: cherry-pick author attribution and PR assignment#994
Conversation
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
WalkthroughAdds a new global and per-repository config flag to control assigning cherry-pick PRs to the original PR author, exposes that flag on the GitHub webhook object, threads it into label-triggered and command-triggered cherry-pick flows, updates the RunnerHandler.cherry_pick signature to accept an assign-to-owner flag, and updates tests and examples accordingly. Changes
Sequence Diagram(s)sequenceDiagram
participant PR as Pull Request
participant PRH as PullRequestHandler
participant RH as RunnerHandler
participant GH as GitHub
PR->>PRH: merged with `cherry-pick-<branch>` label(s)
PRH->>PRH: filter labels\nextract PR author
PRH->>RH: cherry_pick(pr, target_branch,\nassign_to_pr_owner=webhook.cherry_pick_assign_to_pr_author)
RH->>RH: build requested_by text\n(determine assignee_flag if assign_to_pr_owner)
alt assignee_flag present
Note over RH: assignee_flag = "-a {author_login}"
end
alt target branch exists
RH->>GH: run hub create pull-request (include labels, assignee_flag)
GH-->>RH: success
else
RH->>GH: post comment on original PR about failure
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). 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. Comment |
Review Summary by QodoAdd PR author attribution and optional assignee for cherry-pick PRs
WalkthroughsDescription• Add PR author attribution to cherry-pick descriptions with new by_label parameter • Implement optional assignee feature via cherry-pick-assign-to-pr-author config option • Extract PR author login when cherry-pick triggered by label on merge • Add comprehensive test coverage for assignee and attribution functionality File Changes1. webhook_server/libs/github_api.py
|
|
Report bugs in Issues Welcome! 🎉This pull request will be automatically processed with the following features: 🔄 Automatic Actions
📋 Available CommandsPR Status Management
Review & Approval
Testing & Validation
Container Operations
Cherry-pick Operations
Label Management
✅ Merge RequirementsThis PR will be automatically approved when the following conditions are met:
📊 Review ProcessApprovers and ReviewersApprovers:
Reviewers:
Available Labels
💡 Tips
For more information, please refer to the project documentation or contact the maintainers. |
Code Review by Qodo
✅ 1.
|
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@webhook_server/libs/handlers/runner_handler.py`:
- Around line 539-555: In cherry_pick, avoid producing "by with target-branch
label" when by_label is True but reviewed_user is empty: update the requested_by
assignment to check reviewed_user and use a sensible fallback (e.g. "by
target-branch label" or "by unknown") or format conditionally so you only
include "by {reviewed_user} with target-branch label" when reviewed_user is
non-empty; reference the cherry_pick method and the requested_by / reviewed_user
/ by_label variables when making the change.
In `@webhook_server/tests/test_runner_handler.py`:
- Around line 965-1003: Rename the test function
test_cherry_pick_assigns_to_pr_author_fallback to reflect actual behavior (e.g.,
test_cherry_pick_always_assigns_to_pr_author_when_flag_set) and update its
docstring to state that when
runner_handler.github_webhook.cherry_pick_assign_to_pr_author is True the
assignee is always pull_request.user.login regardless of reviewed_user; also
update the inline comment on Line 996 to match this invariant (referencing
runner_handler.cherry_pick, reviewed_user, and cherry_pick_assign_to_pr_author
to locate the code).
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@webhook_server/tests/test_runner_handler.py`:
- Around line 1008-1046: Add a new async test that exercises
runner_handler.cherry_pick with by_label=True and reviewed_user="" to cover the
fallback branch that sets requested_by to "by target-branch label";
specifically, create a test named like
test_cherry_pick_by_label_empty_reviewed_user_requested_by_format that mirrors
test_cherry_pick_by_label_requested_by_format's setup (patch is_branch_exists,
check_run_handler methods, _checkout_worktree, run_command, and
PR.create_issue_comment) but calls runner_handler.cherry_pick(mock_pull_request,
"main", reviewed_user="", by_label=True) and asserts the last run_command
invocation's hub command contains "requested-by by target-branch label" and does
not contain the double-space pattern "by with".
- Around line 999-1000: The test's assertion using mock_to_thread.call_count >=
1 is too weak; when cherry_pick_assign_to_pr_author=True the success path should
make exactly two asyncio.to_thread calls (one for accessing user.login and one
for create_issue_comment). Update the assertion in the test_runner_handler to
assert mock_to_thread.call_count == 2 (or otherwise verify the two specific
calls exist), and/or add an explicit check that one of the mock_to_thread calls
invoked user.login (e.g., by inspecting mock_to_thread.call_args_list) so the
test guarantees user.login was called via asyncio.to_thread.
f8195c0 to
4731f18
Compare
|
/build-and-push-container |
|
New container for ghcr.io/myk-org/github-webhook-server:pr-994 published |
|
/verified |
…feat/issue-993-cherry-pick-author-attribution
|
/verified |
|
review and approve |
|
The changes implement cherry-pick author attribution with optional assignment:
The implementation follows existing configuration patterns and includes comprehensive test updates. 🧠 Learnings used✅ Actions performedComments resolved and changes approved. Review triggered.
|
…feat/issue-993-cherry-pick-author-attribution
|
/verififed |
|
/verified |
|
review and approve if all ok |
|
✅ Implementation Quality
✅ Testing & Quality
✅ Configuration & Documentation
No issues found. The feature implementation is solid, well-tested, and maintains consistency with the codebase patterns. 🧠 Learnings used✅ Actions performedComments resolved and changes approved. |
if all looks ood, approve the pr |
|
Approving now. 🧠 Learnings used✅ Actions performedComments resolved and changes approved. |
…feat/issue-993-cherry-pick-author-attribution
|
/verified |
|
/lgtm |
|
Successfully removed PR tag: ghcr.io/myk-org/github-webhook-server:pr-994. |
|
New container for ghcr.io/myk-org/github-webhook-server:latest published |
Summary
cherry-pick-assign-to-pr-authorconfig optionTest plan