-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathUpdateRepo_TEMPLATE.ps1
More file actions
95 lines (77 loc) · 4.21 KB
/
UpdateRepo_TEMPLATE.ps1
File metadata and controls
95 lines (77 loc) · 4.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<#
.SYNOPSIS
Updates or clones a specific repository by calling UpdateOrCloneRepository.ps1
with parameters set through global variables.
.DESCRIPTION
This script defines a set of variables named with the 'CurrentRepo_' prefix in
the same order as UpdateOrCloneRepository.ps1 parameters. Then, it invokes
UpdateOrCloneRepository.ps1 *without* passing parameters, relying on
-DefaultFromVars to pick up the values from these global variables.
When repository directory is specified as relative path, path is
resolved with the script directory as base path.
.NOTES
Make sure UpdateOrCloneRepository.ps1 is accessible at the path specified in
$UpdatingScriptPath (absolute or relative).
#>
Write-Host "`n`n======================================================="
Write-Host "Updating/cloning a specific repository..."
########################################################################
# Custom section (USER DEFINED):
# Path to UpdateOrCloneRepository.ps1
$UpdatingScriptPath = "./UpdateOrCloneRepository.ps1"
# Define parameter variables for UpdateOrCloneRepository.ps1
# in the same order as that script's parameters:
$global:CurrentRepo_Directory = ""
$global:CurrentRepo_Ref = $null # "main"
$global:CurrentRepo_Address = ""
$global:CurrentRepo_Remote = "origin"
$global:CurrentRepo_AddressSecondary = $null
$global:CurrentRepo_RemoteSecondary = $null
$global:CurrentRepo_AddressTertiary = "d:\backup_sync\bk_code\git\ig\misc\iglib_modules\IGLibScripts\"
$global:CurrentRepo_RemoteTertiary = "local"
$global:CurrentRepo_ThrowOnErrors = $false
# End of custom section
########################################################################
# $global:CurrentRepo_DefaultFromVars = $true # params set from variables above
$global:CurrentRepo_BaseDirectory = $null # base dir will be set to script dir
# Set CurrentRepo_BaseDirectory to the directory containing this script:
$scriptPath = $MyInvocation.MyCommand.Path
$scriptDir = Split-Path $scriptPath -Parent
# $scriptFilename = [System.IO.Path]::GetFileName($scriptPath)
# Set base directory for relative paths to the current script's directory:
$global:CurrentRepo_BaseDirectory = $scriptDir
# If $UpdatingScriptPath is a relative path, convert it to absolute
if (-not [System.IO.Path]::IsPathRooted($UpdatingScriptPath)) {
$UpdatingScriptPath = Join-Path $scriptDir $UpdatingScriptPath
}
# Write-Host "`n${scriptFilename}:"
# Write-Host " CurrentRepo_Directory: $CurrentRepo_Directory"
# Write-Host " CurrentRepo_Address: $CurrentRepo_Address"
# Write-Host " CurrentRepo_Ref: $CurrentRepo_Ref"
# # Write-Host " UpdatingScriptPath: $UpdatingScriptPath"
# # Write-Host " CurrentRepo_BaseDirectory: $CurrentRepo_BaseDirectory `n"
# Print all variables used as settings for updating / cloning repositories:
Write-Host "-------------------------------------------------------"
Write-Host "Variables for repository updating / cloning scripts:"
Write-Host " CurrentRepo_Directory: $CurrentRepo_Directory"
Write-Host " CurrentRepo_Ref: $CurrentRepo_Ref"
Write-Host " CurrentRepo_Address: $CurrentRepo_Address"
Write-Host " CurrentRepo_Remote: $CurrentRepo_Remote"
Write-Host " CurrentRepo_AddressSecondary: $CurrentRepo_AddressSecondary"
Write-Host " CurrentRepo_RemoteSecondary: $CurrentRepo_RemoteSecondary"
Write-Host " CurrentRepo_AddressTertiary: $CurrentRepo_AddressTertiary"
Write-Host " CurrentRepo_RemoteTertiary: $CurrentRepo_RemoteTertiary"
Write-Host " CurrentRepo_ThrowOnErrors: $CurrentRepo_ThrowOnErrors"
#
Write-Host " CurrentRepo_DefaultFromVars: $CurrentRepo_DefaultFromVars"
Write-Host " CurrentRepo_BaseDirectory : $CurrentRepo_BaseDirectory"
#
Write-Host "---------------------------------------------------------"
# # Uncomment the line below only when the print script exists!
# & (Join-Path $scriptDir PrintSettingsUpdateOrClone.ps1)
# Invoke UpdateOrCloneRepository.ps1 with no parameters,
# so it uses the global variables defined above:
Write-Host "`nCalling update script without parameters; it will use global variables..."
& $UpdatingScriptPath -Execute -DefaultFromVars
Write-Host "`nUpdating or cloning the repository completed."
Write-Host "---------------------------------------------------------`n`n"