trim trailing spaces

This commit is contained in:
David Refoua 2022-10-15 12:46:13 +03:30
parent 23edc8036f
commit abbab3f8b4
10 changed files with 34 additions and 45 deletions

View File

@ -66,33 +66,26 @@ function Digest-Hash($path) {
} }
function Get-VersionStr() { function Get-VersionStr() {
# Clear existing variable # Clear existing variable
if ($string) { Clear-Variable -name string } if ($string) { Clear-Variable -name string }
# Determine if git is available # Determine if git is available
if (Get-Command "git.exe" -ErrorAction SilentlyContinue) if (Get-Command "git.exe" -ErrorAction SilentlyContinue) {
{
# Determine if the current diesctory is a git repository # Determine if the current diesctory is a git repository
$GitPresent = Invoke-Expression "git rev-parse --is-inside-work-tree" -erroraction SilentlyContinue $GitPresent = Invoke-Expression "git rev-parse --is-inside-work-tree" -erroraction SilentlyContinue
if ( $GitPresent -eq 'true' ) if ( $GitPresent -eq 'true' ) {
{
$string = Invoke-Expression "git describe --abbrev=0 --tags" $string = Invoke-Expression "git describe --abbrev=0 --tags"
} }
} }
# Fallback used when Git is not available # Fallback used when Git is not available
if ( -not($string) ) if ( -not($string) ) {
{
$string = Parse-Changelog ($PSScriptRoot + '\..\' + 'CHANGELOG.md') $string = Parse-Changelog ($PSScriptRoot + '\..\' + 'CHANGELOG.md')
} }
# Add build number, if AppVeyor is present # Add build number, if AppVeyor is present
if ( $Env:APPVEYOR -eq 'True' ) if ( $Env:APPVEYOR -eq 'True' ) {
{
$string = $string + '.' + $Env:APPVEYOR_BUILD_NUMBER $string = $string + '.' + $Env:APPVEYOR_BUILD_NUMBER
} }
@ -100,11 +93,9 @@ function Get-VersionStr() {
$string = $string -replace '^v+','' # normalize version string $string = $string -replace '^v+','' # normalize version string
return $string return $string
} }
function Parse-Changelog($file) { function Parse-Changelog($file) {
# Define the regular expression to match the version string from changelog # Define the regular expression to match the version string from changelog
[regex]$regex = '^## \[(?<version>[\w\-\.]+)\]\([^\n()]+\)\s+\([^\n()]+\)$'; [regex]$regex = '^## \[(?<version>[\w\-\.]+)\]\([^\n()]+\)\s+\([^\n()]+\)$';
@ -115,7 +106,6 @@ function Parse-Changelog($file) {
} }
function Create-RC($string, $path) { function Create-RC($string, $path) {
$version = $string + '.0.0.0.0' # padding for version string $version = $string + '.0.0.0.0' # padding for version string
if ( !(Test-Path "$path.sample") ) { if ( !(Test-Path "$path.sample") ) {
@ -141,7 +131,6 @@ function Create-RC($string, $path) {
# Write the results # Write the results
Set-Content -Path $path -Value $resource Set-Content -Path $path -Value $resource
} }
function Register-Cmder() { function Register-Cmder() {
@ -210,7 +199,7 @@ function Download-File {
Write-Verbose "Downloading from $Url to $File" Write-Verbose "Downloading from $Url to $File"
$wc = New-Object System.Net.WebClient $wc = New-Object System.Net.WebClient
if ($env:https_proxy) { if ($env:https_proxy) {
$wc.proxy = (New-Object System.Net.WebProxy($env:https_proxy)) $wc.proxy = (New-Object System.Net.WebProxy($env:https_proxy))
} }
$wc.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials; $wc.Proxy.Credentials=[System.Net.CredentialCache]::DefaultNetworkCredentials;
$wc.DownloadFile($Url, $File) $wc.DownloadFile($Url, $File)