Added un/stage all buttons
This commit is contained in:
parent
6d0f621bcd
commit
ee745bd4e0
@ -86,6 +86,8 @@ class GitManager @Inject constructor(
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun openRepository(directory: File) {
|
fun openRepository(directory: File) {
|
||||||
|
println("Trying to open repository ${directory.absoluteFile}")
|
||||||
|
|
||||||
val gitDirectory = if (directory.name == ".git") {
|
val gitDirectory = if (directory.name == ".git") {
|
||||||
directory
|
directory
|
||||||
} else {
|
} else {
|
||||||
@ -199,6 +201,14 @@ class GitManager @Inject constructor(
|
|||||||
suspend fun diffListFromCommit(commit: RevCommit): List<DiffEntry> {
|
suspend fun diffListFromCommit(commit: RevCommit): List<DiffEntry> {
|
||||||
return diffManager.commitDiffEntries(safeGit, commit)
|
return diffManager.commitDiffEntries(safeGit, commit)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun unstageAll() = managerScope.launch {
|
||||||
|
statusManager.unstageAll(safeGit)
|
||||||
|
}
|
||||||
|
|
||||||
|
fun stageAll() = managerScope.launch {
|
||||||
|
statusManager.stageAll(safeGit)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -53,7 +53,7 @@ class StatusManager @Inject constructor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun stage(git: Git, diffEntry: DiffEntry) = withContext(Dispatchers.IO) {
|
suspend fun stage(git: Git, diffEntry: DiffEntry) = withContext(Dispatchers.IO) {
|
||||||
if(diffEntry.changeType == DiffEntry.ChangeType.DELETE) {
|
if (diffEntry.changeType == DiffEntry.ChangeType.DELETE) {
|
||||||
git.rm()
|
git.rm()
|
||||||
.addFilepattern(diffEntry.filePath)
|
.addFilepattern(diffEntry.filePath)
|
||||||
.call()
|
.call()
|
||||||
@ -83,7 +83,7 @@ class StatusManager @Inject constructor() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
suspend fun reset(git: Git, diffEntry: DiffEntry, staged: Boolean) = withContext(Dispatchers.IO) {
|
suspend fun reset(git: Git, diffEntry: DiffEntry, staged: Boolean) = withContext(Dispatchers.IO) {
|
||||||
if(staged) {
|
if (staged) {
|
||||||
git
|
git
|
||||||
.reset()
|
.reset()
|
||||||
.addPath(diffEntry.filePath)
|
.addPath(diffEntry.filePath)
|
||||||
@ -97,6 +97,23 @@ class StatusManager @Inject constructor() {
|
|||||||
|
|
||||||
loadStatus(git)
|
loadStatus(git)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
suspend fun unstageAll(git: Git) = withContext(Dispatchers.IO) {
|
||||||
|
git
|
||||||
|
.reset()
|
||||||
|
.call()
|
||||||
|
|
||||||
|
loadStatus(git)
|
||||||
|
}
|
||||||
|
|
||||||
|
suspend fun stageAll(git: Git) = withContext(Dispatchers.IO) {
|
||||||
|
git
|
||||||
|
.add()
|
||||||
|
.addFilepattern(".")
|
||||||
|
.call()
|
||||||
|
|
||||||
|
loadStatus(git)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
sealed class StageStatus {
|
sealed class StageStatus {
|
||||||
|
@ -72,6 +72,7 @@ fun UncommitedChanges(
|
|||||||
.weight(5f)
|
.weight(5f)
|
||||||
.fillMaxWidth(),
|
.fillMaxWidth(),
|
||||||
title = "Staged",
|
title = "Staged",
|
||||||
|
allActionTitle = "Unstage all",
|
||||||
actionTitle = "Unstage",
|
actionTitle = "Unstage",
|
||||||
actionColor = MaterialTheme.colors.error,
|
actionColor = MaterialTheme.colors.error,
|
||||||
diffEntries = staged,
|
diffEntries = staged,
|
||||||
@ -81,6 +82,9 @@ fun UncommitedChanges(
|
|||||||
},
|
},
|
||||||
onReset = { diffEntry ->
|
onReset = { diffEntry ->
|
||||||
gitManager.resetStaged(diffEntry)
|
gitManager.resetStaged(diffEntry)
|
||||||
|
},
|
||||||
|
onAllAction = {
|
||||||
|
gitManager.unstageAll()
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -99,7 +103,11 @@ fun UncommitedChanges(
|
|||||||
},
|
},
|
||||||
onReset = { diffEntry ->
|
onReset = { diffEntry ->
|
||||||
gitManager.resetUnstaged(diffEntry)
|
gitManager.resetUnstaged(diffEntry)
|
||||||
}
|
},
|
||||||
|
{
|
||||||
|
gitManager.stageAll()
|
||||||
|
},
|
||||||
|
allActionTitle = "Stage all"
|
||||||
)
|
)
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
@ -143,6 +151,7 @@ fun UncommitedChanges(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@OptIn(ExperimentalAnimationApi::class)
|
||||||
@Composable
|
@Composable
|
||||||
private fun EntriesList(
|
private fun EntriesList(
|
||||||
modifier: Modifier,
|
modifier: Modifier,
|
||||||
@ -153,12 +162,15 @@ private fun EntriesList(
|
|||||||
onDiffEntrySelected: (DiffEntry) -> Unit,
|
onDiffEntrySelected: (DiffEntry) -> Unit,
|
||||||
onDiffEntryOptionSelected: (DiffEntry) -> Unit,
|
onDiffEntryOptionSelected: (DiffEntry) -> Unit,
|
||||||
onReset: (DiffEntry) -> Unit,
|
onReset: (DiffEntry) -> Unit,
|
||||||
|
onAllAction: () -> Unit,
|
||||||
|
allActionTitle: String,
|
||||||
) {
|
) {
|
||||||
|
|
||||||
Card(
|
Card(
|
||||||
modifier = modifier
|
modifier = modifier
|
||||||
) {
|
) {
|
||||||
Column {
|
Column {
|
||||||
|
Box {
|
||||||
Text(
|
Text(
|
||||||
modifier = Modifier
|
modifier = Modifier
|
||||||
.background(color = MaterialTheme.colors.headerBackground)
|
.background(color = MaterialTheme.colors.headerBackground)
|
||||||
@ -172,6 +184,19 @@ private fun EntriesList(
|
|||||||
maxLines = 1,
|
maxLines = 1,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Button(
|
||||||
|
onClick = onAllAction,
|
||||||
|
modifier = Modifier
|
||||||
|
.padding(horizontal = 16.dp)
|
||||||
|
.align(Alignment.CenterEnd),
|
||||||
|
elevation = ButtonDefaults.elevation(0.dp, 0.dp, 0.dp),
|
||||||
|
colors = ButtonDefaults.buttonColors(backgroundColor = actionColor)
|
||||||
|
) {
|
||||||
|
Text(allActionTitle, fontSize = 10.sp)
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
ScrollableLazyColumn(
|
ScrollableLazyColumn(
|
||||||
modifier = Modifier.fillMaxSize(),
|
modifier = Modifier.fillMaxSize(),
|
||||||
) {
|
) {
|
||||||
|
Loading…
Reference in New Issue
Block a user