|
15 | 15 | eliminating the need for manual temporal ordering in "API Compatible Tags". |
16 | 16 | |
17 | 17 | Post-checkout PowerShell scripts can be executed after successful repository |
18 | | - checkouts to integrate with external dependency management systems. |
| 18 | + checkouts to integrate with external dependency management systems. Scripts |
| 19 | + can be configured at any depth level, including depth 0 (root level). |
19 | 20 | .PARAMETER InputFile |
20 | 21 | Path to the JSON configuration file. Defaults to 'dependencies.json' in the script directory. |
21 | 22 | .PARAMETER CredentialsFile |
|
41 | 42 | .\LsiGitCheckout.ps1 -InputFile "repos.json" -EnableDebug -ApiCompatibility Strict |
42 | 43 | .\LsiGitCheckout.ps1 -Verbose -DisablePostCheckoutScripts |
43 | 44 | .NOTES |
44 | | - Version: 6.2.0 |
45 | | - Last Modified: 2025-01-24 |
| 45 | + Version: 6.2.1 |
| 46 | + Last Modified: 2025-01-27 |
46 | 47 | |
47 | 48 | This script uses PuTTY/plink for SSH authentication. SSH keys must be in PuTTY format (.ppk). |
48 | 49 | Use PuTTYgen to convert OpenSSH keys to PuTTY format if needed. |
49 | 50 | |
| 51 | + Changes in 6.2.1: |
| 52 | + - Added support for post-checkout scripts at depth 0 (root level) when configured in the input dependency file |
| 53 | + - Post-checkout scripts can now be configured in the main input dependency file and execute before processing repositories |
| 54 | + - At depth 0, environment variables are provided as empty strings (except LSIGIT_SCRIPT_VERSION) |
| 55 | + - Script path construction at depth 0 uses the input dependency file location as the base path |
| 56 | + |
50 | 57 | Changes in 6.2.0: |
51 | 58 | - Added support for post-checkout PowerShell script execution |
52 | 59 | - New "Post-Checkout Script File Name" and "Post-Checkout Script File Path" configuration options |
@@ -130,7 +137,7 @@ param( |
130 | 137 | ) |
131 | 138 |
|
132 | 139 | # Script configuration |
133 | | -$script:Version = "6.2.0" |
| 140 | +$script:Version = "6.2.1" |
134 | 141 | $script:ScriptPath = Split-Path -Parent $MyInvocation.MyCommand.Path |
135 | 142 | $script:ErrorFile = Join-Path $ScriptPath "LsiGitCheckout_Errors.txt" |
136 | 143 | $script:DebugLogFile = Join-Path $ScriptPath ("debug_log_{0}.txt" -f (Get-Date -Format "yyyyMMddHHmm")) |
@@ -1662,33 +1669,47 @@ function Process-DependencyFile { |
1662 | 1669 | Write-Log "Post-checkout script configured: $postCheckoutScriptFileName" -Level Info |
1663 | 1670 | } |
1664 | 1671 |
|
1665 | | - # Execute post-checkout script for the repository that contains this dependency file |
1666 | | - # This should happen BEFORE processing the repositories listed in the dependency file |
1667 | | - if (-not [string]::IsNullOrWhiteSpace($postCheckoutScriptFileName) -and |
1668 | | - -not [string]::IsNullOrWhiteSpace($CallingRepositoryRootPath) -and |
1669 | | - $Depth -gt 0) { |
1670 | | - |
1671 | | - # Get the repository URL for the calling repository (the one containing the dependency file) |
1672 | | - $callingRepositoryUrl = "" |
1673 | | - $callingRepositoryTag = "" |
1674 | | - |
1675 | | - # Find the calling repository in our dictionary by matching the path |
1676 | | - foreach ($repoEntry in $script:RepositoryDictionary.GetEnumerator()) { |
1677 | | - if ($repoEntry.Value.AbsolutePath -eq $CallingRepositoryRootPath) { |
1678 | | - $callingRepositoryUrl = $repoEntry.Key |
1679 | | - $callingRepositoryTag = $repoEntry.Value.Tag |
1680 | | - break |
1681 | | - } |
1682 | | - } |
1683 | | - |
1684 | | - if (-not [string]::IsNullOrWhiteSpace($callingRepositoryUrl)) { |
1685 | | - Write-Log "Executing post-checkout script for repository containing dependency file: $callingRepositoryUrl" -Level Info |
1686 | | - $scriptResult = Invoke-PostCheckoutScript -RepoAbsolutePath $CallingRepositoryRootPath -ScriptFileName $postCheckoutScriptFileName -ScriptFilePath $postCheckoutScriptFilePath -RepositoryUrl $callingRepositoryUrl -Tag $callingRepositoryTag |
| 1672 | + # Execute post-checkout script for depth 0 (root level) or when processing nested dependencies |
| 1673 | + if (-not [string]::IsNullOrWhiteSpace($postCheckoutScriptFileName)) { |
| 1674 | + if ($Depth -eq 0) { |
| 1675 | + # Depth 0: Execute from input dependency file location with empty environment variables |
| 1676 | + Write-Log "Executing post-checkout script at depth 0 (root level)" -Level Info |
| 1677 | + |
| 1678 | + # For depth 0, use the directory containing the input dependency file as the base path |
| 1679 | + $inputFileDirectory = Split-Path -Parent (Resolve-Path $DependencyFilePath) |
| 1680 | + Write-Log "Using input dependency file directory as base path for depth 0: $inputFileDirectory" -Level Debug |
| 1681 | + |
| 1682 | + # Execute script with empty environment variables (except LSIGIT_SCRIPT_VERSION) |
| 1683 | + $scriptResult = Invoke-PostCheckoutScript -RepoAbsolutePath $inputFileDirectory -ScriptFileName $postCheckoutScriptFileName -ScriptFilePath $postCheckoutScriptFilePath -RepositoryUrl "" -Tag "" |
1687 | 1684 | if (-not $scriptResult) { |
1688 | | - Write-Log "Post-checkout script failed for repository '$callingRepositoryUrl', but continuing with dependency processing" -Level Warning |
| 1685 | + Write-Log "Post-checkout script failed at depth 0, but continuing with repository processing" -Level Warning |
| 1686 | + } |
| 1687 | + } elseif ($Depth -gt 0 -and -not [string]::IsNullOrWhiteSpace($CallingRepositoryRootPath)) { |
| 1688 | + # Depth > 0: Execute for the repository containing the dependency file |
| 1689 | + Write-Log "Executing post-checkout script for repository containing dependency file at depth $Depth" -Level Info |
| 1690 | + |
| 1691 | + # Get the repository URL for the calling repository (the one containing the dependency file) |
| 1692 | + $callingRepositoryUrl = "" |
| 1693 | + $callingRepositoryTag = "" |
| 1694 | + |
| 1695 | + # Find the calling repository in our dictionary by matching the path |
| 1696 | + foreach ($repoEntry in $script:RepositoryDictionary.GetEnumerator()) { |
| 1697 | + if ($repoEntry.Value.AbsolutePath -eq $CallingRepositoryRootPath) { |
| 1698 | + $callingRepositoryUrl = $repoEntry.Key |
| 1699 | + $callingRepositoryTag = $repoEntry.Value.Tag |
| 1700 | + break |
| 1701 | + } |
| 1702 | + } |
| 1703 | + |
| 1704 | + if (-not [string]::IsNullOrWhiteSpace($callingRepositoryUrl)) { |
| 1705 | + Write-Log "Executing post-checkout script for repository containing dependency file: $callingRepositoryUrl" -Level Info |
| 1706 | + $scriptResult = Invoke-PostCheckoutScript -RepoAbsolutePath $CallingRepositoryRootPath -ScriptFileName $postCheckoutScriptFileName -ScriptFilePath $postCheckoutScriptFilePath -RepositoryUrl $callingRepositoryUrl -Tag $callingRepositoryTag |
| 1707 | + if (-not $scriptResult) { |
| 1708 | + Write-Log "Post-checkout script failed for repository '$callingRepositoryUrl', but continuing with dependency processing" -Level Warning |
| 1709 | + } |
| 1710 | + } else { |
| 1711 | + Write-Log "Could not determine repository URL for calling repository at path: $CallingRepositoryRootPath" -Level Warning |
1689 | 1712 | } |
1690 | | - } else { |
1691 | | - Write-Log "Could not determine repository URL for calling repository at path: $CallingRepositoryRootPath" -Level Warning |
1692 | 1713 | } |
1693 | 1714 | } |
1694 | 1715 |
|
@@ -1885,8 +1906,6 @@ Failed: $($script:FailureCount) |
1885 | 1906 | } |
1886 | 1907 | } |
1887 | 1908 |
|
1888 | | - $summary += "`nTag Temporal Sorting: Always Enabled" |
1889 | | - |
1890 | 1909 | # Show post-checkout script statistics |
1891 | 1910 | if ($script:PostCheckoutScriptsEnabled) { |
1892 | 1911 | $summary += "`nPost-Checkout Scripts: Enabled" |
|
0 commit comments