Package fsgitignore adapts go-git's functions for use with an io/fs filesystem.
// Package fsgitignore adapts go-git's functions for use with an io/fs filesystem.
package fsgitignore
import (
"bufio"
"bytes"
_ "embed"
"errors"
"io"
"io/fs"
"os"
"os/exec"
"path/filepath"
"strings"
"sync"
"syscall"
"github.com/go-git/go-git/v5/plumbing/format/gitignore"
)
const (
commentPrefix = "#"
gitDir = ".git"
gitignoreFile = ".gitignore"
infoExcludeFile = gitDir + "/info/exclude"
)
// Split splits a file path into segments, i.e. the format the upstream gitignore package prefers.
func Split(path string) []string {
if path == "." {
return []string{}
}
return strings.Split(filepath.Clean(path), string(os.PathSeparator))
}
// ParsePatterns turns string patterns into parsed versions.
// The domain is usually a relative path split into segments (s
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key