Skip to content

Single git call for authors and dates#172

Merged
glenn-jocher merged 8 commits intomainfrom
tqdm
Nov 22, 2025
Merged

Single git call for authors and dates#172
glenn-jocher merged 8 commits intomainfrom
tqdm

Conversation

@glenn-jocher
Copy link
Member

@glenn-jocher glenn-jocher commented Nov 22, 2025

🛠️ PR Summary

Made with ❤️ by Ultralytics Actions

🌟 Summary

Speeds up and centralizes git metadata handling for the MkDocs plugin, improving author/JSON-LD generation performance and logging. 🚀

📊 Key Changes

  • 🔢 Version bump: Plugin version updated from 0.2.1 to 0.2.2.
  • 🧠 Centralized git metadata build: Added build_git_map() to compute creation dates, last modified dates, and author email counts for all markdown files in a single git log pass.
  • 📁 Config-level git preload: MetaPlugin.on_config() now precomputes git_repo_url and git_data once when authors or JSON-LD are enabled, instead of doing it per page.
  • 🧬 Processor integration: process_html() and get_git_info() now use the precomputed git_data and repo_url instead of calling git repeatedly.
  • 👤 Author lookup refactor: get_github_usernames_from_file() now accepts precomputed email counts and an optional repo_url, removing internal git log/git blame calls.
  • ⚙️ Site postprocessing optimization: postprocess_site() now:
    • Builds a single git map for all markdown files used in HTML pages.
    • Passes git_data and repo_url down to process_html_file().
  • 📈 Better CLI feedback: Optional use of TQDM progress bars and a pluggable log function for more controlled verbose logging during site postprocessing.
  • 🧹 Error handling & logging tweaks: Standardized read/write error logging through the injected log function when verbose is enabled.

🎯 Purpose & Impact

  • Performance boost for large sites: Avoids running git per page/file, significantly reducing build time when authors and JSON-LD are enabled.
  • 🧩 More consistent metadata: Central git map ensures creation/modified dates and author data are derived in a uniform way across all pages.
  • 👥 Reliable author attribution: Uses aggregated email counts from git log to generate stable, weighted author lists (with avatars and profiles) for pages.
  • 📊 Improved UX during builds: Optional progress bar and structured logging make long postprocessing runs more transparent and easier to monitor.
  • 🛠️ Easier maintenance and extension: Consolidating git access into shared utilities (build_git_map, shared repo_url) simplifies future enhancements and debugging.

@UltralyticsAssistant UltralyticsAssistant added the enhancement New feature or request label Nov 22, 2025
@UltralyticsAssistant
Copy link
Member

👋 Hello @glenn-jocher, thank you for submitting a ultralytics/mkdocs 🚀 PR! This is an automated review assistant, and a human engineer will follow up to help finalize and merge as appropriate.

  • Define a Purpose: Clearly explain the purpose of your fix or feature in your PR description, and link to any relevant issues. Ensure your commit messages are clear, concise, and adhere to the project's conventions.
  • Synchronize with Source: Confirm your PR is synchronized with the ultralytics/mkdocs main branch. If it's behind, update it by clicking the 'Update branch' button or by running git pull and git merge main locally.
  • Ensure CI Checks Pass: Verify all Ultralytics Continuous Integration (CI) checks are passing. If any checks fail, please address the issues.
  • Update Documentation: Update the relevant documentation for any new or modified features.
  • Add Tests: If applicable, include or update tests to cover your changes, and confirm that all tests are passing.
  • Sign the CLA: Please ensure you have signed our Contributor License Agreement if this is your first Ultralytics PR by writing "I have read the CLA Document and I sign the CLA" in a new message.
  • Minimize Changes: Limit your changes to the minimum necessary for your bug fix or feature addition. "It is not daily increase but daily decrease, hack away the unessential. The closer to the source, the less wastage there is." — Bruce Lee

For more guidance, please refer to our Contributing Guide. Don't hesitate to leave a comment if you have any questions. Thank you for contributing to Ultralytics! 🚀

Copy link
Member

@UltralyticsAssistant UltralyticsAssistant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 PR Review

Made with ❤️ by Ultralytics Actions

Main blocker: postprocess_site() references processor.build_git_cache, which doesn’t exist and will crash as soon as authors or JSON‑LD are enabled. Additionally, get_git_info() no longer falls back to direct git queries when the cache misses, so git metadata disappears whenever git_data isn’t populated. Both issues need fixing to keep the plugin functional.

💬 Posted 2 inline comments

@glenn-jocher glenn-jocher changed the title Refactor for single git call Single git call for authors and dates Nov 22, 2025
Copy link
Member

@UltralyticsAssistant UltralyticsAssistant left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 PR Review 2

Made with ❤️ by Ultralytics Actions

Please restore the legacy git fallback in get_git_info so standalone consumers still receive real timestamps/authors, and bump the TQDM progress bar per file so the post-process feedback remains accurate.

💬 Posted 2 inline comments

Signed-off-by: Glenn Jocher <glenn.jocher@ultralytics.com>
@glenn-jocher glenn-jocher merged commit dcbd0d4 into main Nov 22, 2025
1 check passed
@glenn-jocher glenn-jocher deleted the tqdm branch November 22, 2025 14:28
@UltralyticsAssistant
Copy link
Member

Absolutely awesome to see this merged, @glenn-jocher — a huge quality-of-life and performance win for the MkDocs plugin. 🚀

“Great things are done by a series of small things brought together.” – Vincent van Gogh

Centralizing git metadata handling, optimizing author and JSON-LD generation, and tightening the logging flow are exactly those “small things” that compound into a faster, more reliable, and more maintainable docs pipeline for everyone using Ultralytics tooling and Ultralytics HUB.

Thank you for pushing the plugin forward with such a thoughtful, performance-focused refactor and for setting a high bar for future improvements. 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants