mirror of
https://github.com/extrawurst/gitui.git
synced 2024-12-27 02:53:50 +03:00
honor options in stage_all
command (see #933)
This commit is contained in:
parent
5c661be159
commit
389bd75d46
@ -13,6 +13,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
- add highlighting matches in fuzzy finder ([#893](https://github.com/extrawurst/gitui/issues/893))
|
||||
- support `home` and `end` keys in branchlist ([#957](https://github.com/extrawurst/gitui/issues/957))
|
||||
|
||||
## Fixed
|
||||
- honor options (for untracked files) in `stage_all` command ([#933](https://github.com/extrawurst/gitui/issues/933))
|
||||
|
||||
## [0.18] - 2021-10-11
|
||||
|
||||
**rebase merge with conflicts**
|
||||
|
@ -167,7 +167,7 @@ mod tests {
|
||||
.write_all(b"file3")?;
|
||||
}
|
||||
|
||||
stage_add_all(repo_path, "*").unwrap();
|
||||
stage_add_all(repo_path, "*", None).unwrap();
|
||||
commit(repo_path, "msg").unwrap();
|
||||
|
||||
{
|
||||
|
@ -1,6 +1,6 @@
|
||||
//! sync git api (various methods)
|
||||
|
||||
use super::CommitId;
|
||||
use super::{CommitId, ShowUntrackedFilesConfig};
|
||||
use crate::{
|
||||
error::{Error, Result},
|
||||
sync::config::untracked_files_config_repo,
|
||||
@ -125,23 +125,31 @@ pub fn stage_add_file(repo_path: &str, path: &Path) -> Result<()> {
|
||||
}
|
||||
|
||||
/// like `stage_add_file` but uses a pattern to match/glob multiple files/folders
|
||||
pub fn stage_add_all(repo_path: &str, pattern: &str) -> Result<()> {
|
||||
pub fn stage_add_all(
|
||||
repo_path: &str,
|
||||
pattern: &str,
|
||||
stage_untracked: Option<ShowUntrackedFilesConfig>,
|
||||
) -> Result<()> {
|
||||
scope_time!("stage_add_all");
|
||||
|
||||
let repo = repo(repo_path)?;
|
||||
|
||||
let mut index = repo.index()?;
|
||||
|
||||
let config = untracked_files_config_repo(&repo)?;
|
||||
|
||||
if config.include_none() {
|
||||
index.update_all(vec![pattern], None)?;
|
||||
let stage_untracked = if let Some(config) = stage_untracked {
|
||||
config
|
||||
} else {
|
||||
untracked_files_config_repo(&repo)?
|
||||
};
|
||||
|
||||
if stage_untracked.include_untracked() {
|
||||
index.add_all(
|
||||
vec![pattern],
|
||||
IndexAddOption::DEFAULT,
|
||||
None,
|
||||
)?;
|
||||
} else {
|
||||
index.update_all(vec![pattern], None)?;
|
||||
}
|
||||
|
||||
index.write()?;
|
||||
@ -291,7 +299,7 @@ mod tests {
|
||||
|
||||
assert_eq!(status_count(StatusType::WorkingDir), 3);
|
||||
|
||||
stage_add_all(repo_path, "a/d").unwrap();
|
||||
stage_add_all(repo_path, "a/d", None).unwrap();
|
||||
|
||||
assert_eq!(status_count(StatusType::WorkingDir), 1);
|
||||
assert_eq!(status_count(StatusType::Stage), 2);
|
||||
@ -354,7 +362,7 @@ mod tests {
|
||||
|
||||
assert_eq!(get_statuses(repo_path), (0, 0));
|
||||
|
||||
stage_add_all(repo_path, "*").unwrap();
|
||||
stage_add_all(repo_path, "*", None).unwrap();
|
||||
|
||||
assert_eq!(get_statuses(repo_path), (0, 0));
|
||||
|
||||
@ -420,7 +428,7 @@ mod tests {
|
||||
assert_eq!(status_count(StatusType::WorkingDir), 1);
|
||||
|
||||
//expect to fail
|
||||
assert!(stage_add_all(repo_path, "sub").is_err());
|
||||
assert!(stage_add_all(repo_path, "sub", None).is_err());
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
use super::{
|
||||
filetree::FileTreeComponent,
|
||||
utils::filetree::{FileTreeItem, FileTreeItemKind},
|
||||
CommandBlocking, DrawableComponent,
|
||||
CommandBlocking, DrawableComponent, SharedOptions,
|
||||
};
|
||||
use crate::{
|
||||
components::{CommandInfo, Component, EventState},
|
||||
@ -22,6 +22,7 @@ pub struct ChangesComponent {
|
||||
is_working_dir: bool,
|
||||
queue: Queue,
|
||||
key_config: SharedKeyConfig,
|
||||
options: SharedOptions,
|
||||
}
|
||||
|
||||
impl ChangesComponent {
|
||||
@ -33,6 +34,7 @@ impl ChangesComponent {
|
||||
queue: Queue,
|
||||
theme: SharedTheme,
|
||||
key_config: SharedKeyConfig,
|
||||
options: SharedOptions,
|
||||
) -> Self {
|
||||
Self {
|
||||
files: FileTreeComponent::new(
|
||||
@ -45,6 +47,7 @@ impl ChangesComponent {
|
||||
is_working_dir,
|
||||
queue,
|
||||
key_config,
|
||||
options,
|
||||
}
|
||||
}
|
||||
|
||||
@ -95,10 +98,14 @@ impl ChangesComponent {
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
let config =
|
||||
self.options.borrow().status_show_untracked;
|
||||
|
||||
//TODO: check if we can handle the one file case with it aswell
|
||||
sync::stage_add_all(
|
||||
CWD,
|
||||
tree_item.info.full_path.as_str(),
|
||||
config,
|
||||
)?;
|
||||
|
||||
return Ok(true);
|
||||
@ -113,7 +120,9 @@ impl ChangesComponent {
|
||||
}
|
||||
|
||||
fn index_add_all(&mut self) -> Result<()> {
|
||||
sync::stage_add_all(CWD, "*")?;
|
||||
let config = self.options.borrow().status_show_untracked;
|
||||
|
||||
sync::stage_add_all(CWD, "*", config)?;
|
||||
|
||||
self.queue.push(InternalEvent::Update(NeedsUpdate::ALL));
|
||||
|
||||
|
@ -164,6 +164,7 @@ impl Status {
|
||||
queue.clone(),
|
||||
theme.clone(),
|
||||
key_config.clone(),
|
||||
options.clone(),
|
||||
),
|
||||
index: ChangesComponent::new(
|
||||
&strings::title_index(&key_config),
|
||||
@ -172,6 +173,7 @@ impl Status {
|
||||
queue.clone(),
|
||||
theme.clone(),
|
||||
key_config.clone(),
|
||||
options.clone(),
|
||||
),
|
||||
diff: DiffComponent::new(
|
||||
queue.clone(),
|
||||
|
Loading…
Reference in New Issue
Block a user