Skip to content

Commit

Permalink
Add edit.auto-create option (#2538)
Browse files Browse the repository at this point in the history
This will allow to restore the old behaviour where gopass edit would
automatically create a secret if a non-existing name was given.

RELEASE_NOTES=[ENHANCEMENT] Add edit.auto-create

Fixes #2531

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
  • Loading branch information
dominikschulz authored Feb 5, 2023
1 parent c925539 commit 8bc952d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 1 addition & 0 deletions docs/config.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ This is a list of available options:
| `create.pre-hook` | `string` | This hook is executed right before the secret creation during `gopass create`. | `None` |
| `delete.post-hook` | `string` | This hook is run right after removing a record with `gopass rm` | `None` |
| `domain-alias.<from>.insteadOf` | `string` | Alias from domain to the string value of this entry. | `` |
| `edit.auto-create` | `bool` | Automatically create new secrets when editing. | `false` |
| `edit.editor` | `string` | This setting controls which editor is used when opening a file with `gopass edit`. It takes precedence over the `$EDITOR` environment variable. This setting can contain flags. | `None` |
| `edit.post-hook` | `string` | This hook is run right after editing a record with `gopass edit` |
| `edit.pre-hook` | `string` | This hook is run right before editing a record with `gopass edit` |
Expand Down
3 changes: 2 additions & 1 deletion internal/action/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

"github.com/gopasspw/gopass/internal/action/exit"
"github.com/gopasspw/gopass/internal/audit"
"github.com/gopasspw/gopass/internal/config"
"github.com/gopasspw/gopass/internal/editor"
"github.com/gopasspw/gopass/internal/hook"
"github.com/gopasspw/gopass/internal/out"
Expand Down Expand Up @@ -86,7 +87,7 @@ func (s *Action) editUpdate(ctx context.Context, name string, content, nContent
}

func (s *Action) editGetContent(ctx context.Context, name string, create bool) (string, []byte, bool, error) {
if !s.Store.Exists(ctx, name) && !create {
if !s.Store.Exists(ctx, name) && !create && !config.Bool(ctx, "edit.auto-create") {
var err error
name, err = s.editFindName(ctx, name)
if err != nil {
Expand Down

0 comments on commit 8bc952d

Please sign in to comment.