aboutsummaryrefslogtreecommitdiffstats
path: root/gitignore.go
blob: 80d14a6c101639bb226888f9d82d842110e35a54 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
package main

import (
	"os"
	"path/filepath"

	ignore "github.com/sabhiram/go-gitignore"
)

func loadGitignore(hostDir string) (*ignore.GitIgnore, error) {
	gitignorePath := filepath.Join(hostDir, ".gitignore")

	if _, err := os.Stat(gitignorePath); os.IsNotExist(err) {
		return ignore.CompileIgnoreLines(), nil
	}

	return ignore.CompileIgnoreFile(gitignorePath)
}