Reduced number of operations that have to be executed to update the status
This commit is contained in:
parent
4ed10c0682
commit
b6c4fa0ed7
@ -13,10 +13,8 @@ import org.eclipse.jgit.revwalk.RevCommit
|
|||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
|
|
||||||
class LogManager @Inject constructor(
|
class LogManager @Inject constructor() {
|
||||||
private val statusManager: StatusManager,
|
suspend fun loadLog(git: Git, currentBranch: Ref?, hasUncommitedChanges: Boolean) = withContext(Dispatchers.IO) {
|
||||||
) {
|
|
||||||
suspend fun loadLog(git: Git, currentBranch: Ref?) = withContext(Dispatchers.IO) {
|
|
||||||
val commitList = GraphCommitList()
|
val commitList = GraphCommitList()
|
||||||
val repositoryState = git.repository.repositoryState
|
val repositoryState = git.repository.repositoryState
|
||||||
println("Repository state ${repositoryState.description}")
|
println("Repository state ${repositoryState.description}")
|
||||||
@ -30,7 +28,7 @@ class LogManager @Inject constructor(
|
|||||||
walk.markStartAllRefs(Constants.R_REMOTES)
|
walk.markStartAllRefs(Constants.R_REMOTES)
|
||||||
walk.markStartAllRefs(Constants.R_TAGS)
|
walk.markStartAllRefs(Constants.R_TAGS)
|
||||||
|
|
||||||
if (statusManager.hasUncommitedChanges(git))
|
if (hasUncommitedChanges)
|
||||||
commitList.addUncommitedChangesGraphCommit(logList.first())
|
commitList.addUncommitedChangesGraphCommit(logList.first())
|
||||||
|
|
||||||
commitList.source(walk)
|
commitList.source(walk)
|
||||||
|
@ -29,17 +29,15 @@ class LogViewModel @Inject constructor(
|
|||||||
_logStatus.value = LogStatus.Loading
|
_logStatus.value = LogStatus.Loading
|
||||||
|
|
||||||
val currentBranch = branchesManager.currentBranchRef(git)
|
val currentBranch = branchesManager.currentBranchRef(git)
|
||||||
val log = logManager.loadLog(git, currentBranch)
|
|
||||||
val hasUncommitedChanges = statusManager.hasUncommitedChanges(git)
|
|
||||||
|
|
||||||
val statsSummary = if (hasUncommitedChanges) {
|
val statsSummary = statusManager.getStatusSummary(
|
||||||
statusManager.getStatusSummary(
|
git = git,
|
||||||
git = git,
|
currentBranch = currentBranch,
|
||||||
currentBranch = currentBranch,
|
repositoryState = repositoryManager.getRepositoryState(git),
|
||||||
repositoryState = repositoryManager.getRepositoryState(git),
|
)
|
||||||
)
|
|
||||||
} else
|
val hasUncommitedChanges = statsSummary.addedCount + statsSummary.deletedCount + statsSummary.modifiedCount > 0
|
||||||
StatusSummary(0, 0, 0)
|
val log = logManager.loadLog(git, currentBranch, hasUncommitedChanges)
|
||||||
|
|
||||||
_logStatus.value = LogStatus.Loaded(hasUncommitedChanges, log, currentBranch, statsSummary)
|
_logStatus.value = LogStatus.Loaded(hasUncommitedChanges, log, currentBranch, statsSummary)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user