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

View File

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

View File

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

View File

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

View File

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