Skip to content

Commit

Permalink
Lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Trenly committed Nov 5, 2024
1 parent 3172457 commit 44f66b8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 27 deletions.
36 changes: 12 additions & 24 deletions resources/GitDsc/GitDsc.psm1
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ class GitClone {
if ($gitRemoteValue -like $this.HttpsUrl) {
$currentState.Ensure = [Ensure]::Present
}
}
catch {
} catch {
# Failed to execute `git remote`. Ensure state is `absent`
}
}
Expand Down Expand Up @@ -114,8 +113,7 @@ class GitRemote {
try {
$gitRemoteValue = Invoke-GitRemote("get-url $($this.RemoteName)")
$currentState.Ensure = ($gitRemoteValue -like $this.RemoteUrl) ? [Ensure]::Present : [Ensure]::Absent
}
catch {
} catch {
$currentState.Ensure = [Ensure]::Absent
}

Expand All @@ -133,16 +131,13 @@ class GitRemote {
if ($this.Ensure -eq [Ensure]::Present) {
try {
Invoke-GitRemote("add $($this.RemoteName) $($this.RemoteUrl)")
}
catch {
} catch {
throw 'Failed to add remote repository.'
}
}
else {
} else {
try {
Invoke-GitRemote("remove $($this.RemoteName)")
}
catch {
} catch {
throw 'Failed to remove remote repository.'
}
}
Expand Down Expand Up @@ -174,12 +169,10 @@ class GitConfigUserName {
if ($this.ProjectDirectory) {
if (Test-Path -Path $this.ProjectDirectory) {
Set-Location $this.ProjectDirectory
}
else {
} else {
throw 'Project directory does not exist.'
}
}
else {
} else {
throw 'Project directory parameter must be specified for non-system and non-global configurations.'
}
}
Expand All @@ -206,8 +199,7 @@ class GitConfigUserName {

if ($this.Ensure -eq [Ensure]::Present) {
$configArgs = ConstructGitConfigUserArguments -Arguments "user.name '$($this.UserName)'" -ConfigLocation $this.ConfigLocation
}
else {
} else {
$configArgs = ConstructGitConfigUserArguments -Arguments '--unset user.name' -ConfigLocation $this.ConfigLocation
}

Expand Down Expand Up @@ -240,12 +232,10 @@ class GitConfigUserEmail {
if ($this.ProjectDirectory) {
if (Test-Path -Path $this.ProjectDirectory) {
Set-Location $this.ProjectDirectory
}
else {
} else {
throw 'Project directory does not exist.'
}
}
else {
} else {
throw 'Project directory parameter must be specified for non-system and non-global configurations.'
}
}
Expand All @@ -272,8 +262,7 @@ class GitConfigUserEmail {

if ($this.Ensure -eq [Ensure]::Present) {
$configArgs = ConstructGitConfigUserArguments -Arguments "user.email $($this.UserEmail)" -ConfigLocation $this.ConfigLocation
}
else {
} else {
$configArgs = ConstructGitConfigUserArguments -Arguments '--unset user.email' -ConfigLocation $this.ConfigLocation
}

Expand All @@ -290,8 +279,7 @@ function Assert-Git {
try {
Invoke-Git -Command 'help'
return
}
catch {
} catch {
throw 'Git is not installed'
}
}
Expand Down
5 changes: 2 additions & 3 deletions tests/GitDsc/GitDsc.Tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Licensed under the MIT License.
using module GitDsc

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

<#
Expand All @@ -11,8 +11,7 @@ Set-StrictMode -Version Latest
#>

BeforeAll {
if ($null -eq (Get-Module -ListAvailable -Name PSDesiredStateConfiguration))
{
if ($null -eq (Get-Module -ListAvailable -Name PSDesiredStateConfiguration)) {
Install-Module -Name PSDesiredStateConfiguration -Force -SkipPublisherCheck
}

Expand Down

0 comments on commit 44f66b8

Please sign in to comment.