gopass
gopass copied to clipboard
feature request: gopass move to rename/move directories
Summary
Currently gopass move
only supports moving password entries around. Is it possible to also implement moving whole subpaths/directories around? For git backend this is as simple as git mv && git commit && git push
, which is my workaround for now.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
@dominikschulz apparently things went a slightly different direction at some point.
Today I did a gopass show SomeFolder/SomeSecret
and having used gopass edit --create SomeFolder/SomeSecret/AnotherSecret
I got a message telling me that I had both a secret and a folder at the path, so to use gopass list
to view the folder contents, and gopass show
to view the secret. This worked as expected, but trying a gopass mv SomeFolder/SomeSecret SomeFolder/NewSecretName
, it instead moved BOTH the SomeSecret
folder AND the SomeSecret
entry under the new path. I would hope that it could be scoped to prefer only selecting the secret to be moved if both a secret and a directory exist. The worst part was I ended up with SomeSecret/NewSecretName/SomeSecret/AnotherSecret and SomeSecret/NewSecretName/SomeSecret, so I get to work through some duplication in the path as well.
Confirmed to still be the case as described in the latest comment.
So I've encountered the problem before, that after creating a secret some/example
I created another secret some/example/account2
.
This is not ideal, but also not a big deal, git
mv, commit, push …
However when attempting to use gopass move some/example some/example/account1
, it quietly moves the dir instead of the file, resulting in this:
some/example/account1/account2 // this is account2
some/example // this is account1
I think I've identified the code responsible and the necessary change, however I've not written in Go before.
https://github.com/gopasspw/gopass/blob/a247d970986801d324e35bfa423dd312e0e663ef/internal/store/root/move.go#L41-L47
// L45 becomes
srcIsDir := r.IsDir(ctx, from) && !r.Exists(ctx, from) // move the dir iff no secret exists at `from`
// Insert this at L47
if r.IsDir(ctx, from) && r.Exists(ctx, from) {
// Output some warning about the ambiguity and state that gopass is moving the secret
// Maybe ask for confirmation
// (Do _not_ ask if they instead want to move the dir, in my opinion)
}
https://github.com/gopasspw/gopass/blob/a247d970986801d324e35bfa423dd312e0e663ef/internal/store/root/move.go#L48-L54
Thanks for the investigation, you almost had it, there was another problem slightly further down in moveFromTo
, where we weren't using srcIsDir
properly and so fixing it here didn't help.
But hopefully #2718 should now fix this (very) longstanding issue 😳 😅
thanks!