-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathignore.go
47 lines (38 loc) · 1.12 KB
/
ignore.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package ian
import (
"io/ioutil"
"path/filepath"
"github.com/penguinpowernz/go-ian/util/str"
)
// Ignored will return the ignore patterns from the .ianignore file
func Ignored(dir string) ([]string, error) {
ign := []string{}
data, err := ioutil.ReadFile(filepath.Join(dir, ".ianignore"))
if err != nil {
return ign, err
}
ign = str.CleanStrings(str.Lines(string(data)))
return ign, nil
}
// IgnoreList will use the ignore file from the package to generate
// a list of ignored file patterns. If there is no ignore file then
// an empty slice is returned
func (p *Pkg) IgnoreList() []string {
data, err := ioutil.ReadFile(p.IgnoreFile())
if err != nil {
return []string{}
}
return str.CleanStrings(str.Lines(string(data)))
}
// IgnoreFile returns the path to the packages ignore file
func (p *Pkg) IgnoreFile() string {
return p.Dir(".ianignore")
}
// Excludes provides things in the repo to be excluded from the package
func (p *Pkg) Excludes() []string {
exc := p.IgnoreList()
exc = append(exc, []string{
".git", "pkg", ".gitignore", ".ianpush", ".ianignore", ".gitkeep", "DEBIAN/build",
}...)
return exc
}