-
-
Notifications
You must be signed in to change notification settings - Fork 479
/
git.go
33 lines (27 loc) · 815 Bytes
/
git.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
package action
import (
"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/v2"
)
// Git passes the git command to the underlying backend.
func (s *Action) Git(c *cli.Context) error {
ctx := ctxutil.WithGlobalFlags(c)
store := c.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 := c.Args().Slice()
out.Noticef(ctx, "Running 'git %s' in %s...", strings.Join(args, " "), sub.Path())
cmd := exec.CommandContext(ctx, "git", args...)
cmd.Dir = sub.Path()
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
return cmd.Run()
}