mirror of
https://github.com/gopasspw/gopass.git
synced 2025-12-08 19:24:54 +00:00
* feat: add reorg command for bulk secret reorganization This commit introduces the `gopass reorg` command, which allows for bulk reorganization of secrets within a password store. The command works by listing secrets in a temporary file, which the user can then edit in their default editor. After the editor is closed, gopass calculates the necessary moves, shows a diff for confirmation, and then executes the moves as a single commit. This feature addresses issue #1866, providing a more efficient way to manage large password stores. * feat: add reorg command for bulk secret reorganization This commit introduces the `gopass reorg` command, which allows for bulk reorganization of secrets within a password store. The command works by listing secrets in a temporary file, which the user can then edit in their default editor. After the editor is closed, gopass calculates the necessary moves, shows a diff for confirmation, and then executes the moves as a single commit. This feature addresses issue #1866, providing a more efficient way to manage large password stores. * feat: add reorg command for bulk secret reorganization This commit introduces the `gopass reorg` command, which allows for bulk reorganization of secrets within a password store. The command works by listing secrets in a temporary file, which the user can then edit in their default editor. After the editor is closed, gopass calculates the necessary moves, shows a diff for confirmation, and then executes the moves as a single commit. This feature addresses issue #1866, providing a more efficient way to manage large password stores. * feat: add reorg command for bulk secret reorganization This commit introduces the `gopass reorg` command, which allows for bulk reorganization of secrets within a password store. The command works by listing secrets in a temporary file, which the user can then edit in their default editor. After the editor is closed, gopass calculates the necessary moves, shows a diff for confirmation, and then executes the moves as a single commit. This feature addresses issue #1866, providing a more efficient way to manage large password stores. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
59 lines
1.3 KiB
Go
59 lines
1.3 KiB
Go
package action
|
|
|
|
import (
|
|
"bytes"
|
|
"os"
|
|
"testing"
|
|
|
|
"github.com/gopasspw/gopass/internal/out"
|
|
"github.com/gopasspw/gopass/pkg/ctxutil"
|
|
"github.com/gopasspw/gopass/pkg/gopass/secrets"
|
|
"github.com/gopasspw/gopass/tests/gptest"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
func TestReorg(t *testing.T) {
|
|
u := gptest.NewUnitTester(t)
|
|
|
|
ctx := t.Context()
|
|
ctx = ctxutil.WithAlwaysYes(ctx, true)
|
|
ctx = ctxutil.WithInteractive(ctx, false)
|
|
ctx = ctxutil.WithTerminal(ctx, true)
|
|
ctx = ctxutil.WithHidden(ctx, true)
|
|
|
|
act, err := newMock(ctx, u.StoreDir(""))
|
|
require.NoError(t, err)
|
|
require.NotNil(t, act)
|
|
ctx = act.cfg.WithConfig(ctx)
|
|
|
|
buf := &bytes.Buffer{}
|
|
out.Stdout = buf
|
|
out.Stderr = buf
|
|
defer func() {
|
|
out.Stdout = os.Stdout
|
|
out.Stderr = os.Stderr
|
|
}()
|
|
|
|
t.Run("move foo to bar", func(t *testing.T) {
|
|
defer buf.Reset()
|
|
|
|
// create a secret
|
|
sec := secrets.NewAKVWithData("foo", nil, "", false)
|
|
require.NoError(t, act.Store.Set(ctxutil.WithGitCommit(ctx, false), "foo", sec))
|
|
buf.Reset()
|
|
|
|
initial := []string{"foo"}
|
|
modified := []string{"bar"}
|
|
|
|
require.NoError(t, act.ReorgAfterEdit(ctx, initial, modified))
|
|
|
|
// check that foo is now bar
|
|
_, err := act.Store.Get(ctx, "bar")
|
|
require.NoError(t, err)
|
|
|
|
// check that foo is gone
|
|
_, err = act.Store.Get(ctx, "foo")
|
|
require.Error(t, err)
|
|
})
|
|
}
|