Skip to content

Commit

Permalink
updating git logic to work on detached head
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelcolas committed Oct 10, 2019
1 parent e9bd78f commit bcd804f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions tests/QA/module.tests.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,12 @@ $SourcePath = (Get-ChildItem $ProjectPath\*\*.psd1 | Where-Object {

Describe 'Changelog Management' -Tag 'Changelog' {
It 'Changelog has been updated' -skip:(![bool](Get-Command git -EA SilentlyContinue)) {
$filesChanged = &git diff master.. --name-only # Get the list of changed files compared with master
$currentBranch = &git rev-parse --abbrev-ref HEAD
if($currentBranch -ne 'master') {
# Get the list of changed files compared with master
$HeadCommit = &git rev-parse HEAD
$MasterCommit = &git rev-parse origin/master
$filesChanged = &git diff $MasterCommit...$HeadCommit --name-only

if($HeadCommit -ne $MasterCommit) { # if we're not testing same commit (i.e. master..master)
$filesChanged.Where{ (Split-Path $_ -Leaf) -match '^changelog' } | Should -Not -BeNullOrEmpty
}
}
Expand Down

0 comments on commit bcd804f

Please sign in to comment.