Untracked files are now staged before stash
This commit is contained in:
parent
0ff882a31c
commit
df3f47f073
@ -244,7 +244,8 @@ class StatusManager @Inject constructor(
|
||||
.map {
|
||||
val entries = it.value
|
||||
|
||||
val hasConflicts = (entries.count() > 1 && (repositoryState.isMerging || repositoryState.isRebasing))
|
||||
val hasConflicts =
|
||||
(entries.count() > 1 && (repositoryState.isMerging || repositoryState.isRebasing))
|
||||
|
||||
StatusEntry(entries.first(), isConflict = hasConflicts)
|
||||
}
|
||||
@ -311,6 +312,26 @@ class StatusManager @Inject constructor(
|
||||
addedCount = addedCount,
|
||||
)
|
||||
}
|
||||
|
||||
suspend fun stageUntrackedFiles(git: Git) = withContext(Dispatchers.IO) {
|
||||
val diffEntries = git
|
||||
.diff()
|
||||
.setShowNameAndStatusOnly(true)
|
||||
.call()
|
||||
|
||||
val addedEntries = diffEntries.filter { it.changeType == DiffEntry.ChangeType.ADD }
|
||||
|
||||
if(addedEntries.isNotEmpty()) {
|
||||
val addCommand = git
|
||||
.add()
|
||||
|
||||
for (entry in addedEntries) {
|
||||
addCommand.addFilepattern(entry.newPath)
|
||||
}
|
||||
|
||||
addCommand.call()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -1,9 +1,6 @@
|
||||
package app.viewmodels
|
||||
|
||||
import app.git.RefreshType
|
||||
import app.git.RemoteOperationsManager
|
||||
import app.git.StashManager
|
||||
import app.git.TabState
|
||||
import app.git.*
|
||||
import java.awt.Desktop
|
||||
import javax.inject.Inject
|
||||
|
||||
@ -11,6 +8,7 @@ class MenuViewModel @Inject constructor(
|
||||
private val tabState: TabState,
|
||||
private val remoteOperationsManager: RemoteOperationsManager,
|
||||
private val stashManager: StashManager,
|
||||
private val statusManager: StatusManager,
|
||||
) {
|
||||
fun pull(rebase: Boolean = false) = tabState.safeProcessing(
|
||||
refreshType = RefreshType.ALL_DATA,
|
||||
@ -36,6 +34,7 @@ class MenuViewModel @Inject constructor(
|
||||
fun stash() = tabState.safeProcessing(
|
||||
refreshType = RefreshType.UNCOMMITED_CHANGES_AND_LOG,
|
||||
) { git ->
|
||||
statusManager.stageUntrackedFiles(git)
|
||||
stashManager.stash(git)
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user