Skip to content

Commit 89b6933

Browse files
committed
fix: make SVN dependency optional
1 parent 20e0fcf commit 89b6933

File tree

4 files changed

+26
-4
lines changed

4 files changed

+26
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@
22

33
## [Unreleased]
44

5+
### Fixed
6+
7+
- Make SVN dependency optional.
8+
59
## [2.11.0] - 2025-04-24
610

711
### Added

src/main/kotlin/com/github/blarc/ai/commits/intellij/plugin/AICommitsUtils.kt

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,17 +100,19 @@ object AICommitsUtils {
100100
changes.mapNotNull {
101101
it.virtualFile?.let { virtualFile ->
102102
VcsUtil.getVcsFor(project, virtualFile)?.let { vcs ->
103-
when (vcs) {
104-
is SvnVcs -> {
103+
when {
104+
isSvnAvailable() && vcs is SvnVcs -> {
105105
SvnUtil.getUrl(vcs, VfsUtilCore.virtualToIoFile(virtualFile))?.let { url ->
106106
extractSvnBranchName(url.toDecodedString())
107107
}
108108
}
109-
is GitVcs -> {
109+
110+
vcs is GitVcs -> {
110111
GitRepositoryManager.getInstance(project)
111112
.getRepositoryForFile(it.virtualFile)
112113
?.currentBranchName
113114
}
115+
114116
else -> {
115117
null
116118
}
@@ -203,4 +205,17 @@ object AICommitsUtils {
203205
fun getIDELocale(): Locale {
204206
return DynamicBundle.getLocale()
205207
}
208+
209+
private fun isClassAvailable(className: String): Boolean {
210+
return try {
211+
Class.forName(className)
212+
true
213+
} catch (e: ClassNotFoundException) {
214+
false
215+
}
216+
}
217+
218+
private fun isSvnAvailable(): Boolean {
219+
return isClassAvailable("org.jetbrains.idea.svn.SvnVcs") && isClassAvailable("org.jetbrains.idea.svn.SvnUtil")
220+
}
206221
}

src/main/resources/META-INF/plugin.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
Read more: https://plugins.jetbrains.com/docs/intellij/plugin-compatibility.html -->
6969
<depends>com.intellij.modules.platform</depends>
7070
<depends>Git4Idea</depends>
71-
<depends>Subversion</depends>
71+
<depends optional="true" config-file="subversion.xml">Subversion</depends>
7272

7373
<applicationListeners>
7474

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
<idea-plugin>
2+
<!-- This file contains Subversion-specific extensions that will be loaded only when Subversion plugin is available -->
3+
</idea-plugin>

0 commit comments

Comments
 (0)