MCPcopy Create free account
hub / github.com/augmentable-dev/tickgit / Exec

Function Exec

pkg/blame/blame.go:168–198  ·  view source on GitHub ↗

Exec uses git to lookup the blame of a file, given the supplied options

(ctx context.Context, filePath string, options *Options)

Source from the content-addressed store, hash-verified

166
167// Exec uses git to lookup the blame of a file, given the supplied options
168func Exec(ctx context.Context, filePath string, options *Options) (Result, error) {
169 gitPath, err := exec.LookPath("git")
170 if err != nil {
171 return nil, fmt.Errorf("could not find git: %w", err)
172 }
173
174 args := options.argsFromOptions(filePath)
175
176 cmd := exec.CommandContext(ctx, gitPath, args...)
177 cmd.Dir = options.Directory
178
179 stdout, err := cmd.StdoutPipe()
180 if err != nil {
181 return nil, err
182 }
183
184 if err := cmd.Start(); err != nil {
185 return nil, err
186 }
187
188 res, err := parsePorcelain(stdout)
189 if err != nil {
190 return nil, err
191 }
192
193 if err := cmd.Wait(); err != nil {
194 return nil, err
195 }
196
197 return res, nil
198}

Callers 1

FindBlameMethod · 0.92

Calls 2

parsePorcelainFunction · 0.85
argsFromOptionsMethod · 0.80

Tested by

no test coverage detected