-
-
Notifications
You must be signed in to change notification settings - Fork 497
/
loader.go
54 lines (43 loc) · 1.13 KB
/
loader.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package gitfs
import (
"context"
"fmt"
"path/filepath"
"github.com/gopasspw/gopass/internal/backend"
"github.com/gopasspw/gopass/pkg/fsutil"
"github.com/gopasspw/gopass/pkg/termio"
)
const (
name = "gitfs"
)
func init() {
backend.RegisterStorage(backend.GitFS, name, &loader{})
}
type loader struct{}
func (l loader) New(ctx context.Context, path string) (backend.Storage, error) {
return New(path)
}
// Open implements backend.RCSLoader
func (l loader) Open(ctx context.Context, path string) (backend.Storage, error) {
return New(path)
}
// Clone implements backend.RCSLoader
func (l loader) Clone(ctx context.Context, repo, path string) (backend.Storage, error) {
return Clone(ctx, repo, path)
}
// Init implements backend.RCSLoader
func (l loader) Init(ctx context.Context, path string) (backend.Storage, error) {
return Init(ctx, path, termio.DetectName(ctx, nil), termio.DetectEmail(ctx, nil))
}
func (l loader) Handles(path string) error {
if !fsutil.IsDir(filepath.Join(path, ".git")) {
return fmt.Errorf("no .git")
}
return nil
}
func (l loader) Priority() int {
return 1
}
func (l loader) String() string {
return name
}