Repository navigation
Conversation
Remove the restriction that required GitOps comments to target only the HEAD commit of a branch. Users can now trigger PipelineRuns on any commit in the push history, enabling more flexible automation workflows. Replaces HEAD commit validation with GitHub Compare Commits API to check if provided SHA is part of the target branch (behind or identical status), allowing users to re-run pipelines on historical commits. Added comprehensive unit tests covering: - Happy path: commit behind branch - Happy path: commit identical to branch head - Failure path: commit ahead of branch - Failure path: invalid branch name https://redhat.atlassian.net/browse/SRVKP-4404 Signed-off-by: Zaki Shaikh <zashaikh@redhat.com>
Paco ReviewThe PR replaces the Paco could not check everything:
No new verified findings. This is not a guarantee that the change is defect-free. 1 candidates not published
Reviewed commit: 2456ba2. 0 verified findings; 0 summary-only. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #3059 +/- ##
==========================================
+ Coverage 91.98% 91.99% +0.01%
==========================================
Files 167 167
Lines 12973 12965 -8
==========================================
- Hits 11933 11927 -6
+ Misses 1039 1037 -2
Partials 1 1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
🟡 Changes recommended
Unresolved ancestry and branch-existence validation gaps allow non-ancestor commits to be treated as default-branch commits and SHAs or tags to be accepted as branches, potentially selecting incorrect pipelines.
2 open issues
What changed in this PR
This PR enables GitHub GitOps commands on historical commits, replacing the branch-HEAD restriction with an ancestry check when a branch is explicitly supplied.
Changes:
- Accepts older commits belonging to an explicitly selected GitHub branch.
- Updates payload tests and removes the obsolete HEAD-check helper and tests.
- Removes the HEAD-only restriction from the shared push-command guide.
| File | Description |
|---|---|
pkg/provider/github/parse_payload.go |
Adds commit comparison for explicitly selected branches. |
pkg/provider/github/parse_payload_test.go |
Covers historical commits, branch HEADs, and invalid comparisons. |
pkg/provider/github/github.go |
Removes the HEAD-only validation helper. |
pkg/provider/github/github_test.go |
Removes tests for the deleted helper. |
docs/content/docs/guides/gitops-commands/push-commands.md |
Removes the documented HEAD-only limitation. |
Review effort: Balanced
| if branchName == "" { | ||
| branchName = runevent.HeadBranch | ||
| } | ||
| } else { |
| comparison, _, err := wrapAPI(v, "compare_refs", func() (*github.CommitsComparison, *github.Response, error) { | ||
| return v.Client().Repositories.CompareCommits(ctx, runevent.Organization, runevent.Repository, branchName, runevent.SHA, &github.ListOptions{}) | ||
| }) |
theakshaypant
left a comment
There was a problem hiding this comment.
How would this impact ok-to-test?
None, this is about Gitops comment on pushed commits where we don't need ok-to-test comment. |

📝 Description of the Change
Remove the restriction that required GitOps comments to target only the HEAD commit of a branch for both GitHub and GitLab providers. Users can now trigger PipelineRuns on any commit in the push history, enabling more flexible automation workflows.
🔗 Linked GitHub Issue
Fixes #
🧪 Testing Strategy
🤖 AI Assistance
AI assistance can be used for various tasks, such as code generation,
documentation, or testing.
Please indicate whether you have used AI assistance
for this PR and provide details if applicable.
Important
Slop will be simply rejected, if you are using AI assistance you need to make sure you
understand the code generated and that it meets the project's standards. you
need at least know how to run the code and deploy it (if needed). See
startpaac to make it easy
to deploy and test your code changes.
If the majority of the code in this PR was generated by an AI, please add a
Co-authored-bytrailer to your commit message.For example:
Co-authored-by: Claude noreply@anthropic.com
✅ Submitter Checklist
fix:,feat:) matches the "Type of Change" I selected above.make testandmake lintlocally to check for and fix anyissues. For an efficient workflow, I have considered installing
pre-commit and running
pre-commit installtoautomate these checks.