Add WithHead option to prcreator for App-auth PR creation#4974
Add WithHead option to prcreator for App-auth PR creation#4974jmguzik wants to merge 1 commit intoopenshift:mainfrom
Conversation
Allow prcreator to skip git operations (fork, commit, push) and only create/update the PR when --head is provided. This enables a split workflow where fork+push is handled externally (e.g. via bash with PAT) and prcreator only does PR creation using GitHub App auth. Signed-off-by: Jakub Guzik <jguzik@redhat.com>
|
Pipeline controller notification For optional jobs, comment This repository is configured in: automatic mode |
WalkthroughThis pull request adds support for creating pull requests with a pre-pushed head reference via a new Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 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). Comment |
|
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: jmguzik The full list of commands accepted by this bot can be found here. The pull request process is described here DetailsNeeds approval from an approver in each of these files:
Approvers can indicate their approval by writing |
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@pkg/github/prcreation/prcreation.go`:
- Around line 124-126: Before calling upsertPR, add fast-fail validation of
inputs: if prArgs.head != "" validate the head value format (e.g., non-empty and
matches expected "user:branch" or "owner/branch" pattern) and return a clear
error if malformed; otherwise (when prArgs.head == "") ensure a token path is
provided (e.g., prArgs.tokenPath is non-empty) and return an error if missing.
Place these checks immediately before the existing conditional that calls
o.upsertPR(org, repo, branch, prTitle, prArgs) so invalid inputs are rejected
early.
ℹ️ Review info
Configuration used: Repository: openshift/coderabbit/.coderabbit.yaml
Review profile: CHILL
Plan: Pro
Cache: Disabled due to data retention organization setting
Knowledge base: Disabled due to data retention organization setting
📒 Files selected for processing (3)
cmd/prcreator/main.gopkg/github/prcreation/orgaware.gopkg/github/prcreation/prcreation.go
| if prArgs.head != "" { | ||
| return o.upsertPR(org, repo, branch, prTitle, prArgs) | ||
| } |
There was a problem hiding this comment.
Validate execution mode inputs before branching.
This branch should fail fast for malformed --head and for non-head mode without a token path; otherwise failures happen later during API/git operations and are harder to diagnose.
Suggested fix
if prArgs.head != "" {
+ parts := strings.SplitN(prArgs.head, ":", 2)
+ if len(parts) != 2 || parts[0] == "" || parts[1] == "" {
+ return fmt.Errorf("invalid --head value %q, expected <owner>:<branch>", prArgs.head)
+ }
return o.upsertPR(org, repo, branch, prTitle, prArgs)
}
+
+ if o.TokenPath == "" {
+ return fmt.Errorf("token path is required when --head is not set")
+ }📝 Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.
| if prArgs.head != "" { | |
| return o.upsertPR(org, repo, branch, prTitle, prArgs) | |
| } | |
| if prArgs.head != "" { | |
| parts := strings.SplitN(prArgs.head, ":", 2) | |
| if len(parts) != 2 || parts[0] == "" || parts[1] == "" { | |
| return fmt.Errorf("invalid --head value %q, expected <owner>:<branch>", prArgs.head) | |
| } | |
| return o.upsertPR(org, repo, branch, prTitle, prArgs) | |
| } | |
| if o.TokenPath == "" { | |
| return fmt.Errorf("token path is required when --head is not set") | |
| } |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.
In `@pkg/github/prcreation/prcreation.go` around lines 124 - 126, Before calling
upsertPR, add fast-fail validation of inputs: if prArgs.head != "" validate the
head value format (e.g., non-empty and matches expected "user:branch" or
"owner/branch" pattern) and return a clear error if malformed; otherwise (when
prArgs.head == "") ensure a token path is provided (e.g., prArgs.tokenPath is
non-empty) and return an error if missing. Place these checks immediately before
the existing conditional that calls o.upsertPR(org, repo, branch, prTitle,
prArgs) so invalid inputs are rejected early.
|
@jmguzik: The following tests failed, say
Full PR test history. Your PR dashboard. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
Allow prcreator to skip git operations (fork, commit, push) and only create/update the PR when --head is provided. This enables a split workflow where fork+push is handled externally (e.g. via bash with PAT) and prcreator only does PR creation using GitHub App auth.
Summary by CodeRabbit
Release Notes