Skip to content

Commit

Permalink
refactor(vcs)!: Make all WorkingTree implementations internal
Browse files Browse the repository at this point in the history
These partly take constructor arguments that are specific to the
implementation (like `SVNClientManager`), so make these generally internal
to not expose any implementation details.

Signed-off-by: Sebastian Schuberth <sebastian@doubleopen.org>
  • Loading branch information
sschuberth committed Nov 10, 2023
1 parent 1622397 commit 801948f
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion downloader/src/main/kotlin/vcs/GitWorkingTree.kt
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ private fun findGitOrSubmoduleDir(workingDirOrFile: File): Repository {
}.getOrThrow()
}

open class GitWorkingTree(
internal open class GitWorkingTree(
workingDir: File,
vcsType: VcsType,
private val repositoryUrlPrefixReplacements: Map<String, String> = emptyMap()
Expand Down
2 changes: 1 addition & 1 deletion downloader/src/main/kotlin/vcs/Mercurial.kt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ class Mercurial : VersionControlSystem(MercurialCommand) {

override fun getDefaultBranchName(url: String) = "default"

override fun getWorkingTree(vcsDirectory: File) = MercurialWorkingTree(vcsDirectory, type)
override fun getWorkingTree(vcsDirectory: File): WorkingTree = MercurialWorkingTree(vcsDirectory, type)

override fun isApplicableUrlInternal(vcsUrl: String) = ProcessCapture("hg", "identify", vcsUrl).isSuccess

Expand Down
2 changes: 1 addition & 1 deletion downloader/src/main/kotlin/vcs/MercurialWorkingTree.kt
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import org.ossreviewtoolkit.downloader.WorkingTree
import org.ossreviewtoolkit.model.VcsType
import org.ossreviewtoolkit.utils.common.ProcessCapture

class MercurialWorkingTree(workingDir: File, vcsType: VcsType) : WorkingTree(workingDir, vcsType) {
internal class MercurialWorkingTree(workingDir: File, vcsType: VcsType) : WorkingTree(workingDir, vcsType) {
override fun isValid(): Boolean {
if (!workingDir.isDirectory) return false

Expand Down
3 changes: 2 additions & 1 deletion downloader/src/main/kotlin/vcs/Subversion.kt
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ class Subversion : VersionControlSystem() {

override fun getDefaultBranchName(url: String) = "trunk"

override fun getWorkingTree(vcsDirectory: File) = SubversionWorkingTree(vcsDirectory, type, clientManager)
override fun getWorkingTree(vcsDirectory: File): WorkingTree =
SubversionWorkingTree(vcsDirectory, type, clientManager)

override fun isApplicableUrlInternal(vcsUrl: String) =
try {
Expand Down
2 changes: 1 addition & 1 deletion downloader/src/main/kotlin/vcs/SubversionWorkingTree.kt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import org.tmatesoft.svn.core.SVNURL
import org.tmatesoft.svn.core.wc.SVNClientManager
import org.tmatesoft.svn.core.wc.SVNRevision

class SubversionWorkingTree(
internal class SubversionWorkingTree(
workingDir: File,
vcsType: VcsType,
private val clientManager: SVNClientManager
Expand Down

0 comments on commit 801948f

Please sign in to comment.