Skip to content

Commit 066eefb

Browse files
authored
fix(library): do not check if .git is a dir (#1900)
Closes #1898. `findGitDir` function is used to figure out where the script is run from, so it's a critical function that is called upon each YAML regeneration. The check if it's a directory causes troubles when using git's worktrees. `.git` is a symlink to the real `.git` dir, so it's not a directory. Based on #1898 (comment).
1 parent 87492af commit 066eefb

File tree

1 file changed

+2
-4
lines changed
  • shared-internal/src/main/kotlin/io/github/typesafegithub/workflows/shared/internal

1 file changed

+2
-4
lines changed

shared-internal/src/main/kotlin/io/github/typesafegithub/workflows/shared/internal/PathUtils.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,8 @@ package io.github.typesafegithub.workflows.shared.internal
33
import java.nio.file.Path
44
import kotlin.io.path.absolute
55
import kotlin.io.path.exists
6-
import kotlin.io.path.isDirectory
76

87
fun Path.findGitRoot(): Path =
98
generateSequence(this.absolute()) { it.parent }
10-
.firstOrNull {
11-
it.resolve(".git")?.let { it.exists() && it.isDirectory() } ?: false
12-
} ?: error("could not find a git root from ${this.absolute()}")
9+
.firstOrNull { it.resolve(".git").exists() }
10+
?: error("could not find a git root from ${this.absolute()}")

0 commit comments

Comments
 (0)