@@ -36,6 +36,37 @@ function Get-DefaultBranch {
36
36
[BranchInfo ]::new($shaPattern.Match ($output ).Value, $branchPattern.Match ($output ).Value)
37
37
}
38
38
39
+ function Get-OutdatedRemotes {
40
+ [CmdletBinding ()]
41
+ param (
42
+ [Parameter (Mandatory = $true , Position = 0 )]
43
+ $project ,
44
+
45
+ [Parameter (Mandatory = $true , Position = 1 )]
46
+ $masterBranch
47
+ )
48
+
49
+ $project.dst | ? {
50
+ $remoteName = $_.name
51
+ $remoteUrl = $_.url
52
+
53
+ Write-Host " `t $remoteName " - ForegroundColor Cyan - NoNewline
54
+ $branchRemote = Get-DefaultBranch $remoteUrl
55
+
56
+ if ($branchRemote.SHA -eq $masterBranch.SHA ) {
57
+ Write-Host " [OK]" - ForegroundColor Green
58
+ }
59
+ else {
60
+ Write-Host " [MISSMATCH]" - ForegroundColor Red
61
+ Write-Host " Master SHA: $ ( $masterBranch.SHA ) " - ForegroundColor Yellow
62
+ Write-Host " Remote SHA: $ ( $branchRemote.SHA ) " - ForegroundColor Yellow
63
+ $_
64
+ }
65
+ }
66
+
67
+
68
+ }
69
+
39
70
Clear-Host
40
71
$configuration = Get-Content - Raw - Path .\config.json | ConvertFrom-Json
41
72
$rootDirectoryPath = Get-CurrentLocation
@@ -51,6 +82,7 @@ $configuration.projects | % {
51
82
52
83
$sha = $_.sha
53
84
$branch = Get-DefaultBranch $_.url
85
+ # deprecated - SHA validation will be done against the master branch and remotes
54
86
if (! [string ]::IsNullOrWhiteSpace($sha )) {
55
87
if ($sha -eq $branch.SHA ) {
56
88
Write-Host " Validating SHA [OK]"
@@ -62,6 +94,14 @@ $configuration.projects | % {
62
94
Write-Host " Config SHA: $sha " - ForegroundColor Yellow
63
95
}
64
96
}
97
+ # end deprecated
98
+
99
+ Write-Host " Getting outdated remotes" - ForegroundColor Yellow
100
+ $remotes = Get-OutdatedRemotes - Project $_ - MasterBranch $branch
101
+ if (! $remotes ) {
102
+ Write-Host " No remotes to update" - ForegroundColor Green
103
+ return
104
+ }
65
105
66
106
$repoPath = Join-Path $rootDirectoryPath $_.name
67
107
if (Test-Path $repoPath ) {
@@ -96,7 +136,7 @@ $configuration.projects | % {
96
136
Write-Host " Current Location $ ( Get-CurrentLocation ) " - ForegroundColor Gray
97
137
98
138
Write-Host " Validating remotes" - ForegroundColor Cyan
99
- $_ .dst | % {
139
+ $remotes | % {
100
140
$remoteName = $_.name
101
141
$remoteUrl = $_.url
102
142
Write-Host " `t $remoteName " - ForegroundColor Cyan - NoNewline
0 commit comments