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
|
package pama
import (
"fmt"
"git.sr.ht/~rjarry/aerc/lib/pama/models"
"git.sr.ht/~rjarry/aerc/lib/pama/revctrl"
"git.sr.ht/~rjarry/aerc/lib/pama/store"
)
type (
detectFn func(string) (string, string, error)
rcFn func(string, string) (models.RevisionController, error)
storeFn func() models.PersistentStorer
)
type PatchManager struct {
detect detectFn
rc rcFn
store storeFn
}
func New() PatchManager {
return PatchManager{
detect: revctrl.Detect,
rc: revctrl.New,
store: store.Store,
}
}
func FromFunc(d detectFn, r rcFn, s storeFn) PatchManager {
return PatchManager{
detect: d,
rc: r,
store: s,
}
}
func storeErr(err error) error {
if err == nil {
return nil
}
return fmt.Errorf("store error: %w", err)
}
func revErr(err error) error {
if err == nil {
return nil
}
return fmt.Errorf("revision control error: %w", err)
}
|