Files
Dominik Schulz 7c63ba09b7 chore(deps): migrate from urfave/cli v2 to v3 (#3428)
Migrate the entire codebase from github.com/urfave/cli/v2 to
github.com/urfave/cli/v3 (v3.9.0).

Key breaking changes addressed:
- cli.App removed, replaced by *cli.Command
- ActionFunc signature: func(*Context) error -> func(context.Context, *Command) error
- BeforeFunc signature: func(*Context) error -> func(context.Context, *Command) (context.Context, error)
- app.RunContext -> app.Run
- app.EnableBashCompletion -> app.EnableShellCompletion
- Subcommands field renamed to Commands
- EnvVars on flags -> Sources: cli.EnvVars(...)
- cli.NewContext removed; test helpers updated to use cmd.Run() pattern
- cli.Flag interface updated (Apply removed, Get/PreParse/PostParse/Set added)
- VersionPrinter type changed to func(*Command)

Also updates .capabilities.json baseline to reflect new cli/v3 call paths.

Signed-off-by: Dominik Schulz <dominik.schulz@gauner.org>
2026-05-16 18:13:19 +02:00

35 lines
882 B
Go

package action
import (
"context"
"os"
"os/exec"
"strings"
"github.com/gopasspw/gopass/internal/action/exit"
"github.com/gopasspw/gopass/internal/out"
"github.com/gopasspw/gopass/pkg/ctxutil"
"github.com/urfave/cli/v3"
)
// Git passes the git command to the underlying backend.
func (s *syncHandler) Git(ctx context.Context, cmd *cli.Command) error {
ctx = ctxutil.WithGlobalFlags(ctx, cmd)
store := cmd.String("store")
sub, err := s.Store.GetSubStore(store)
if err != nil || sub == nil {
return exit.Error(exit.Git, err, "failed to get sub store %s: %s", store, err)
}
args := cmd.Args().Slice()
out.Noticef(ctx, "Running 'git %s' in %s...", strings.Join(args, " "), sub.Path())
gitCmd := exec.CommandContext(ctx, "git", args...)
gitCmd.Dir = sub.Path()
gitCmd.Stdout = os.Stdout
gitCmd.Stderr = os.Stderr
gitCmd.Stdin = os.Stdin
return gitCmd.Run()
}