Ensure file paths are sorted in status/commit changes

This commit is contained in:
Abdelilah El Aissaoui 2023-12-18 21:51:28 +01:00
parent c0046d4086
commit e0b94adc8a
No known key found for this signature in database
GPG Key ID: 7587FC860F594869
5 changed files with 11 additions and 15 deletions

View File

@ -1,5 +1,6 @@
package com.jetpackduba.gitnuro.git.diff
import com.jetpackduba.gitnuro.extensions.filePath
import com.jetpackduba.gitnuro.extensions.fullData
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
@ -36,6 +37,7 @@ class GetCommitDiffEntriesUseCase @Inject constructor() {
.setNewTree(newTreeParser)
.setOldTree(oldTreeParser)
.call()
.sortedBy { it.filePath }
}
}

View File

@ -23,6 +23,6 @@ class GetStagedUseCase @Inject constructor() {
added,
modified,
removed,
)
).sortedBy { it.filePath }
}
}

View File

@ -8,16 +8,13 @@ import javax.inject.Inject
class GetUnstagedUseCase @Inject constructor() {
suspend operator fun invoke(status: Status) = withContext(Dispatchers.IO) {
// TODO Test uninitialized modules after the refactor
// val uninitializedSubmodules = submodulesManager.uninitializedSubmodules(git)
val added = status.untracked.map {
val untracked = status.untracked.map {
StatusEntry(it, StatusType.ADDED)
}
val modified = status.modified.map {
StatusEntry(it, StatusType.MODIFIED)
}
val removed = status.missing.map {
val missing = status.missing.map {
StatusEntry(it, StatusType.REMOVED)
}
val conflicting = status.conflicting.map {
@ -25,10 +22,10 @@ class GetUnstagedUseCase @Inject constructor() {
}
return@withContext flatListOf(
added,
untracked,
modified,
removed,
missing,
conflicting,
)
).sortedBy { it.filePath }
}
}

View File

@ -19,7 +19,7 @@ private val updateJson = Json {
class UpdatesRepository @Inject constructor(
private val updatesWebService: UpdatesService,
) {
fun hasUpdatesFlow() = flow<Update> {
fun hasUpdatesFlow() = flow {
val latestReleaseJson = updatesWebService.release(AppConstants.VERSION_CHECK_URL)
while(coroutineContext.isActive) {

View File

@ -40,7 +40,6 @@ class StatusViewModel @Inject constructor(
private val resetEntryUseCase: DiscardEntryUseCase,
private val stageAllUseCase: StageAllUseCase,
private val unstageAllUseCase: UnstageAllUseCase,
private val checkHasPreviousCommitsUseCase: CheckHasPreviousCommitsUseCase,
private val getLastCommitMessageUseCase: GetLastCommitMessageUseCase,
private val resetRepositoryStateUseCase: ResetRepositoryStateUseCase,
private val continueRebaseUseCase: ContinueRebaseUseCase,
@ -53,12 +52,10 @@ class StatusViewModel @Inject constructor(
private val doCommitUseCase: DoCommitUseCase,
private val loadAuthorUseCase: LoadAuthorUseCase,
private val saveAuthorUseCase: SaveAuthorUseCase,
private val getRepositoryStateUseCase: GetRepositoryStateUseCase,
private val getRebaseAmendCommitIdUseCase: GetRebaseAmendCommitIdUseCase,
private val sharedRepositoryStateManager: SharedRepositoryStateManager,
private val getSpecificCommitMessageUseCase: GetSpecificCommitMessageUseCase,
private val tabScope: CoroutineScope,
private val appSettings: AppSettings,
tabScope: CoroutineScope,
appSettings: AppSettings,
) {
private val _showSearchUnstaged = MutableStateFlow(false)
val showSearchUnstaged: StateFlow<Boolean> = _showSearchUnstaged