gitcha

package module
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 13, 2023 License: MIT Imports: 4 Imported by: 4

README

gitcha

Latest Release Build Status Coverage Status Go ReportCard GoDoc

Go helpers to work with git repositories

Examples

import "github.com/muesli/gitcha"

// returns the directory of the git repository path is a member of:
repo, err := gitcha.GitRepoForPath(path)

// finds files from list in path. It respects all .gitignores it finds while
// traversing paths:
ch, err := gitcha.FindFiles(path, []string{"*.md"})
for v := range ch {
    fmt.Println(v.Path)
}

// finds files, excluding any matches in a given set of ignore patterns:
ch, err := gitcha.FindFilesExcept(path, []string{"*.md"}, []string{".*"})
...

// if you are only interested in the first match:
result, err := gitcha.FindFirstFile(path, []string{"*.md"})
...

// just for convenience:
ok := gitcha.IsPathInGit(path)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FindAllFiles added in v0.3.0

func FindAllFiles(path string, list []string) (chan SearchResult, error)

FindAllFiles finds all files from list in path. It does not respect any gitignore files.

func FindAllFilesExcept added in v0.3.0

func FindAllFilesExcept(path string, list, ignorePatterns []string) (chan SearchResult, error)

FindAllFilesExcept finds all files from list in path. It does not respect any gitignore files.

func FindFiles

func FindFiles(path string, list []string) (chan SearchResult, error)

FindFiles finds files from list in path. It respects all .gitignores it finds while traversing paths.

func FindFilesExcept added in v0.2.0

func FindFilesExcept(path string, list, ignorePatterns []string) (chan SearchResult, error)

FindFilesExcept finds files from a list in a path, excluding any matches in a given set of ignore patterns. It also respects all .gitignores it finds while traversing paths.

func GitRepoForPath

func GitRepoForPath(path string) (string, error)

GitRepoForPath returns the directory of the git repository path is a member of, or an error.

func IsPathInGit

func IsPathInGit(path string) bool

IsPathInGit returns true when a path is part of a git repository.

Types

type SearchResult

type SearchResult struct {
	Path string
	Info os.FileInfo
}

SearchResult combines the absolute path of a file with a FileInfo struct.

func FindFirstFile

func FindFirstFile(path string, list []string) (SearchResult, error)

FindFirstFile looks for files from a list in a path, returning the first match it finds. It respects all .gitignores it finds along the way.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL