MCPcopy Index your code
hub / github.com/git-bug/git-bug / LoadBackend

Function LoadBackend

commands/execenv/loading.go:61–91  ·  view source on GitHub ↗

LoadBackend is a pre-run function that load the repository and the Backend for use in a command When using this function you also need to use CloseBackend as a post-run

(env *Env)

Source from the content-addressed store, hash-verified

59// LoadBackend is a pre-run function that load the repository and the Backend for use in a command
60// When using this function you also need to use CloseBackend as a post-run
61func LoadBackend(env *Env) func(*cobra.Command, []string) error {
62 return func(cmd *cobra.Command, args []string) error {
63 err := LoadRepo(env)(cmd, args)
64 if err != nil {
65 return err
66 }
67
68 var events chan cache.BuildEvent
69 env.Backend, events = cache.NewRepoCache(env.Repo)
70
71 err = CacheBuildProgressBar(env, events)
72 if err != nil {
73 return err
74 }
75
76 cleaner := func(env *Env) interrupt.CleanerFunc {
77 return func() error {
78 if env.Backend != nil {
79 err := env.Backend.Close()
80 env.Backend = nil
81 return err
82 }
83 return nil
84 }
85 }
86
87 // Cleanup properly on interrupt
88 interrupt.RegisterCleaner(cleaner(env))
89 return nil
90 }
91}
92
93// LoadBackendEnsureUser is the same as LoadBackend, but also ensure that the user has configured
94// an identity. Use this pre-run function when an error after using the configured user won't

Callers 15

newPushCommandFunction · 0.92
newLabelCommandFunction · 0.92
newPullCommandFunction · 0.92
newWipeCommandFunction · 0.92
BridgeFunction · 0.92
BridgeAuthFunction · 0.92
GitRemoteFunction · 0.92
LabelFunction · 0.92
LsFunction · 0.92
UserFunction · 0.92
UserForQueryFunction · 0.92
NewBridgeCommandFunction · 0.92

Calls 5

NewRepoCacheFunction · 0.92
RegisterCleanerFunction · 0.92
LoadRepoFunction · 0.85
CacheBuildProgressBarFunction · 0.85
CloseMethod · 0.65

Tested by

no test coverage detected