History

adapt to changes in `gix-dir`

Sebastian Thiel committed 2 years ago

Commit aa7c1901 parent 4d5767c1 file · +18 −5Browse files

Unified · Split

gitoxide-core/src/repository/clean.rs+18−5
@@ -210,6 +210,11 @@ pub(crate) mod function { · 209 unmodified lines
210210 saw_ignored_directory |= is_ignored;
211211 saw_untracked_directory |= entry.status == gix::dir::entry::Status::Untracked;
212212 }
213+
214+ if gix::interrupt::is_triggered() {
215+ execute = false;
216+ }
217+ let mut may_remove_this_entry = execute;
213218 writeln!(
214219 out,
215220 "{maybe}{suffix} {}{} {status}",
@@ -235,7 +240,18 @@ pub(crate) mod function { · 19 unmodified lines
235240 "".into()
236241 },
237242 },
238− maybe = if execute { "removing" } else { "WOULD remove" },
243+ maybe = if entry.property == Some(gix::dir::entry::Property::EmptyDirectoryAndCWD) {
244+ may_remove_this_entry = false;
245+ if execute {
246+ "Refusing to remove empty current working directory"
247+ } else {
248+ "Would refuse to remove empty current working directory"
249+ }
250+ } else if execute {
251+ "removing"
252+ } else {
253+ "WOULD remove"
254+ },
239255 suffix = match disk_kind {
240256 Kind::Directory if entry.property == Some(gix::dir::entry::Property::EmptyDirectory) => {
241257 " empty"
@@ -249,10 +265,7 @@ pub(crate) mod function { · 7 unmodified lines
249265 },
250266 )?;
251267
252− if gix::interrupt::is_triggered() {
253− execute = false;
254− }
255− if execute {
268+ if may_remove_this_entry {
256269 let path = workdir.join(entry_path);
257270 if disk_kind.is_dir() {
258271 std::fs::remove_dir_all(path)?;