Added error when trying to stash a clean workspace

This commit is contained in:
Abdelilah El Aissaoui 2024-06-23 14:57:21 +02:00
parent 2375f43a44
commit b2621d2c51
No known key found for this signature in database
GPG Key ID: 7587FC860F594869

View File

@ -7,7 +7,7 @@ import javax.inject.Inject
class StashChangesUseCase @Inject constructor() { class StashChangesUseCase @Inject constructor() {
suspend operator fun invoke(git: Git, message: String?): Unit = withContext(Dispatchers.IO) { suspend operator fun invoke(git: Git, message: String?): Unit = withContext(Dispatchers.IO) {
git val commit = git
.stashCreate() .stashCreate()
.setIncludeUntracked(true) .setIncludeUntracked(true)
.apply { .apply {
@ -15,5 +15,9 @@ class StashChangesUseCase @Inject constructor() {
setWorkingDirectoryMessage(message) setWorkingDirectoryMessage(message)
} }
.call() .call()
if (commit == null) {
throw Exception("No changes to stash")
}
} }
} }