Skip to content
This repository was archived by the owner on May 3, 2025. It is now read-only.

Commit c87211b

Browse files
authored
Merge pull request #46 from CherryPerry/windows-check
Windows support
2 parents 11c6ea9 + 33b29dd commit c87211b

File tree

4 files changed

+17
-11
lines changed

4 files changed

+17
-11
lines changed

.github/workflows/build.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,10 @@ on:
66
pull_request:
77
jobs:
88
build:
9-
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
os: [ ubuntu-latest, windows-latest ]
12+
runs-on: ${{ matrix.os }}
1013
steps:
1114
- uses: actions/checkout@v2
1215
- uses: actions/setup-java@v2

build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ repositories {
5555
}
5656

5757
dependencies {
58-
implementation("org.eclipse.jgit", "org.eclipse.jgit", "5.13.0.202109080827-r")
58+
implementation("org.eclipse.jgit", "org.eclipse.jgit", "6.1.0.202203080745-r")
5959
compileOnly(gradleApi())
6060
testImplementation("junit", "junit", "4.13.2")
6161
testImplementation(gradleTestKit())

src/main/kotlin/com/cherryperry/gfe/CheckGitIgnoreTask.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import org.gradle.api.file.FileCollection
1313
import org.gradle.api.tasks.InputFiles
1414
import org.gradle.api.tasks.SkipWhenEmpty
1515
import org.gradle.api.tasks.TaskAction
16+
import java.io.File
1617
import java.io.IOException
1718

1819
/**
@@ -40,32 +41,33 @@ open class CheckGitIgnoreTask : BaseTask(), PlainFilesAware {
4041
} catch (exception: IOException) {
4142
throw GradleException("Git repository was not found at path $projectDir", exception)
4243
}
43-
val plainFiles = plainFiles.mapNotNull { it.toRelativeString(projectDir.asFile) }.toHashSet()
44+
val plainFiles = plainFiles.toHashSet()
4445
TreeWalk(git.repository).use { treeWalk -> walkThrough(git, treeWalk, plainFiles) }
4546
failTaskIfAnyFilesLeft(plainFiles)
4647
}
4748

48-
private fun walkThrough(git: Git, treeWalk: TreeWalk, plainFiles: MutableCollection<String>) {
49+
private fun walkThrough(git: Git, treeWalk: TreeWalk, plainFiles: MutableCollection<File>) {
4950
val fileTreeIterator = FileTreeIterator(git.repository)
5051
fileTreeIterator.setWalkIgnoredDirectories(true)
5152
treeWalk.addTree(fileTreeIterator)
5253
treeWalk.isRecursive = true
5354
while (treeWalk.next() && plainFiles.isNotEmpty()) {
5455
if (treeWalk.getTree(WorkingTreeIterator::class.java).isEntryIgnored) {
55-
val path = treeWalk.pathString
56-
val removed = plainFiles.remove(path)
56+
val file = projectDir.file(treeWalk.pathString).asFile
57+
val removed = plainFiles.remove(file)
5758
if (removed) {
58-
logger.info("$path is ignored")
59+
logger.info("$file is ignored")
5960
}
6061
}
6162
}
6263
}
6364

64-
private fun failTaskIfAnyFilesLeft(relativePlainFiles: Collection<String>) {
65+
private fun failTaskIfAnyFilesLeft(relativePlainFiles: Collection<File>) {
6566
if (relativePlainFiles.isNotEmpty()) {
6667
relativePlainFiles.forEach { plainFile ->
68+
val fileForLog = plainFile.relativeToOrNull(projectDir.asFile) ?: plainFile
6769
logger.error(
68-
"${projectDir.file(plainFile)} is not ignored by any ${Constants.DOT_GIT_IGNORE} files of project"
70+
"$fileForLog is not ignored by any ${Constants.DOT_GIT_IGNORE} files of project"
6971
)
7072
}
7173
throw GradleException("Some plain files are not ignored by git, see log above")

src/test/kotlin/com/cherryperry/gfe/FileEncryptPluginFunctionalTest.kt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ class FileEncryptPluginFunctionalTest(
4141
@Parameterized.Parameters(name = "Gradle version: {0}")
4242
fun gradleVersions(): Collection<Array<Any>> = arrayListOf(
4343
arrayOf<Any>("6.8.3"),
44-
arrayOf<Any>("6.9.1"),
44+
arrayOf<Any>("6.9.2"),
4545
arrayOf<Any>("7.0.2"),
4646
arrayOf<Any>("7.1.1"),
4747
arrayOf<Any>("7.2"),
48-
arrayOf<Any>("7.3"),
48+
arrayOf<Any>("7.3.3"),
49+
arrayOf<Any>("7.4.2"),
4950
)
5051
}
5152

0 commit comments

Comments
 (0)