Skip to content

Conversation

@tiye
Copy link
Member

@tiye tiye commented Jul 30, 2025

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.

Summary by CodeRabbit

  • New Features

    • Added a new command to display Git tags in chronological order, showing the latest 10 tags by default.
    • Option to display all tags using a flag.
    • Output includes tag creation date, name, and description in a formatted table.
  • Documentation

    • Updated the README with instructions and examples for the new Git tags command.
  • Chores

    • Updated .gitignore to exclude .DS_Store files.

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.
@tiye tiye requested review from a team and Copilot July 30, 2025 17:35
@coderabbitai
Copy link

coderabbitai bot commented Jul 30, 2025

Walkthrough

A new "Show Git Tags" feature has been introduced, allowing users to list git tags in chronological order via a new in tags command. Documentation for this feature was added to the README, command-line argument parsing was extended to support the new subcommand, command dispatch logic in the main function was updated, and a new module implements the tag listing functionality.

Changes

Cohort / File(s) Change Summary
Documentation Update
README.md
Added a "Show Git Tags" section documenting the new in tags command, including usage, output examples, and explanation of the --all flag.
Argument Parsing Extension
src/args.rs
Added ShowTags variant to InspectionCommand enum and introduced the InspectForTags struct to support the new tags subcommand with an --all flag.
Main Command Dispatch
src/main.rs
Imported the new tags module and added a branch to dispatch the ShowTags subcommand, calling tags::show_tags and handling errors appropriately.
Tag Listing Implementation
src/tags.rs
Created a new module implementing show_tags, which runs a git command to list tags, parses and formats the output, handles the --all flag, and prints results or error messages.
Git Ignore Update
.gitignore
Added .DS_Store to the .gitignore file to exclude macOS system files from version control.

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
Loading

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 details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 071cf5d and 9650f6f.

⛔ Files ignored due to path filters (1)
  • .DS_Store is excluded by !**/.DS_Store
📒 Files selected for processing (1)
  • .gitignore (1 hunks)
✅ Files skipped from review due to trivial changes (1)
  • .gitignore
✨ Finishing Touches
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch tags

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need 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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

Copilot AI left a 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 tags module with functionality to retrieve and display git tags using git for-each-ref
  • Updates the argument parser to include the new InspectForTags subcommand with an --all flag
  • 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()
Copy link

Copilot AI Jul 30, 2025

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.

Suggested change
all_tags.clone()
all_tags

Copilot uses AI. Check for mistakes.
let tags_to_display = if options.all {
all_tags.clone()
} else {
let tags: Vec<TagInfo> = all_tags.iter().rev().take(10).cloned().collect();
Copy link

Copilot AI Jul 30, 2025

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.

Suggested change
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();

Copilot uses AI. Check for mistakes.
Copy link

@coderabbitai coderabbitai bot left a 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

📥 Commits

Reviewing files that changed from the base of the PR and between 17b95ce and 071cf5d.

📒 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-ref with 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.

@NoEgAm NoEgAm merged commit 76eaaba into main Sep 1, 2025
2 checks passed
@NoEgAm NoEgAm deleted the tags branch September 1, 2025 07:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants