-
Notifications
You must be signed in to change notification settings - Fork 0
feat(tags): add 'tags' command to display git tags #5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Implements a new subcommand 'in tags' to list git tags chronologically. Key features: - Displays tag date, name, and commit subject. - By default, shows the 10 most recent tags in ascending order. - Provides a summary of the total number of tags and the date range when showing a partial list. - Includes an '--all' flag to display all tags. - Updates the README with documentation for the new command.
WalkthroughA new "Show Git Tags" feature has been introduced, allowing users to list git tags in chronological order via a new Changes
Sequence Diagram(s)sequenceDiagram
participant User
participant CLI
participant ArgsParser
participant TagsModule
participant Git
User->>CLI: Run `in tags [--all]`
CLI->>ArgsParser: Parse command-line arguments
ArgsParser-->>CLI: Return InspectionCommand::ShowTags(options)
CLI->>TagsModule: show_tags(options)
TagsModule->>Git: Run git for-each-ref to list tags
Git-->>TagsModule: Return tag list output
TagsModule->>CLI: Print formatted tag list or error
CLI->>User: Display result
Estimated code review effort🎯 2 (Simple) | ⏱️ ~8 minutes Note ⚡️ Unit Test Generation is now available in beta!Learn more here, or try it out under "Finishing Touches" below. 📜 Recent review detailsConfiguration used: CodeRabbit UI ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (1)
✅ Files skipped from review due to trivial changes (1)
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
Implements a new 'tags' subcommand for the 'in' CLI tool to display git tags chronologically. The command shows tag information including date, name, and commit subject, with options to limit output or show all tags.
- Adds a new
tagsmodule with functionality to retrieve and display git tags usinggit for-each-ref - Updates the argument parser to include the new
InspectForTagssubcommand with an--allflag - Integrates the tags command into the main CLI dispatcher
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| src/tags.rs | New module implementing git tag listing with chronological sorting and formatting |
| src/main.rs | Adds module import and command dispatcher case for the tags subcommand |
| src/args.rs | Defines the InspectForTags struct and adds it to the InspectionCommand enum |
| README.md | Documents the new tags command with usage examples and output formatting |
Comments suppressed due to low confidence (1)
|
|
||
| let total_tags = all_tags.len(); | ||
| let tags_to_display = if options.all { | ||
| all_tags.clone() |
Copilot
AI
Jul 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Unnecessary clone of the entire all_tags vector when options.all is true. Consider using a reference or moving the vector instead of cloning.
| all_tags.clone() | |
| all_tags |
| let tags_to_display = if options.all { | ||
| all_tags.clone() | ||
| } else { | ||
| let tags: Vec<TagInfo> = all_tags.iter().rev().take(10).cloned().collect(); |
Copilot
AI
Jul 30, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The magic number 10 is hardcoded. Consider making this configurable or defining it as a named constant for better maintainability.
| let tags: Vec<TagInfo> = all_tags.iter().rev().take(10).cloned().collect(); | |
| let tags: Vec<TagInfo> = all_tags.iter().rev().take(DEFAULT_TAGS_TO_DISPLAY).cloned().collect(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Nitpick comments (2)
README.md (1)
97-110: Add language specification to fenced code block.The fenced code block showing example output should specify a language for better syntax highlighting and accessibility.
-Example output: -``` +Example output: +```text Showing the last 10 of 12 tags (from 2025-07-31 to 2025-07-31). Use --all to see all. 2025-07-31 v0.1.03 Test tag 3 2025-07-31 v0.1.04 Test tag 4 2025-07-31 v0.1.05 Test tag 5 2025-07-31 v0.1.06 Test tag 6 2025-07-31 v0.1.07 Test tag 7 2025-07-31 v0.1.08 Test tag 8 2025-07-31 v0.1.09 Test tag 9 2025-07-31 v0.1.10 Test tag 10 2025-07-31 v0.1.11 Test tag 11 2025-07-31 v0.1.12 Test tag 12</blockquote></details> <details> <summary>src/tags.rs (1)</summary><blockquote> `48-72`: **Consider simplifying the "last 10 tags" logic.** The current approach works but involves a double reversal that could be confusing. Consider these alternatives: **Option 1: Use git sorting to get latest tags directly** ```diff let output = Command::new("git") .args([ "for-each-ref", - "--sort=creatordate", // Sort by date ascending + "--sort=-creatordate", // Sort by date descending "--format=%(creatordate:short)\t%(refname:short)\t%(subject)", "refs/tags", ])Then simplify the selection logic:
let tags_to_display = if options.all { - all_tags.clone() + all_tags } else { - let tags: Vec<TagInfo> = all_tags.iter().rev().take(10).cloned().collect(); - tags.into_iter().rev().collect() + all_tags.into_iter().take(10).collect() };Option 2: Use a more direct slice approach
let tags_to_display = if options.all { all_tags.clone() } else { - let tags: Vec<TagInfo> = all_tags.iter().rev().take(10).cloned().collect(); - tags.into_iter().rev().collect() + let start = all_tags.len().saturating_sub(10); + all_tags[start..].to_vec() };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
README.md(1 hunks)src/args.rs(2 hunks)src/main.rs(2 hunks)src/tags.rs(1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
src/main.rs (1)
src/tags.rs (1)
show_tags(11-93)
🪛 markdownlint-cli2 (0.17.2)
README.md
97-97: Fenced code blocks should have a language specified
(MD040, fenced-code-language)
🔇 Additional comments (9)
README.md (1)
88-117: LGTM! Well-structured documentation.The documentation clearly explains the new tags command functionality, including usage examples and the --all flag option. The example output accurately reflects the expected behavior.
src/main.rs (2)
5-5: LGTM! Module import follows established pattern.The new tags module import is correctly placed with other module declarations.
127-132: LGTM! Error handling follows established pattern.The ShowTags command handling correctly follows the same error handling pattern used by other commands in the application - calling the implementation function and handling errors by printing to stderr and exiting with status 1.
src/args.rs (2)
21-21: LGTM! Command variant follows established pattern.The new ShowTags variant is correctly added to the InspectionCommand enum following the established naming convention.
33-40: LGTM! Well-structured command definition.The InspectForTags struct is properly defined with appropriate derive macros, clear documentation, and follows the established pattern for command-line argument parsing. The --all switch is well-documented and appropriately typed.
src/tags.rs (4)
4-9: LGTM! Simple and appropriate struct definition.The TagInfo struct is well-defined with appropriate fields and Clone derive for the functionality needs.
12-30: LGTM! Robust git command execution.The git command execution is well-implemented with:
- Appropriate use of
git for-each-refwith correct arguments- Proper error handling for both command execution and git errors
- Good handling of the empty output case
32-46: LGTM! Robust parsing with good error handling.The parsing logic correctly handles the tab-separated format from git and gracefully filters out malformed lines. Using
splitn(3, '\t')is appropriate to handle subjects that might contain tab characters.
74-93: LGTM! Clean formatting and output logic.The formatting logic correctly calculates the maximum tag width for proper alignment and produces clean, readable output. The approach is straightforward and effective.
Implements a new subcommand 'in tags' to list git tags chronologically.
Key features:
Summary by CodeRabbit
New Features
Documentation
Chores
.gitignoreto exclude.DS_Storefiles.