Untracked files are now staged before stash
This commit is contained in:
parent
0ff882a31c
commit
df3f47f073
@ -234,7 +234,7 @@ class StatusManager @Inject constructor(
|
|||||||
}
|
}
|
||||||
.call()
|
.call()
|
||||||
|
|
||||||
statusEntries = if(repositoryState.isMerging || repositoryState.isRebasing) {
|
statusEntries = if (repositoryState.isMerging || repositoryState.isRebasing) {
|
||||||
status.groupBy {
|
status.groupBy {
|
||||||
if (it.newPath != "/dev/null")
|
if (it.newPath != "/dev/null")
|
||||||
it.newPath
|
it.newPath
|
||||||
@ -244,7 +244,8 @@ class StatusManager @Inject constructor(
|
|||||||
.map {
|
.map {
|
||||||
val entries = it.value
|
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)
|
StatusEntry(entries.first(), isConflict = hasConflicts)
|
||||||
}
|
}
|
||||||
@ -311,6 +312,26 @@ class StatusManager @Inject constructor(
|
|||||||
addedCount = addedCount,
|
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
|
package app.viewmodels
|
||||||
|
|
||||||
import app.git.RefreshType
|
import app.git.*
|
||||||
import app.git.RemoteOperationsManager
|
|
||||||
import app.git.StashManager
|
|
||||||
import app.git.TabState
|
|
||||||
import java.awt.Desktop
|
import java.awt.Desktop
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
||||||
@ -11,6 +8,7 @@ class MenuViewModel @Inject constructor(
|
|||||||
private val tabState: TabState,
|
private val tabState: TabState,
|
||||||
private val remoteOperationsManager: RemoteOperationsManager,
|
private val remoteOperationsManager: RemoteOperationsManager,
|
||||||
private val stashManager: StashManager,
|
private val stashManager: StashManager,
|
||||||
|
private val statusManager: StatusManager,
|
||||||
) {
|
) {
|
||||||
fun pull(rebase: Boolean = false) = tabState.safeProcessing(
|
fun pull(rebase: Boolean = false) = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.ALL_DATA,
|
refreshType = RefreshType.ALL_DATA,
|
||||||
@ -36,6 +34,7 @@ class MenuViewModel @Inject constructor(
|
|||||||
fun stash() = tabState.safeProcessing(
|
fun stash() = tabState.safeProcessing(
|
||||||
refreshType = RefreshType.UNCOMMITED_CHANGES_AND_LOG,
|
refreshType = RefreshType.UNCOMMITED_CHANGES_AND_LOG,
|
||||||
) { git ->
|
) { git ->
|
||||||
|
statusManager.stageUntrackedFiles(git)
|
||||||
stashManager.stash(git)
|
stashManager.stash(git)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user