Skip to content

Commit cbd7511

Browse files
author
Stephan Dilly
committed
add error handling on potential error in ignore (#191)
1 parent fc142b4 commit cbd7511

File tree

2 files changed

+21
-9
lines changed

2 files changed

+21
-9
lines changed

asyncgit/src/sync/ignore.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ static GITIGNORE: &str = ".gitignore";
88
/// add file or path to root ignore file
99
pub fn add_to_ignore(
1010
repo_path: &str,
11-
path_to_ignore: String,
11+
path_to_ignore: &str,
1212
) -> Result<()> {
1313
scope_time!("add_to_ignore");
1414

src/components/changes.rs

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -172,15 +172,27 @@ impl ChangesComponent {
172172
false
173173
}
174174

175-
fn add_to_ignore(&mut self) -> Result<bool> {
175+
fn add_to_ignore(&mut self) -> bool {
176176
if let Some(tree_item) = self.selection() {
177-
sync::add_to_ignore(CWD, tree_item.info.full_path)?;
178-
self.queue
179-
.borrow_mut()
180-
.push_back(InternalEvent::Update(NeedsUpdate::ALL));
181-
return Ok(true);
177+
if let Err(e) =
178+
sync::add_to_ignore(CWD, &tree_item.info.full_path)
179+
{
180+
self.queue.borrow_mut().push_back(
181+
InternalEvent::ShowErrorMsg(format!(
182+
"ignore error:\n{}\nfile:\n{:?}",
183+
e, tree_item.info.full_path
184+
)),
185+
);
186+
} else {
187+
self.queue.borrow_mut().push_back(
188+
InternalEvent::Update(NeedsUpdate::ALL),
189+
);
190+
191+
return true;
192+
}
182193
}
183-
Ok(false)
194+
195+
false
184196
}
185197
}
186198

@@ -306,7 +318,7 @@ impl Component for ChangesComponent {
306318
if self.is_working_dir
307319
&& !self.is_empty() =>
308320
{
309-
Ok(self.add_to_ignore()?)
321+
Ok(self.add_to_ignore())
310322
}
311323
_ => Ok(false),
312324
};

0 commit comments

Comments
 (0)