Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# List of whitespace-only commits to ignore in the Git blame;
# to improve tracking changes and avoid noise
58db4e3419bf1e5cc1bb61fcd7ce2ebbca89243a
efb3338f5cf0eec21e8a75abc62ee14965cb4a7e
3859f6ffc088b2ae78748abc84986f4adcadcd41
d6569192fc91167f555c3eff58402ff01f1197ea
67de97a492c9389f95499db38f9474a1c20ec585
a0d085f93eaa69c22449d0217e8daf9eaea2b180
1cfba25beb46c74bb1debca2bcfe7ac470e96172
f6bc623284914489e891bbac923feb774c862b99
abbab3f8b477e917d0a175d0de23cce121096631
126347025f9cade241beff182738b2527da7535e
4740b836f300658b27e6ad4d79efac63c9c24c24
be44bac95670b1cbbc91bd657882d985989846f9
f67e5704eda60526d495be758572181f01a6cac8
928bdfc3b80675e745a1a6642c3636e66d1c6071
4 changes: 4 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ jobs:
with:
fetch-depth: 0

- name: Check trailing whitespace
shell: pwsh
run: .\scripts\check-trailing-whitespace.ps1

- name: Summary - Test execution started
shell: pwsh
run: |
Expand Down
4 changes: 2 additions & 2 deletions scripts/build.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ if (-not $noVendor) {

# Kill ssh-agent.exe if it is running from the $env:cmder_root we are building
foreach ($ssh_agent in $(Get-Process ssh-agent -ErrorAction SilentlyContinue)) {
if ([string]$($ssh_agent.path) -Match [string]$cmder_root.replace('\', '\\')) {
if ([string]$($ssh_agent.path) -match [string]$cmder_root.replace('\', '\\')) {
Write-Verbose $("Stopping " + $ssh_agent.path + "!")
Stop-Process $ssh_agent.id
}
Expand Down Expand Up @@ -178,4 +178,4 @@ if ( $Env:GITHUB_ACTIONS -eq 'true' ) {
Write-Output "::notice title=Build Complete::Building Cmder v$version was successful."
}

Write-Host -ForegroundColor green "All good and done!"
Write-ColorOutput -ForegroundColor Green -Message "All good and done!"
56 changes: 56 additions & 0 deletions scripts/check-trailing-whitespace.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
[CmdletBinding()]
param()

Set-StrictMode -Version Latest
$ErrorActionPreference = "Stop"

$extensions = @(
'.ps1',
'.psm1',
'.psd1',
'.cmd',
'.bat',
'.sh',
'.lua',
'.yml',
'.yaml',
'.json',
'.xml',
'.ini',
'.rc',
'.vcxproj',
'.filters',
'.props',
'.sln',
'.cpp',
'.c',
'.h',
'.hpp'
)

$files = @(
git ls-files |
Where-Object { $extensions -contains [System.IO.Path]::GetExtension($_).ToLowerInvariant() }
)

$findings = foreach ($file in $files) {
$lineNumber = 0
foreach ($line in Get-Content -LiteralPath $file) {
$lineNumber++
if ($line -match '[ \t]+$') {
[pscustomobject]@{
File = $file
Line = $lineNumber
}
}
}
}

if ($findings) {
Write-Error (
"Trailing whitespace found:`n" +
(($findings | ForEach-Object { "$($_.File):$($_.Line)" }) -join "`n")
)
}

Write-Output "No trailing whitespace found in checked files."
33 changes: 17 additions & 16 deletions scripts/update.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,31 +39,32 @@ Param(
[switch]$IncludePrerelease = $false
)

# Get the root directory of the cmder project.
$cmder_root = Resolve-Path "$PSScriptRoot\.."

# Dot source util functions into this scope
. "$PSScriptRoot\utils.ps1"
$ErrorActionPreference = "Stop"

# Attempts to match the current link with the new link, returning the count of matching characters.
function Match-Filenames {
function Compare-Filename {
param (
$url,
$downloadUrl,
$fromEnd
[Parameter(Mandatory = $true)]
[uri]$Url,

[Parameter(Mandatory = $true)]
[string]$DownloadUrl,

[bool]$FromEnd = $false
)

$filename = [System.IO.Path]::GetFileName($url)
$filenameDownload = [System.IO.Path]::GetFileName($downloadUrl)
$filename = [System.IO.Path]::GetFileName($Url)
$filenameDownload = [System.IO.Path]::GetFileName($DownloadUrl)

$position = 0

if ([String]::IsNullOrEmpty($filename) -or [String]::IsNullOrEmpty($filenameDownload)) {
throw "Either one or both filenames are empty!"
}

if ($fromEnd) {
if ($FromEnd) {
$arr = $filename -split ""
[array]::Reverse($arr)
$filename = $arr -join ''
Expand Down Expand Up @@ -229,14 +230,14 @@ function Fetch-DownloadUrl {
return ''
}

$temp = $downloadLinks | Where-Object { (Match-Filenames $url $_) -eq $charCount }
$temp = $downloadLinks | Where-Object { (Compare-Filename -Url $url -DownloadUrl $_) -eq $charCount }

$downloadLinks = (New-Object System.Collections.Generic.List[System.Object])

$charCount = 0

foreach ($l in $temp) {
$score = Match-Filenames $url $l true
$score = Compare-Filename -Url $url -DownloadUrl $l -FromEnd $true

if ( ($score -eq 0) -or ($score -lt $charCount) ) {
continue
Expand All @@ -245,7 +246,7 @@ function Fetch-DownloadUrl {
$charCount = $score
}

$downloadLinks = $temp | Where-Object { (Match-Filenames $url $_ true) -eq $charCount }
$downloadLinks = $temp | Where-Object { (Compare-Filename -Url $url -DownloadUrl $_ -FromEnd $true) -eq $charCount }

if (($null -eq $downloadLinks) -or (-not $downloadLinks)) {
throw "No suitable download links matched for the url!"
Expand Down Expand Up @@ -307,7 +308,7 @@ foreach ($s in $sources) {
# Analyze version change type using shared function
$result = Get-VersionChangeType -OldVersion $s.version -NewVersion $version
$changeType = $result.ChangeType

# Determine if this is a breaking change
if ($changeType -eq "downgrade" -or $changeType -eq "major") {
$hasBreakingChanges = $true
Expand All @@ -332,7 +333,7 @@ foreach ($s in $sources) {
$sources | ConvertTo-Json | Set-Content $sourcesPath

if ($count -eq 0) {
Write-Host -ForegroundColor yellow "No new releases were found."
Write-ColorOutput -ForegroundColor Yellow -Message "No new releases were found."
return
}

Expand All @@ -348,4 +349,4 @@ if ($Env:APPVEYOR -eq 'True') {
Add-AppveyorMessage -Message "Successfully updated $count dependencies." -Category Information
}

Write-Host -ForegroundColor green "Successfully updated $count dependencies."
Write-ColorOutput -ForegroundColor Green -Message "Successfully updated $count dependencies."
Loading
Loading