MCPcopy Create free account
hub / github.com/appleboy/CodeGPT / CanExecuteGitDiff

Method CanExecuteGitDiff

git/git.go:177–188  ·  view source on GitHub ↗

CanExecuteGitDiff checks if git diff can be executed in the current directory. It returns an error if the current directory is not a git repository or if git diff cannot be executed.

(ctx context.Context)

Source from the content-addressed store, hash-verified

175// CanExecuteGitDiff checks if git diff can be executed in the current directory.
176// It returns an error if the current directory is not a git repository or if git diff cannot be executed.
177func (c *Command) CanExecuteGitDiff(ctx context.Context) error {
178 output, err := c.checkGitRepository(ctx).Output()
179 if err != nil {
180 return errors.New("not a git repository (or any of the parent directories)")
181 }
182
183 if strings.TrimSpace(string(output)) != "true" {
184 return errors.New("not inside a git working tree")
185 }
186
187 return nil
188}
189
190// Diff compares the differences between two sets of data.
191// It returns a string representing the differences and an error.

Callers 2

TestCanExecuteGitDiffFunction · 0.80
checkFunction · 0.80

Calls 1

checkGitRepositoryMethod · 0.95

Tested by 1

TestCanExecuteGitDiffFunction · 0.64