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

Function LoadRepo

commands/execenv/loading.go:18–38  ·  view source on GitHub ↗

LoadRepo is a pre-run function that load the repository for use in a command

(env *Env)

Source from the content-addressed store, hash-verified

16
17// LoadRepo is a pre-run function that load the repository for use in a command
18func LoadRepo(env *Env) func(*cobra.Command, []string) error {
19 return func(cmd *cobra.Command, args []string) error {
20 cwd, err := os.Getwd()
21 if err != nil {
22 return fmt.Errorf("unable to get the current working directory: %q", err)
23 }
24
25 // Note: we are not loading clocks here because we assume that LoadRepo is only used
26 // when we don't manipulate entities, or as a child call of LoadBackend which will
27 // read all clocks anyway.
28 env.Repo, err = repository.OpenGoGitRepo(cwd, gitBugNamespace, nil)
29 if err == repository.ErrNotARepo {
30 return fmt.Errorf("%s must be run from within a git Repo", RootCommandName)
31 }
32 if err != nil {
33 return err
34 }
35
36 return nil
37 }
38}
39
40// LoadRepoEnsureUser is the same as LoadRepo, but also ensure that the user has configured
41// an identity. Use this pre-run function when an error after using the configured user won't

Callers 4

newWebUICommandFunction · 0.92
newBridgeAuthRmFunction · 0.92
LoadRepoEnsureUserFunction · 0.85
LoadBackendFunction · 0.85

Calls 2

OpenGoGitRepoFunction · 0.92
ErrorfMethod · 0.80

Tested by

no test coverage detected