Skip to content

Commit

Permalink
Change default path to global hooks
Browse files Browse the repository at this point in the history
  • Loading branch information
y0ung3r committed Nov 26, 2023
1 parent 03d4bcf commit e44570d
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class Git(private val commandExecutor: CliCommandExecutor) {
const val GIT_GLOBAL_COMMAND = "--global"
const val GIT_CONFIG_GET_COMMAND = "--get"
const val GIT_HOOKS_PATH_SECTION = "core.hooksPath"
const val DEFAULT_HOOKS_PATH = "./.git/hooks"
const val DEFAULT_HOOKS_PATH = "~/.git/hooks"

@JvmStatic
val minRequiredVersion = SemanticVersion(2, 9, 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ class GetGlobalHooksPathTests {
fun `Should returns default hooks path if path is not overridden`() {
// Arrange
val expectedPath = Path.of(
SystemPathUtils.getCurrentDirectoryPath(),
SystemPathUtils.getUserHomePath(),
".git",
"hooks"
)
Expand All @@ -39,7 +39,7 @@ class GetGlobalHooksPathTests {
fun `Should returns default hooks path if path is empty`() {
// Arrange
val expectedPath = Path.of(
SystemPathUtils.getCurrentDirectoryPath(),
SystemPathUtils.getUserHomePath(),
".git",
"hooks"
)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.github.y0ung3r.gitglobalhookslocator.gitTests

import com.github.y0ung3r.gitglobalhookslocator.gitTests.testEngine.HookTestBase
import com.github.y0ung3r.gitglobalhookslocator.gitTests.testEngine.RespondInterchangeably
import com.github.y0ung3r.gitglobalhookslocator.git.Git
import com.github.y0ung3r.gitglobalhookslocator.git.HooksFolder
import com.github.y0ung3r.gitglobalhookslocator.git.cli.CliResponse
import org.junit.Assert
import org.junit.Assert.assertEquals
import org.junit.Assert.assertTrue
import com.github.y0ung3r.gitglobalhookslocator.gitTests.testEngine.HookTestBase
import com.github.y0ung3r.gitglobalhookslocator.gitTests.testEngine.RespondInterchangeably
import org.junit.Assert.*
import org.junit.Test
import java.nio.file.Path

Expand All @@ -22,18 +20,6 @@ class HooksFolderTests : HookTestBase() {
)
}

@Test
fun `Should be empty if provided empty path`() {
// Arrange
val git = getGit(Path.of(""))

// Act
val sut = HooksFolder(git)

// Assert
assertTrue(sut.isEmpty())
}

@Test
fun `Should load all hooks from disabled hooks path`() {
// Arrange
Expand Down Expand Up @@ -65,7 +51,7 @@ class HooksFolderTests : HookTestBase() {
val sut = HooksFolder(git)

// Act & Assert
Assert.assertTrue(sut.isAllDisabled())
assertTrue(sut.isAllDisabled())
}

@Test
Expand All @@ -75,7 +61,7 @@ class HooksFolderTests : HookTestBase() {
val sut = HooksFolder(git)

// Act & Assert
Assert.assertFalse(sut.isAllDisabled())
assertFalse(sut.isAllDisabled())
}

@Test
Expand All @@ -88,7 +74,7 @@ class HooksFolderTests : HookTestBase() {
sut.disableAll()

// Assert
Assert.assertTrue(sut.isAllDisabled())
assertTrue(sut.isAllDisabled())
}

@Test
Expand All @@ -101,6 +87,6 @@ class HooksFolderTests : HookTestBase() {
sut.enableAll()

// Assert
Assert.assertFalse(sut.isAllDisabled())
assertFalse(sut.isAllDisabled())
}
}

0 comments on commit e44570d

Please sign in to comment.