Skip to content

Commit aa7c190

Browse files
committed
adapt to changes in gix-dir
1 parent 4d5767c commit aa7c190

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

gitoxide-core/src/repository/clean.rs

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -210,6 +210,11 @@ pub(crate) mod function {
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 {
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 {
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)?;

0 commit comments

Comments
 (0)