mirror of
https://github.com/gitui-org/gitui
synced 2026-05-24 09:28:21 +00:00
support Stage all/Unstage all (closes #82)
This commit is contained in:
parent
0bf18331a5
commit
dbd7dd33ea
5 changed files with 58 additions and 4 deletions
|
|
@ -9,6 +9,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||||
### Changed
|
### Changed
|
||||||
- changed hotkeys for selecting stage/workdir (**[w] / [s]** now to change between workdir and stage) and added hotkeys (`[1234]`) to switch to tabs directly ([#92](https://github.com/extrawurst/gitui/issues/92))
|
- changed hotkeys for selecting stage/workdir (**[w] / [s]** now to change between workdir and stage) and added hotkeys (`[1234]`) to switch to tabs directly ([#92](https://github.com/extrawurst/gitui/issues/92))
|
||||||
- `arrow-up`/`down` on bottom/top of status file list switches focus ([#105](https://github.com/extrawurst/gitui/issues/105))
|
- `arrow-up`/`down` on bottom/top of status file list switches focus ([#105](https://github.com/extrawurst/gitui/issues/105))
|
||||||
|
- New `Stage all [a]`/`Unstage all [a]` in changes lists ([#82](https://github.com/extrawurst/gitui/issues/82))
|
||||||
|
|
||||||
## [0.5.0] - 2020-06-01
|
## [0.5.0] - 2020-06-01
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ use scopetime::scope_time;
|
||||||
use std::{fs, path::Path};
|
use std::{fs, path::Path};
|
||||||
|
|
||||||
///
|
///
|
||||||
pub fn reset_stage(repo_path: &str, path: &Path) -> Result<()> {
|
pub fn reset_stage(repo_path: &str, path: &str) -> Result<()> {
|
||||||
scope_time!("reset_stage");
|
scope_time!("reset_stage");
|
||||||
|
|
||||||
let repo = repo(repo_path)?;
|
let repo = repo(repo_path)?;
|
||||||
|
|
@ -299,7 +299,7 @@ mod tests {
|
||||||
|
|
||||||
assert_eq!(get_statuses(repo_path), (0, 1));
|
assert_eq!(get_statuses(repo_path), (0, 1));
|
||||||
|
|
||||||
reset_stage(repo_path, file_path).unwrap();
|
reset_stage(repo_path, file_path.to_str().unwrap()).unwrap();
|
||||||
|
|
||||||
assert_eq!(get_statuses(repo_path), (1, 0));
|
assert_eq!(get_statuses(repo_path), (1, 0));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -97,8 +97,7 @@ impl ChangesComponent {
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let path =
|
let path = tree_item.info.full_path.as_str();
|
||||||
Path::new(tree_item.info.full_path.as_str());
|
|
||||||
sync::reset_stage(CWD, path)?;
|
sync::reset_stage(CWD, path)?;
|
||||||
return Ok(true);
|
return Ok(true);
|
||||||
}
|
}
|
||||||
|
|
@ -107,6 +106,26 @@ impl ChangesComponent {
|
||||||
Ok(false)
|
Ok(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fn index_add_all(&mut self) -> Result<()> {
|
||||||
|
sync::stage_add_all(CWD, "*")?;
|
||||||
|
|
||||||
|
self.queue
|
||||||
|
.borrow_mut()
|
||||||
|
.push_back(InternalEvent::Update(NeedsUpdate::ALL));
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
fn stage_remove_all(&mut self) -> Result<()> {
|
||||||
|
sync::reset_stage(CWD, "*")?;
|
||||||
|
|
||||||
|
self.queue
|
||||||
|
.borrow_mut()
|
||||||
|
.push_back(InternalEvent::Update(NeedsUpdate::ALL));
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
fn dispatch_reset_workdir(&mut self) -> bool {
|
fn dispatch_reset_workdir(&mut self) -> bool {
|
||||||
if let Some(tree_item) = self.selection() {
|
if let Some(tree_item) = self.selection() {
|
||||||
let is_folder =
|
let is_folder =
|
||||||
|
|
@ -160,6 +179,11 @@ impl Component for ChangesComponent {
|
||||||
let some_selection = self.selection().is_some();
|
let some_selection = self.selection().is_some();
|
||||||
|
|
||||||
if self.is_working_dir {
|
if self.is_working_dir {
|
||||||
|
out.push(CommandInfo::new(
|
||||||
|
commands::STAGE_ALL,
|
||||||
|
some_selection,
|
||||||
|
self.focused(),
|
||||||
|
));
|
||||||
out.push(CommandInfo::new(
|
out.push(CommandInfo::new(
|
||||||
commands::STAGE_ITEM,
|
commands::STAGE_ITEM,
|
||||||
some_selection,
|
some_selection,
|
||||||
|
|
@ -181,6 +205,11 @@ impl Component for ChangesComponent {
|
||||||
some_selection,
|
some_selection,
|
||||||
self.focused(),
|
self.focused(),
|
||||||
));
|
));
|
||||||
|
out.push(CommandInfo::new(
|
||||||
|
commands::UNSTAGE_ALL,
|
||||||
|
some_selection,
|
||||||
|
self.focused(),
|
||||||
|
));
|
||||||
out.push(
|
out.push(
|
||||||
CommandInfo::new(
|
CommandInfo::new(
|
||||||
commands::COMMIT_OPEN,
|
commands::COMMIT_OPEN,
|
||||||
|
|
@ -221,6 +250,17 @@ impl Component for ChangesComponent {
|
||||||
}
|
}
|
||||||
Ok(true)
|
Ok(true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
keys::STATUS_STAGE_ALL if !self.is_empty() => {
|
||||||
|
if self.is_working_dir {
|
||||||
|
self.index_add_all()?;
|
||||||
|
} else {
|
||||||
|
self.stage_remove_all()?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(true)
|
||||||
|
}
|
||||||
|
|
||||||
keys::STATUS_RESET_FILE
|
keys::STATUS_RESET_FILE
|
||||||
if self.is_working_dir =>
|
if self.is_working_dir =>
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -44,6 +44,7 @@ pub const SHIFT_DOWN: KeyEvent =
|
||||||
with_mod(KeyCode::Down, KeyModifiers::SHIFT);
|
with_mod(KeyCode::Down, KeyModifiers::SHIFT);
|
||||||
pub const ENTER: KeyEvent = no_mod(KeyCode::Enter);
|
pub const ENTER: KeyEvent = no_mod(KeyCode::Enter);
|
||||||
pub const STATUS_STAGE_FILE: KeyEvent = no_mod(KeyCode::Enter);
|
pub const STATUS_STAGE_FILE: KeyEvent = no_mod(KeyCode::Enter);
|
||||||
|
pub const STATUS_STAGE_ALL: KeyEvent = no_mod(KeyCode::Char('a'));
|
||||||
pub const STATUS_RESET_FILE: KeyEvent =
|
pub const STATUS_RESET_FILE: KeyEvent =
|
||||||
with_mod(KeyCode::Char('D'), KeyModifiers::SHIFT);
|
with_mod(KeyCode::Char('D'), KeyModifiers::SHIFT);
|
||||||
pub const STATUS_IGNORE_FILE: KeyEvent = no_mod(KeyCode::Char('i'));
|
pub const STATUS_IGNORE_FILE: KeyEvent = no_mod(KeyCode::Char('i'));
|
||||||
|
|
|
||||||
|
|
@ -140,12 +140,24 @@ pub mod commands {
|
||||||
CMD_GROUP_CHANGES,
|
CMD_GROUP_CHANGES,
|
||||||
);
|
);
|
||||||
///
|
///
|
||||||
|
pub static STAGE_ALL: CommandText = CommandText::new(
|
||||||
|
"Stage All [a]",
|
||||||
|
"stage all changes (in unstaged files)",
|
||||||
|
CMD_GROUP_CHANGES,
|
||||||
|
);
|
||||||
|
///
|
||||||
pub static UNSTAGE_ITEM: CommandText = CommandText::new(
|
pub static UNSTAGE_ITEM: CommandText = CommandText::new(
|
||||||
"Unstage Item [enter]",
|
"Unstage Item [enter]",
|
||||||
"unstage currently selected file or entire path",
|
"unstage currently selected file or entire path",
|
||||||
CMD_GROUP_CHANGES,
|
CMD_GROUP_CHANGES,
|
||||||
);
|
);
|
||||||
///
|
///
|
||||||
|
pub static UNSTAGE_ALL: CommandText = CommandText::new(
|
||||||
|
"Unstage all [a]",
|
||||||
|
"unstage all files (in staged files)",
|
||||||
|
CMD_GROUP_CHANGES,
|
||||||
|
);
|
||||||
|
///
|
||||||
pub static RESET_ITEM: CommandText = CommandText::new(
|
pub static RESET_ITEM: CommandText = CommandText::new(
|
||||||
"Reset Item [D]",
|
"Reset Item [D]",
|
||||||
"revert changes in selected file or entire path",
|
"revert changes in selected file or entire path",
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue