MCPcopy Index your code
hub / github.com/cli/cli / IsIgnored

Method IsIgnored

git/client.go:731–747  ·  view source on GitHub ↗

IsIgnored reports whether the given path is ignored by .gitignore rules. Returns an error for fatal git failures (e.g. path outside repository).

(ctx context.Context, path string)

Source from the content-addressed store, hash-verified

729// IsIgnored reports whether the given path is ignored by .gitignore rules.
730// Returns an error for fatal git failures (e.g. path outside repository).
731func (c *Client) IsIgnored(ctx context.Context, path string) (bool, error) {
732 cmd, err := c.Command(ctx, "check-ignore", "-q", "--", path)
733 if err != nil {
734 return false, err
735 }
736 _, err = cmd.Output()
737 if err == nil {
738 return true, nil
739 }
740 // Exit 1 here means we can confirm the path is not ignored.
741 // Any other error is a real git error.
742 var exitErr *exec.ExitError
743 if errors.As(err, &exitErr) && exitErr.ExitCode() == 1 {
744 return false, nil
745 }
746 return false, err
747}
748
749// ShortSHA returns the first 8 characters of a SHA hash for display purposes.
750func ShortSHA(sha string) string {

Callers 2

TestClientIsIgnoredFunction · 0.95
checkInstalledSkillDirsFunction · 0.80

Calls 3

CommandMethod · 0.95
OutputMethod · 0.65
ExitCodeMethod · 0.65

Tested by 1

TestClientIsIgnoredFunction · 0.76