amtoine / nu-git-manager

A collection of Nushell tools to manage Git repositories.
GNU General Public License v3.0
27 stars 2 forks source link

`gm remove` does not remove empty directories #76

Closed amtoine closed 11 months ago

amtoine commented 1 year ago

Describe the bug

when using gm remove empty parent directories are left there untouched. this could break manual scripts that try to list stuff in the store...

How to reproduce

tk run --clean {
    gm update-cache
    gm clone https://github.com/amtoine/nu-git-manager --depth 1
    gm remove --no-confirm nu-git-manager

    print ($env.GIT_REPOS_HOME | path join "github.com/amtoine" | path exists)
    print ($env.GIT_REPOS_HOME | path join "github.com/amtoine" | ls $in | is-empty)
}

will print

true
true

Expected behavior

i expected gm remove to clean the empty mess and thus the repro snippet above to print false twice.

Configuration

key value
version 0.86.1
branch main
commit_hash 0ca8fcf58c02bef31f1eb65e001d71f5648b3b35
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.71.1 (eb26296b5 2023-08-03)
rust_channel 1.71.1-x86_64-unknown-linux-gnu
cargo_version cargo 1.71.1 (7f1d04c00 2023-07-29)
build_time 2023-11-02 17:56:54 +01:00
build_rust_channel release
allocator mimalloc
features default, sqlite, trash, which, zip
installed_plugins jwalk, nu_plugin_explore

Additional context

No response

melMass commented 1 year ago

Agreed, it could be a for/try loop from the leaf to the root using rm since it does delete empty dir, and stop when it errors out

amtoine commented 1 year ago

Agreed, it could be a for/try loop from the leaf to the root using rm since it does delete empty dir, and stop when it errors out

yup

i'm on a PR for this already :wink: went for the recursive way with unfold :yum: