From 6465a6f16dc8ed35d3aedc58151933e13dc07e83 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 31 Aug 2020 09:31:14 -0400 Subject: [PATCH 1/2] - fixes an issue where maven version would not be compared --- Scripts/validateMavenVersion.ps1 | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Scripts/validateMavenVersion.ps1 b/Scripts/validateMavenVersion.ps1 index f591d5e1e..cd8bc67ed 100644 --- a/Scripts/validateMavenVersion.ps1 +++ b/Scripts/validateMavenVersion.ps1 @@ -9,23 +9,22 @@ Retrieves the local, Maven, and Bintray versions of the Java-Core build. Checks that the Maven and Bintray versions are aligned, trigger warning if not. Checks that the current local version is greater than those currently deployed. +.Parameter propertiesPath #> -.Parameter packageName -.Parameter propertiesPath Param( - [parameter(Mandatory = $true)] - [string]$packageName, - - [parameter(Mandatory = $true)] [string]$propertiesPath ) #Find the local version from the Gradle.Properties file +if($propertiesPath -eq "" || $null -eq $propertiesPath) { + $propertiesPath = Join-Path -Path $PSScriptRoot -ChildPath "../gradle.properties" +} $file = get-item $propertiesPath $findLocalVersions = $file | Select-String -Pattern "mavenMajorVersion" -Context 0,2 $findLocalVersions = $findLocalVersions -split "`r`n" +$packageName = ($file | Select-String -Pattern "mavenArtifactId").Line.Split("=")[1].Trim() $localMajor = $findLocalVersions[0].Substring($findLocalVersions[0].Length-1) $localMinor = $findLocalVersions[1].Substring($findLocalVersions[1].Length-1) @@ -60,7 +59,7 @@ if($mavenVersion -ne $bintrayVersion){ Write-Warning "The current Maven and Bintray versions are not the same" } #Success if Local version has been updated, Error otherwise. -if($localVersion -gt $bintrayVersion){ +if($localVersion -gt $bintrayVersion && $localVersion -gt $mavenVersion){ Write-Host "The current pull request is of a greater version" } else{ From 81569a5c32d0edd76a49ae20804733aa72bc4edc Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Mon, 31 Aug 2020 11:21:43 -0400 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: Mustafa Zengin --- Scripts/validateMavenVersion.ps1 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Scripts/validateMavenVersion.ps1 b/Scripts/validateMavenVersion.ps1 index cd8bc67ed..da1742bd2 100644 --- a/Scripts/validateMavenVersion.ps1 +++ b/Scripts/validateMavenVersion.ps1 @@ -18,7 +18,7 @@ Param( ) #Find the local version from the Gradle.Properties file -if($propertiesPath -eq "" || $null -eq $propertiesPath) { +if($propertiesPath -eq "" -or $null -eq $propertiesPath) { $propertiesPath = Join-Path -Path $PSScriptRoot -ChildPath "../gradle.properties" } $file = get-item $propertiesPath @@ -59,9 +59,9 @@ if($mavenVersion -ne $bintrayVersion){ Write-Warning "The current Maven and Bintray versions are not the same" } #Success if Local version has been updated, Error otherwise. -if($localVersion -gt $bintrayVersion && $localVersion -gt $mavenVersion){ +if($localVersion -gt $bintrayVersion -and $localVersion -gt $mavenVersion){ Write-Host "The current pull request is of a greater version" } else{ Write-Error "The current local version is not updated. Please update the local version in the Gradle.Properties file." -} \ No newline at end of file +}