Skip to content

Conversation

Copilot
Copy link
Contributor

@Copilot Copilot AI commented Sep 28, 2025

This PR adds a new "CHECKOUT GROWTH" section to the git-metrics output that displays repository structure statistics at the end of each year. The section appears at the bottom of the report and provides insights into how the repository's file structure has evolved over time.

New Section Output

CHECKOUT GROWTH ################################################################################################

Year     Directories    Max depth    Max path length    Files           Total size
----------------------------------------------------------------------------------------------------
2025              16           3                54            56        111.4 KB

Features

The new section tracks five key metrics for each year:

  • Number of directories: Count of unique directories in the repository
  • Maximum path depth: Deepest directory nesting level (e.g., pkg/display/sections/ = depth 3)
  • Maximum path length: Longest file path by character count
  • Number of files: Total count of files in the repository
  • Total size of files: Sum of all file sizes (on-disk compressed size)

Implementation

The implementation consolidates data collection with the existing growth statistics calculation to eliminate additional git commands. The checkout growth metrics are calculated during the same git rev-list --objects --all --before YYYY-01-01 execution used for regular growth statistics, ensuring efficient performance.

Key components:

  • Checkout growth fields integrated directly into the existing GrowthStatistics model
  • GetGrowthStats() function enhanced to calculate both regular growth stats and checkout growth stats in a single pass
  • DisplayCheckoutGrowth() function for formatted output following existing section patterns
  • Comprehensive test coverage for both data collection and display logic

Performance Optimization

The solution eliminates duplicate git operations by consolidating checkout growth calculation with existing growth statistics:

  • Before: 2x git rev-list calls per year (growth stats + checkout stats)
  • After: 1x git rev-list call per year (calculates both in same loop)

The section integrates seamlessly with the existing git-metrics architecture and maintains consistency with other sections' styling and formatting patterns while providing improved performance through consolidated data collection.

Original prompt

Add a new section at the end:

  • Title: CHECKOUT GROWTH
  • Columns: Number of directories, Maximum path depth, Maximum path length, Number of files, Total size of files

Just get the state at the end of each year


💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

@Copilot Copilot AI changed the title [WIP] Add a new section at the end: - Title: CHECKOUT GROWTH - Columns: Number of directories, Maximum path depth, Maximum path length, Number of files, Total size of files Just get the state at the end of each year Add CHECKOUT GROWTH section with year-end repository statistics Sep 28, 2025
@Copilot Copilot AI requested a review from steffen September 28, 2025 04:10
Copilot finished work on behalf of steffen September 28, 2025 04:10
@steffen
Copy link
Owner

steffen commented Sep 29, 2025

@copilot Can you come up with a solution where no additional git rev-list commands are needed for the checkout growth section. Maybe consolidate the git command side with the growth table at the beginning?

… eliminate additional git commands

Co-authored-by: steffen <[email protected]>
Copy link
Contributor Author

Copilot AI commented Sep 29, 2025

@copilot Can you come up with a solution where no additional git rev-list commands are needed for the checkout growth section. Maybe consolidate the git command side with the growth table at the begin...

Done! I've consolidated the checkout growth calculation with the existing growth statistics to eliminate the additional git commands.

Key changes:

  • Added checkout growth fields directly to the GrowthStatistics struct
  • Modified GetGrowthStats() to calculate both regular growth stats AND checkout growth stats in a single pass
  • Removed the separate GetCheckoutGrowthStats() function and additional git calls
  • Updated main.go to use the existing yearlyStatistics for checkout growth display

Performance improvement:

  • Before: 2x git rev-list calls per year (growth stats + checkout stats)
  • After: 1x git rev-list call per year (calculates both in same loop)

The CHECKOUT GROWTH section still displays correctly at the end with the same data accuracy, but now with improved efficiency by reusing the git data already being processed.

Commit: eca7c46

Copilot finished work on behalf of steffen September 29, 2025 00:16
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.

2 participants