fix: bind prune and version flags to correct cobra command#430
fix: bind prune and version flags to correct cobra command#430rishi-jat wants to merge 1 commit intomodelpack:mainfrom
Conversation
Signed-off-by: Rishi Jat <rishijat098@gmail.com>
Summary of ChangesHello, 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 resolves critical flag binding issues within the Highlights
Changelog
Activity
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
|
There was a problem hiding this comment.
Code Review
This pull request correctly fixes an issue where flags for the prune and version commands were bound to the wrong command. The changes are correct. I've added one suggestion on cmd/version.go to remove some redundant code. As a minor note, you may also want to update the error message on line 52 of cmd/prune.go in a follow-up, as it seems to be a copy-paste from another command and is outside the scope of this PR's changes.
| flags := versionCmd.Flags() | ||
|
|
||
| if err := viper.BindPFlags(flags); err != nil { | ||
| panic(fmt.Errorf("bind version flags to viper: %w", err)) |
There was a problem hiding this comment.
There was a problem hiding this comment.
Pull request overview
This PR fixes a bug where the prune and version commands were incorrectly registering their flags to the rm command instead of their own commands. This was caused by using rmCmd.Flags() instead of the respective command's Flags() method in their init functions.
Changes:
- Fixed
prunecommand to usepruneCmd.Flags()instead ofrmCmd.Flags() - Fixed
versioncommand to useversionCmd.Flags()instead ofrmCmd.Flags()
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| cmd/prune.go | Changed flag registration from rmCmd.Flags() to pruneCmd.Flags() to correctly bind prune-specific flags |
| cmd/version.go | Changed flag registration from rmCmd.Flags() to versionCmd.Flags() to correctly bind version-specific flags |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Summary
Fix incorrect flag registration in
pruneandversioncommands.Both commands were binding flags using
rmCmd.Flags(), causing:pruneflags to be attached tormprune --dry-runnot behaving as expectedrmChanges
pruneCmd.Flags()incmd/prune.goversionCmd.Flags()incmd/version.go