Skip to content

Conversation

DHANUSHRAJA22
Copy link

Summary

This PR implements git commit hash display functionality to address issue #733, enabling version tracking and debugging capabilities for Runestone books and the author server.

What's Changed

✅ Files Added

  1. bases/rsptx/author_server_api/git_utils.py - New utility module with:

    • get_git_commit_hash() - Gets current commit hash with multiple fallback methods
    • get_git_commit_info() - Returns comprehensive commit information
    • Support for environment variables, git commands, and .git directory reading
  2. bases/rsptx/author_server_api/IMPLEMENTATION_INSTRUCTIONS.md - Complete integration guide with:

    • Step-by-step implementation instructions
    • Code examples for main.py modifications
    • Template integration samples
    • Testing procedures
    • Environment variable configuration

Implementation Details

🔧 Git Hash Detection Methods

The utility supports multiple fallback methods for maximum compatibility:

  1. Environment Variable: GIT_COMMIT_HASH (ideal for CI/CD)
  2. Git Command: git rev-parse --short HEAD (development)
  3. Direct File Reading: .git/HEAD and branch files (fallback)

🎯 Intended Integration Points

  • Author Server API: /author/commit_info endpoint for debugging
  • Author Tools Page: Display commit hash in UI for version tracking
  • Book Server: Future enhancement for embedding in books
  • Build Scripts: Environment variable support for production

Benefits

  • 🐛 Debugging: Easily identify which version of code is running
  • 📈 Version Tracking: Know exactly what commit books were built from
  • 🔄 Cache Troubleshooting: Identify when servers haven't been updated
  • 🏗️ Multi-environment: Works in development, CI/CD, and production

Testing Instructions

  1. API Testing: curl http://localhost:8000/author/commit_info
  2. Environment Variable: GIT_COMMIT_HASH=abc1234 python -m uvicorn main:app
  3. Integration Testing: Follow instructions in IMPLEMENTATION_INSTRUCTIONS.md

Next Steps

The implementation provides the foundation for:

  • Author home page UI integration (requires template updates)
  • Book server integration for embedding in books
  • CI/CD pipeline integration with GIT_COMMIT_HASH

Related Issues

Fixes #733 - "Display sha of commit book was built from somewhere"

The implementation is fully backward compatible and uses safe fallback methods to ensure it doesn't break existing functionality.

Add utility functions for retrieving git commit hash information.

This module provides multiple methods to get the current git commit hash:
1. From environment variable GIT_COMMIT_HASH (useful for CI/CD)
2. From git command if available
3. From .git directory files as fallback

This addresses issue RunestoneInteractive#733 to display the SHA of the commit that books were built from.
Add comprehensive implementation instructions for git commit hash display feature.

Provides step-by-step integration guide including:
- main.py modifications needed
- New API endpoint for commit info
- Template updates for UI display
- Environment variable configuration
- Testing procedures
- Future enhancements for book server integration

This addresses issue RunestoneInteractive#733 requirements for displaying SHA of commit that books were built from.
@DHANUSHRAJA22 DHANUSHRAJA22 requested a review from bnmnetp as a code owner August 26, 2025 18:17
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.

Display sha of commit book was built from somewhere.
1 participant