forked from gopasspw/gopass
-
Notifications
You must be signed in to change notification settings - Fork 0
/
git.go
37 lines (30 loc) · 771 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
34
35
36
37
package action
import (
"fmt"
"github.com/fatih/color"
"github.com/urfave/cli"
)
// Git runs git commands inside the store or mounts
func (s *Action) Git(c *cli.Context) error {
store := c.String("store")
return s.Store.Git(store, c.Args()...)
}
// GitInit initializes a git repo
func (s *Action) GitInit(c *cli.Context) error {
store := c.String("store")
sk := c.String("sign-key")
return s.gitInit(store, sk)
}
func (s *Action) gitInit(store, sk string) error {
if sk == "" {
s, err := askForPrivateKey(color.CyanString("Please select a key for signing Git Commits"))
if err == nil {
sk = s
}
}
if err := s.Store.GitInit(store, sk); err != nil {
return err
}
fmt.Fprintln(color.Output, color.GreenString("Git initialized"))
return nil
}