Skip to content

Commit 16fc5db

Browse files
committed
feat: Add post-checkout script execution support (#7)
Implement PowerShell script execution after successful repository checkouts to enable integration with external dependency management systems. Features: - Post-checkout script configuration via "Post-Checkout Script File Name" and "Post-Checkout Script File Path" fields in dependency files - Scripts execute only after actual checkouts (new clones or tag changes) - Environment variables provide checkout context (URL, path, tag, version) - New object format for dependency files while maintaining legacy array compatibility - -DisablePostCheckoutScripts parameter to disable script execution - 5-minute timeout protection with comprehensive error handling - Script execution statistics in summary reports Configuration example: ```json { "Post-Checkout Script File Name": "setup-environment.ps1", "Post-Checkout Script File Path": "scripts/build", "Repositories": [...] } ``` Benefits: - Seamless integration with npm, NuGet, pip, and other package managers - Automated build environment setup after repository checkout - Support for custom workflows like security scanning and compliance checks - Enhanced automation for CI/CD pipelines - Maintains full backward compatibility with existing dependency files Breaking Changes: None - All existing dependency files continue to work without modification - Legacy array format fully supported alongside new object format - Post-checkout scripts are optional and disabled via command line parameter Closes #7
1 parent a85e608 commit 16fc5db

5 files changed

Lines changed: 1112 additions & 24 deletions

File tree

CHANGELOG.md

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,109 @@ All notable changes to LsiGitCheckout will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [6.2.0] - 2025-01-24
9+
10+
### Added
11+
- **Post-Checkout Script Execution**: Added support for executing PowerShell scripts after successful repository checkouts
12+
- **New JSON Object Format**: Enhanced dependency file format with top-level configuration options while maintaining full backward compatibility with legacy array format
13+
- **Post-Checkout Script File Name**: Optional field to specify PowerShell script name for execution after checkout
14+
- **Post-Checkout Script File Path**: Optional field to specify subdirectory within repository where post-checkout script is located
15+
- **Script Execution Context**: Environment variables provided to scripts (`LSIGIT_REPOSITORY_URL`, `LSIGIT_REPOSITORY_PATH`, `LSIGIT_TAG`, `LSIGIT_SCRIPT_VERSION`)
16+
- **-DisablePostCheckoutScripts Parameter**: Command line option to disable post-checkout script execution
17+
- **Script Timeout Protection**: Automatic termination of scripts that exceed 5-minute execution limit
18+
- **Comprehensive Script Logging**: Detailed logging of script discovery, execution, and results
19+
- **Script Execution Statistics**: Summary reporting of script executions and failures
20+
- **External Integration Support**: Enable integration with npm, NuGet, pip, and other dependency management systems via post-checkout scripts
21+
22+
### Changed
23+
- **Enhanced JSON Format Support**: Now supports both new object format (`{"Repositories": [...]}`) and legacy array format (`[...]`)
24+
- **Improved Repository Processing**: Post-checkout scripts execute for the repository containing the dependency file configuration, not for individual repositories listed in the dependency file
25+
- **Extended Summary Reporting**: Added post-checkout script execution statistics to summary output
26+
- **Enhanced Debug Logging**: More detailed logging for script discovery, execution timing, and error handling
27+
- **Refined Execution Context**: Scripts execute with repository root as working directory and receive rich context via environment variables
28+
29+
### Fixed
30+
- **Script Execution Isolation**: Each post-checkout script runs in its own PowerShell process with proper environment cleanup
31+
- **Error Handling Robustness**: Script failures are logged but don't affect repository checkout success status
32+
- **Working Directory Management**: Ensures scripts always execute from the correct repository root directory
33+
34+
### Benefits
35+
- **Multi-System Integration**: Seamlessly integrate LsiGitCheckout with existing package managers and build systems
36+
- **Automated Setup**: Automatically configure development environments after repository checkout
37+
- **Flexible Extensibility**: Support for custom post-checkout workflows via PowerShell scripting
38+
- **Zero Breaking Changes**: All existing dependency files continue to work without modification
39+
- **Enhanced Observability**: Comprehensive logging and statistics for script execution monitoring
40+
- **Security Controls**: Scripts can be disabled entirely via command line parameter for untrusted environments
41+
42+
### Configuration Examples
43+
44+
#### New Object Format with Post-Checkout Scripts
45+
```json
46+
{
47+
"Post-Checkout Script File Name": "setup-environment.ps1",
48+
"Post-Checkout Script File Path": "scripts/build",
49+
"Repositories": [
50+
{
51+
"Repository URL": "https://github.com/myorg/project.git",
52+
"Base Path": "repos/project",
53+
"Tag": "v1.0.0"
54+
}
55+
]
56+
}
57+
```
58+
59+
#### Legacy Array Format (Fully Compatible)
60+
```json
61+
[
62+
{
63+
"Repository URL": "https://github.com/myorg/project.git",
64+
"Base Path": "repos/project",
65+
"Tag": "v1.0.0"
66+
}
67+
]
68+
```
69+
70+
#### Example Post-Checkout Script
71+
```powershell
72+
# setup-environment.ps1
73+
Write-Host "Setting up environment for $env:LSIGIT_REPOSITORY_URL at tag $env:LSIGIT_TAG"
74+
75+
# Install npm dependencies
76+
if (Test-Path "package.json") {
77+
npm install
78+
}
79+
80+
# Restore NuGet packages
81+
if (Test-Path "*.csproj") {
82+
dotnet restore
83+
}
84+
85+
Write-Host "Environment setup completed for $env:LSIGIT_REPOSITORY_PATH"
86+
```
87+
88+
### Technical Implementation
89+
- Post-checkout script configuration applies to all repositories in a dependency file
90+
- Scripts execute only after successful repository checkouts (clone or tag change)
91+
- Environment variables provide script context about the checkout operation
92+
- Scripts run with 5-minute timeout protection and comprehensive error handling
93+
- Script execution is fully optional and can be disabled via command line parameter
94+
- Legacy array format maintains 100% backward compatibility
95+
- Enhanced JSON parsing supports both object and array root formats
96+
97+
### Migration Notes
98+
- **Zero configuration changes required**: All existing dependency files work without modification
99+
- **Optional enhancement**: Convert to object format to add post-checkout scripts
100+
- **Gradual adoption**: Add post-checkout scripts to repositories as needed
101+
- **Full compatibility**: Legacy array format support preserved indefinitely
102+
- **Enhanced integration**: Use post-checkout scripts to integrate with existing build and dependency management systems
103+
104+
### Use Cases
105+
- **Package Manager Integration**: Automatically run `npm install`, `dotnet restore`, `pip install`, etc.
106+
- **Build Environment Setup**: Configure development environments after checkout
107+
- **License and Security Scanning**: Run automated compliance checks on checked-out code
108+
- **Custom Initialization**: Execute project-specific setup procedures
109+
- **Multi-System Orchestration**: Coordinate between LsiGitCheckout and other tools
110+
8111
## [6.1.0] - 2025-01-24
9112

10113
### Added

0 commit comments

Comments
 (0)