diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/extensions/RevCommitExtensions.kt b/src/main/kotlin/com/jetpackduba/gitnuro/extensions/RevCommitExtensions.kt index b262a56..5757cca 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/extensions/RevCommitExtensions.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/extensions/RevCommitExtensions.kt @@ -10,6 +10,10 @@ fun RevCommit.fullData(repository: Repository): RevCommit? { this } +val RevCommit.shortName: String + get() = this.name().orEmpty().take(7) + + fun RevCommit.getShortMessageTrimmed(): String { return (this.fullMessage ?: "") .trimStart() diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/CommitChanges.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/CommitChanges.kt index d214dc8..f7c4111 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/CommitChanges.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/CommitChanges.kt @@ -206,17 +206,18 @@ fun CommitChangesView( ) } - Author(commit.id, commit.authorIdent) + Author(commit.shortName, commit.name, commit.authorIdent) } } } @Composable fun Author( - id: ObjectId, + shortName: String, + name: String, author: PersonIdent, ) { - var copied by remember(id) { mutableStateOf(false) } + var copied by remember(name) { mutableStateOf(false) } val scope = rememberCoroutineScope() val clipboard = LocalClipboardManager.current @@ -248,13 +249,13 @@ fun Author( Row(verticalAlignment = Alignment.CenterVertically) { Text( - text = id.abbreviate(7).name(), + text = shortName, color = MaterialTheme.colors.onBackgroundSecondary, maxLines = 1, style = MaterialTheme.typography.body2, modifier = Modifier.handMouseClickable { scope.launch { - clipboard.setText(AnnotatedString(id.name)) + clipboard.setText(AnnotatedString(name)) copied = true delay(2000) // 2s copied = false diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/ui/FileHistory.kt b/src/main/kotlin/com/jetpackduba/gitnuro/ui/FileHistory.kt index 2f3f9ee..9a5dd9f 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/ui/FileHistory.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/ui/FileHistory.kt @@ -26,6 +26,7 @@ import androidx.compose.ui.unit.dp import com.jetpackduba.gitnuro.AppIcons import com.jetpackduba.gitnuro.extensions.handMouseClickable import com.jetpackduba.gitnuro.extensions.handOnHover +import com.jetpackduba.gitnuro.extensions.shortName import com.jetpackduba.gitnuro.extensions.toSmartSystemString import com.jetpackduba.gitnuro.git.diff.DiffResult import com.jetpackduba.gitnuro.keybindings.KeybindingOption @@ -237,7 +238,7 @@ fun HistoryCommit(commit: RevCommit, onCommitSelected: () -> Unit) { Row { Text( - text = commit.name.take(7), + text = commit.shortName, maxLines = 1, style = MaterialTheme.typography.body2, color = MaterialTheme.colors.onBackgroundSecondary, diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/HistoryViewModel.kt b/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/HistoryViewModel.kt index 5a6c24a..81794ad 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/HistoryViewModel.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/HistoryViewModel.kt @@ -76,6 +76,8 @@ class HistoryViewModel @Inject constructor( fun fileHistory(filePath: String) = tabState.safeProcessing( refreshType = RefreshType.NONE, + title = "History", + subtitle = "Loading file history", ) { git -> this@HistoryViewModel.filePath = filePath _historyState.value = HistoryState.Loading(filePath) diff --git a/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/LogViewModel.kt b/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/LogViewModel.kt index 8edb0ae..d24c8ab 100644 --- a/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/LogViewModel.kt +++ b/src/main/kotlin/com/jetpackduba/gitnuro/viewmodels/LogViewModel.kt @@ -3,6 +3,8 @@ package com.jetpackduba.gitnuro.viewmodels import androidx.compose.foundation.ScrollState import androidx.compose.foundation.lazy.LazyListState import com.jetpackduba.gitnuro.extensions.delayedStateChange +import com.jetpackduba.gitnuro.extensions.shortName +import com.jetpackduba.gitnuro.extensions.simpleName import com.jetpackduba.gitnuro.git.RefreshType import com.jetpackduba.gitnuro.git.TabState import com.jetpackduba.gitnuro.git.TaskEvent @@ -162,6 +164,8 @@ class LogViewModel @Inject constructor( fun pushToRemoteBranch(branch: Ref) = tabState.safeProcessing( refreshType = RefreshType.ALL_DATA, + title = "Push", + subtitle = "Pushing current branch to ${branch.simpleName}", ) { git -> pushToSpecificBranchUseCase( git = git, @@ -173,6 +177,8 @@ class LogViewModel @Inject constructor( fun pullFromRemoteBranch(branch: Ref) = tabState.safeProcessing( refreshType = RefreshType.ALL_DATA, + title = "Pull", + subtitle = "Pulling changes from ${branch.simpleName} to the current branch", ) { git -> pullFromSpecificBranchUseCase( git = git, @@ -183,6 +189,8 @@ class LogViewModel @Inject constructor( fun checkoutCommit(revCommit: RevCommit) = tabState.safeProcessing( refreshType = RefreshType.ALL_DATA, + title = "Commit checkout", + subtitle = "Checking out commit ${revCommit.name}", ) { git -> checkoutCommitUseCase(git, revCommit) } @@ -190,24 +198,32 @@ class LogViewModel @Inject constructor( fun revertCommit(revCommit: RevCommit) = tabState.safeProcessing( refreshType = RefreshType.ALL_DATA, refreshEvenIfCrashes = true, + title = "Commit revert", + subtitle = "Reverting commit ${revCommit.name}", ) { git -> revertCommitUseCase(git, revCommit) } fun resetToCommit(revCommit: RevCommit, resetType: ResetType) = tabState.safeProcessing( refreshType = RefreshType.ALL_DATA, + title = "Branch reset", + subtitle = "Reseting branch to commit ${revCommit.shortName}", ) { git -> resetToCommitUseCase(git, revCommit, resetType = resetType) } fun checkoutRef(ref: Ref) = tabState.safeProcessing( refreshType = RefreshType.ALL_DATA, + title = "Branch checkout", + subtitle = "Checking out branch ${ref.simpleName}", ) { git -> checkoutRefUseCase(git, ref) } fun cherrypickCommit(revCommit: RevCommit) = tabState.safeProcessing( refreshType = RefreshType.UNCOMMITED_CHANGES_AND_LOG, + title = "Cherry-pick", + subtitle = "Cherry-picking commit ${revCommit.shortName}", ) { git -> cherryPickCommitUseCase(git, revCommit) } @@ -215,38 +231,44 @@ class LogViewModel @Inject constructor( fun createBranchOnCommit(branch: String, revCommit: RevCommit) = tabState.safeProcessing( refreshType = RefreshType.ALL_DATA, refreshEvenIfCrashesInteractive = { it is CheckoutConflictException }, + title = "New branch", + subtitle = "Creating new branch \"$branch\" on commit ${revCommit.shortName}", ) { git -> createBranchOnCommitUseCase(git, branch, revCommit) } fun createTagOnCommit(tag: String, revCommit: RevCommit) = tabState.safeProcessing( refreshType = RefreshType.ALL_DATA, + title = "New tag", + subtitle = "Creating new tag \"$tag\" on commit ${revCommit.shortName}", ) { git -> createTagOnCommitUseCase(git, tag, revCommit) } fun mergeBranch(ref: Ref) = tabState.safeProcessing( refreshType = RefreshType.ALL_DATA, + title = "Branch merge", + subtitle = "Merging branch ${ref.simpleName}", ) { git -> mergeBranchUseCase(git, ref, appSettings.ffMerge) } fun deleteBranch(branch: Ref) = tabState.safeProcessing( refreshType = RefreshType.ALL_DATA, + title = "Branch delete", + subtitle = "Deleting branch ${branch.simpleName}", ) { git -> deleteBranchUseCase(git, branch) } fun deleteTag(tag: Ref) = tabState.safeProcessing( refreshType = RefreshType.ALL_DATA, + title = "Tag delete", + subtitle = "Deleting tag ${tag.simpleName}", ) { git -> deleteTagUseCase(git, tag) } - suspend fun refreshUncommitedChanges(git: Git) { - uncommitedChangesLoadLog(git) - } - private suspend fun uncommitedChangesLoadLog(git: Git) { val currentBranch = getCurrentBranchUseCase(git) val hasUncommitedChanges = checkHasUncommitedChangedUseCase(git) @@ -279,6 +301,8 @@ class LogViewModel @Inject constructor( fun rebaseBranch(ref: Ref) = tabState.safeProcessing( refreshType = RefreshType.ALL_DATA, + title = "Branch rebase", + subtitle = "Rebasing branch ${ref.simpleName}", ) { git -> rebaseBranchUseCase(git, ref) } @@ -412,6 +436,8 @@ class LogViewModel @Inject constructor( fun deleteRemoteBranch(branch: Ref) = tabState.safeProcessing( refreshType = RefreshType.ALL_DATA, + title = "Delete remote branch", + subtitle = "Deleting remote branch ${branch.simpleName}", ) { git -> deleteRemoteBranchUseCase(git, branch) }