diff options
Diffstat (limited to 'integration-tests/src')
-rw-r--r-- | integration-tests/src/main/kotlin/org/jetbrains/dokka/it/S3Project.kt | 16 | ||||
-rw-r--r-- | integration-tests/src/main/kotlin/org/jetbrains/dokka/it/gitSubmoduleUtils.kt | 40 |
2 files changed, 56 insertions, 0 deletions
diff --git a/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/S3Project.kt b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/S3Project.kt new file mode 100644 index 00000000..ee69ef62 --- /dev/null +++ b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/S3Project.kt @@ -0,0 +1,16 @@ +package org.jetbrains.dokka.it + +import org.junit.After +import java.io.File + +interface S3Project { + val projectOutputLocation: File + + @After + fun copyToLocation() { + System.getenv("DOKKA_IT_AWS_PATH")?.also { location -> + println("Copying to ${File(location).absolutePath}") + projectOutputLocation.copyRecursively(File(location)) + } ?: println("No copy path provided, skipping") + } +} diff --git a/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/gitSubmoduleUtils.kt b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/gitSubmoduleUtils.kt new file mode 100644 index 00000000..312ff21f --- /dev/null +++ b/integration-tests/src/main/kotlin/org/jetbrains/dokka/it/gitSubmoduleUtils.kt @@ -0,0 +1,40 @@ +package org.jetbrains.dokka.it + +import org.eclipse.jgit.api.Git +import org.eclipse.jgit.storage.file.FileRepositoryBuilder +import java.io.File +import java.nio.file.Path + +fun AbstractIntegrationTest.copyAndApplyGitDiff(diffFile: File) = + copyGitDiffFileToParent(diffFile).let(::applyGitDiffFromFile) + +fun AbstractIntegrationTest.copyGitDiffFileToParent(originalDiffFile: File) = + originalDiffFile.copyTo(File(projectDir.parent, originalDiffFile.name)) + +fun AbstractIntegrationTest.applyGitDiffFromFile(diffFile: File) { + val projectGitFile = projectDir.resolve(".git") + val git = if (projectGitFile.exists()) { + if (projectGitFile.isFile) { + println(".git file inside project directory exists, removing") + removeGitFile(projectDir.toPath()) + Git.init().setDirectory(projectDir).call() + } else { + println(".git directory inside project directory exists, reusing") + FileRepositoryBuilder().apply { + isMustExist = true + gitDir = projectDir + }.let { Git(it.build()) } + } + } else { + Git.init().setDirectory(projectDir).call() + } + git.apply().setPatch(diffFile.inputStream()).call() +} + +private fun removeGitFile(repository: Path) = + repository.toFile() + .listFiles().orEmpty() + .filter { it.name.toLowerCase() == ".git" } + .forEach { it.delete() } + + |