-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathproxy.go
More file actions
34 lines (29 loc) · 1.02 KB
/
proxy.go
File metadata and controls
34 lines (29 loc) · 1.02 KB
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
package git
import (
"context"
"github.com/go-git/go-billy/v5/memfs"
"github.com/go-git/go-git/v5"
"github.com/go-git/go-git/v5/storage/memory"
"github.com/gov4git/lib4git/must"
)
type Proxy interface {
// CloneOne fetches just the branch specified in addr then checks out the branch in addr, creating it if not present.
CloneOne(ctx context.Context, addr Address) Cloned
CloneOneTo(ctx context.Context, addr Address, to *Repository) Cloned
// CloneAll fetches all branches then checks out the branch in addr, creating it if not present.
CloneAll(ctx context.Context, addr Address) Cloned
CloneAllTo(ctx context.Context, addr Address, to *Repository) Cloned
}
type Cloned interface {
// Push all branches to the origin.
Push(context.Context)
// Pull the branches indicated by the clone call that created this clone.
Pull(context.Context)
Repo() *Repository
Tree() *Tree
}
func initInMemory(ctx context.Context) *Repository {
repo, err := git.Init(memory.NewStorage(), memfs.New())
must.NoError(ctx, err)
return repo
}