Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gm remove does not remove empty directories #76

Closed
amtoine opened this issue Nov 7, 2023 · 2 comments · Fixed by #77
Closed

gm remove does not remove empty directories #76

amtoine opened this issue Nov 7, 2023 · 2 comments · Fixed by #77
Labels
bug Something isn't working as expected core Related to the main `nu-git-manager` module

Comments

@amtoine
Copy link
Owner

amtoine commented Nov 7, 2023

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

@amtoine amtoine added bug Something isn't working as expected needs-triage The issues hasn't been triaged yet core Related to the main `nu-git-manager` module labels Nov 7, 2023
@melMass
Copy link
Collaborator

melMass commented Nov 7, 2023

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
Copy link
Owner Author

amtoine commented Nov 7, 2023

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 😉
went for the recursive way with unfold 😋

@amtoine amtoine removed the needs-triage The issues hasn't been triaged yet label Nov 9, 2023
melMass added a commit that referenced this issue Nov 17, 2023
closes #76

- adds the `fs/dir clean-empty-directories-rec` command and it's test
`tests store-cleaning`
- adds the `gm clean` command and test in `tests gm store-cleaning`
- cleans the parent of any removed directory after `gm remove` and test
that in `tests gm store-cleaning-after-remove`

---------

Co-authored-by: Mel Massadian <melmassadian@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working as expected core Related to the main `nu-git-manager` module
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants