Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions mps-sync-plugin3/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ dependencies {
testImplementation(libs.kotlin.coroutines.test)
testImplementation(libs.logback.classic)
testImplementation(kotlin("test"))
testImplementation(libs.mockk)
testImplementation(project(":authorization"), excludeMPSLibraries)
testImplementation(project(":model-server"), excludeMPSLibraries)
testImplementation(libs.ktor.client.cio, excludeMPSLibraries)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
fun getServerConnections(): List<IServerConnection>
fun getUsedServerConnections(): List<IServerConnection>
fun getBindings(): List<IBinding>
fun updateBinding(oldBranchRef: BranchReference, newBranchRef: BranchReference, resetLocalState: Boolean = false)

Check warning

Code scanning / detekt

The function updateBinding is missing documentation. Warning

The function updateBinding is missing documentation.
}

data class ModelServerConnectionProperties(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,30 @@
return loadedState.bindings.keys.map { Binding(it) }
}

@Synchronized
override fun updateBinding(oldBranchRef: BranchReference, newBranchRef: BranchReference, resetLocalState: Boolean) {
updateState {
it.bindings.none { it.key.branchRef == oldBranchRef } &&

Check warning

Code scanning / detekt

Name shadowed: implicit lambda parameter 'it' Warning

Name shadowed: implicit lambda parameter 'it'
throw IllegalArgumentException("No binding for $oldBranchRef")

it.copy(
bindings = it.bindings.mapKeys { (key, _) ->
if (key.branchRef == oldBranchRef) {
key.copy(branchRef = newBranchRef)
} else {
key
}
}.mapValues { (key, value) ->
if (resetLocalState && key.branchRef == newBranchRef) {
value.copy(versionHash = null)
} else {
value
}
},
)
}
}

@Synchronized
fun loadState(newState: SyncServiceState) {
val oldState: SyncServiceState = this.loadedState
Expand Down
Loading
Loading