Open DavidKalina opened 6 months ago
sequenceDiagram
participant Developer as Developer
participant Git as Git
participant Script as TypeScript Script
participant Server as Analysis Server
Developer->>Git: Attempt commit
Note over Git: Pre-commit hook triggers
Git->>Script: Capture pre-commit data
Script->>Script: Process (optional)
Script->>Git: Allow commit
Note over Git: Commit successful
Note over Git: Post-commit hook triggers
Git->>Script: Send commit data
Script->>Script: Format commit data
Script->>Server: Transmit data securely
Note over Server: Analyze commit
Server-->>Script: Acknowledgment
Script-->>Developer: Show success/failure message
Overview
This script integrates with Git's pre-commit and post-commit hooks to capture and transmit commit information to a remote server for analysis. It requires a Node.js environment and TypeScript for development.
Requirements
Node.js: Latest LTS version highly recommended. TypeScript: A recent version that aligns with your Node.js installation. Git: Version 2.x or higher.
Functionality
Pre-commit Hook Integration: Intercepts commit attempts and can optionally run checks or preprocessing tasks before the commit proceeds.
Post-commit Hook Integration: Gathers commit data: commit message, author details, diff output. Transmits data to the designated server endpoint.
Data Handling: Structures captured data (likely as JSON). Secure HTTPS transmission with error handling.
Inputs
Outputs
Success/Failure Acknowledgement: Console output on transmission status. Error Messages: Detailed logs for troubleshooting (network issues, server-side problems, etc.).
Error Handling
Graceful error handling and logging, preventing interruptions to the Git workflow (unless explicitly desired). Configurable retries for network/server errors, with either silent failure or user notification after exceeding the retry limit.
Configuration
Security Considerations
Development Steps
Future Enhancements