fix(github): support lightweight tags for GitOps commands#2407
Conversation
Summary of ChangesHello @zakisk, 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 provides a crucial fix for GitOps commands, enabling them to function correctly when invoked on lightweight Git tags. Previously, these commands would encounter errors because the system did not differentiate between annotated and lightweight tags in GitHub's API responses. The changes introduce robust parsing logic to handle both tag types, ensuring that the correct commit SHA is always resolved. This enhancement significantly improves the reliability and usability of GitOps workflows, particularly for projects that utilize lightweight tags. Highlights
Using Gemini Code AssistThe 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
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 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
|
🔍 PR Lint Feedback
|
There was a problem hiding this comment.
Code Review
This pull request introduces a fix to support lightweight tags for GitOps commands, which were previously causing errors. The core change in pkg/provider/github/parse_payload.go correctly uses a switch statement to handle both annotated and lightweight tags by inspecting the ref object type. The accompanying unit tests in pkg/provider/github/parse_payload_test.go are well-structured and cover the new logic, including positive and negative cases. The E2E test in test/github_tag_gitops_test.go is also updated to cover both tag types.
My review has identified a critical issue in a test helper function that could cause a panic due to a nil pointer dereference. Additionally, I've noted a reduction in the E2E test's assertions, which weakens its validation. I've provided suggestions to address both points.
d94bc40 to
3461ff0
Compare
|
/gemini-review |
|
failure is accurate, can reproduce locally |
24aad61 to
8227a63
Compare
When GitOps command `/test` or `/retest` is triggered on a lightweight tag, it was causing an error in ParsePayload because GitHub treats annotated and lightweight tags differently: - Annotated tags: ref object type is "tag", requires GetTag API call to resolve the commit SHA - Lightweight tags: ref object type is "commit", the ref already contains the commit SHA directly The fix uses a switch statement to handle both cases and returns an error for unexpected object types. Also adds: - Unit tests for lightweight tag and invalid object type scenarios - E2E test coverage for both annotated and lightweight tags - LightweightTag option in test framework https://issues.redhat.com/browse/SRVKP-10467 Signed-off-by: Zaki Shaikh <zashaikh@redhat.com>
8227a63 to
2274e06
Compare
When GitOps command
/testor/retestis triggered on a lightweight tag, it was causing an error in ParsePayload because GitHub treats annotated and lightweight tags differently:The fix uses a switch statement to handle both cases and returns an error for unexpected object types.
Also adds:
https://issues.redhat.com/browse/SRVKP-10467
📝 Description of the Change
👨🏻 Linked Jira
🔗 Linked GitHub Issue
Fixes #
🚀 Type of Change
fix:)feat:)feat!:,fix!:)docs:)chore:)refactor:)enhance:)deps:)🧪 Testing Strategy
🤖 AI Assistance
If you have used AI assistance, please provide the following details:
Which LLM was used?
Extent of AI Assistance:
Important
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: Gemini gemini@google.com
Co-authored-by: ChatGPT noreply@chatgpt.com
Co-authored-by: Claude noreply@anthropic.com
Co-authored-by: Cursor noreply@cursor.com
Co-authored-by: Copilot Copilot@users.noreply.github.com
**💡You can use the script
./hack/add-llm-coauthor.shto automatically addthese co-author trailers to your commits.
✅ 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.