mirror of
https://github.com/gopasspw/gopass.git
synced 2025-12-08 19:24:54 +00:00
* feat: Allow to customize commit messages This change introduces the ability for users to customize the commit message when performing actions that modify the secret store. It adds two new flags to the `edit`, `insert`, `generate`, `copy`, `move`, and `delete` commands: - `--commit-message` (`-m`): to specify the commit message directly. - `--interactive-commit` (`-i`): to open an editor for the commit message. The default behavior of using a pre-defined commit message is preserved. * fix: Use correct commit message from context This change fixes a bug where the commit message from the context was not being used correctly in the `delete` function. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
45 lines
1.1 KiB
Go
45 lines
1.1 KiB
Go
package action
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/gopasspw/gopass/internal/action/exit"
|
|
"github.com/gopasspw/gopass/pkg/ctxutil"
|
|
"github.com/gopasspw/gopass/pkg/termio"
|
|
"github.com/urfave/cli/v2"
|
|
)
|
|
|
|
// Move the content from one secret to another.
|
|
func (s *Action) Move(c *cli.Context) error {
|
|
ctx := ctxutil.WithGlobalFlags(c)
|
|
|
|
if c.Args().Len() != 2 {
|
|
return exit.Error(exit.Usage, nil, "Usage: %s mv old-path new-path", s.Name)
|
|
}
|
|
|
|
from := c.Args().Get(0)
|
|
to := c.Args().Get(1)
|
|
|
|
if !c.Bool("force") {
|
|
if s.Store.Exists(ctx, to) && !termio.AskForConfirmation(ctx, fmt.Sprintf("%s already exists. Overwrite it?", to)) {
|
|
return exit.Error(exit.Aborted, nil, "not overwriting your current secret")
|
|
}
|
|
}
|
|
|
|
// Check for custom commit message
|
|
commitMsg := fmt.Sprintf("Moved %s to %s", from, to)
|
|
if c.IsSet("commit-message") {
|
|
commitMsg = c.String("commit-message")
|
|
}
|
|
if c.Bool("interactive-commit") {
|
|
commitMsg = ""
|
|
}
|
|
ctx = ctxutil.WithCommitMessage(ctx, commitMsg)
|
|
|
|
if err := s.Store.Move(ctx, from, to); err != nil {
|
|
return exit.Error(exit.Unknown, err, "%s", err)
|
|
}
|
|
|
|
return nil
|
|
}
|