Skip to content

Conversation

@DFanso
Copy link
Owner

@DFanso DFanso commented Oct 3, 2025

Description

This PR enhances the user interface of the commit message generator by adding comprehensive file statistics and a visual preview of changes. The improvements provide users with clear, colorful feedback about their Git repository state before generating commit messages.

Type of Change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Documentation update
  • Code refactoring
  • Performance improvement
  • Other (please describe):

Related Issue

Fixes #(issue number)

Changes Made

UI Enhancements

  • File Statistics Display: Added a comprehensive changes summary showing:

    • ✅ Staged files count with file names (displays first 5)
    • ⚠️ Unstaged files count with file names (displays first 3)
    • 📝 Untracked files count with file names (displays first 3)
    • Collapsible view showing "... and X more" for additional files
  • Visual Changes Preview: Implemented a table-based preview showing:

    • Lines added (displayed in green with + prefix)
    • Lines deleted (displayed in red with - prefix)
    • Total files affected
  • Enhanced Header: Added a full-width styled header "🚀 Commit Message Generator"

  • Improved Commit Message Display:

    • Commit messages now displayed in a styled bordered box
    • Uses custom box characters (┌─┐│└┘) for a polished look
    • Light green color scheme for better visibility
  • Better Spinner Feedback:

    • Custom spinner sequence for generating animation
    • Success message: "✅ Commit message generated successfully!"
    • Failure handling with appropriate error messages

Code Improvements

  • New Data Structure: Added FileStatistics struct to track:

    • Staged files
    • Unstaged files
    • Untracked files
    • Total file count
    • Lines added/deleted
  • Helper Functions:

    • getFileStatistics(): Collects comprehensive file statistics from Git
    • displayFileStatistics(): Renders file stats with pterm styling
    • displayCommitMessage(): Shows commit message in a styled panel
    • displayChangesPreview(): Displays line change statistics
    • filterEmpty(): Utility to clean up file lists
  • Import Organization: Reordered imports for better code organization

Dependency Updates

  • Added github.com/openai/openai-go/v3 v3.0.1 to support ChatGPT integration
  • Updated go.mod and go.sum with new dependencies and reordered entries

Testing

  • Tested with Gemini API
  • Tested with Grok API
  • Tested on Windows
  • Tested on Linux
  • Tested on macOS
  • Added/updated tests (if applicable)

Test Scenarios Verified

  1. ✅ Repository with staged files only
  2. ✅ Repository with unstaged files only
  3. ✅ Repository with untracked files only
  4. ✅ Repository with mixed file states
  5. ✅ Repository with no changes (displays warning)
  6. ✅ Large number of files (collapse functionality works)
  7. ✅ Line statistics calculation for staged changes

Checklist

  • My code follows the project's code style
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings or errors
  • I have tested this in a real Git repository
  • I have read the CONTRIBUTING.md guidelines

Screenshots (if applicable)

Before

No changes detected in the Git repository.

After

┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃                  🚀 Commit Message Generator                    ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

📊 Changes Summary

  ✅ Staged files: 3
    • src/main.go
    • go.mod
    • go.sum
  
  ⚠️ Unstaged files: 1
    • README.md

🤖 Generating commit message...
✅ Commit message generated successfully!

📝 Generated Commit Message

┌─────────────────── Commit Message ───────────────────┐
│  feat: enhance UI with file statistics and preview   │
│                                                       │
│  - Add file statistics display                       │
│  - Implement changes preview                         │
│  - Update dependencies                               │
└───────────────────────────────────────────────────────┘

🔍 Changes Preview

  Lines Added    | +254
  Lines Deleted  | -32
  Total Files    | 3

Additional Notes

Technical Details

  • Uses pterm library extensively for styled terminal output
  • File statistics are collected before fetching full Git changes for better performance
  • Implements early exit when no changes are detected
  • Statistics calculation only processes staged changes for accuracy
  • Binary and large files are excluded from detailed analysis

Future Enhancements

  • Add line statistics for unstaged changes
  • Include file type breakdown (e.g., Go files, Markdown, etc.)
  • Add option to toggle detailed/summary view
  • Support for displaying modified lines context

Breaking Changes

None. This is a pure UI enhancement that doesn't change any existing functionality or API.


For Hacktoberfest Participants

  • This PR is submitted as part of Hacktoberfest 2025

Thank you for your contribution! 🎉

- Add file statistics display showing staged, unstaged, and untracked files
- Implement visual changes preview with lines added/deleted
- Enhance UI with styled headers, sections, and panels using pterm
- Add FileStatistics struct to track file changes
- Improve commit message display with bordered box
- Update spinner with custom sequence and success/failure messages
- Reorder imports for better organization
@DFanso DFanso added the hacktoberfest Eligible for Hacktoberfest label Oct 3, 2025
@DFanso DFanso self-assigned this Oct 3, 2025
@DFanso DFanso added the hacktoberfest-accepted Approved Hacktoberfest contribution label Oct 3, 2025
@DFanso DFanso merged commit ef70edc into main Oct 3, 2025
7 checks passed
DFanso pushed a commit that referenced this pull request Oct 7, 2025
fix #72 : Replace hardcoded display limits with named constants in ShowFileStatistics
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest Eligible for Hacktoberfest hacktoberfest-accepted Approved Hacktoberfest contribution

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants