mirror of
https://github.com/go-task/task.git
synced 2026-07-09 06:55:14 +00:00
refactor: replace go-git with sabhiram/go-gitignore for lighter dependency
go-git pulled ~30 transitive dependencies and recursively walked the entire worktree on every Globs() call. Replace with sabhiram/go-gitignore (zero dependencies) and a simple walk from task dir up to rootDir to collect .gitignore files. Pass rootDir (Taskfile ROOT_DIR) through the checker chain to bound the search scope.
This commit is contained in:
13
variables.go
13
variables.go
@@ -203,9 +203,9 @@ func (e *Executor) compiledTask(call *Call, evaluateShVars bool) (*ast.Task, err
|
||||
var checker fingerprint.SourcesCheckable
|
||||
|
||||
if origTask.Method == "timestamp" {
|
||||
checker = fingerprint.NewTimestampChecker(e.TempDir.Fingerprint, e.Dry)
|
||||
checker = fingerprint.NewTimestampChecker(e.TempDir.Fingerprint, e.Dry, e.Dir)
|
||||
} else {
|
||||
checker = fingerprint.NewChecksumChecker(e.TempDir.Fingerprint, e.Dry)
|
||||
checker = fingerprint.NewChecksumChecker(e.TempDir.Fingerprint, e.Dry, e.Dir)
|
||||
}
|
||||
|
||||
value, err := checker.Value(&new)
|
||||
@@ -226,7 +226,7 @@ func (e *Executor) compiledTask(call *Call, evaluateShVars bool) (*ast.Task, err
|
||||
continue
|
||||
}
|
||||
if cmd.For != nil {
|
||||
list, keys, err := itemsFromFor(cmd.For, new.Dir, new.Sources, new.Generates, gitignore, vars, origTask.Location, cache)
|
||||
list, keys, err := itemsFromFor(cmd.For, new.Dir, new.Sources, new.Generates, gitignore, e.Dir, vars, origTask.Location, cache)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -275,7 +275,7 @@ func (e *Executor) compiledTask(call *Call, evaluateShVars bool) (*ast.Task, err
|
||||
continue
|
||||
}
|
||||
if dep.For != nil {
|
||||
list, keys, err := itemsFromFor(dep.For, new.Dir, new.Sources, new.Generates, gitignore, vars, origTask.Location, cache)
|
||||
list, keys, err := itemsFromFor(dep.For, new.Dir, new.Sources, new.Generates, gitignore, e.Dir, vars, origTask.Location, cache)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -347,6 +347,7 @@ func itemsFromFor(
|
||||
sources []*ast.Glob,
|
||||
generates []*ast.Glob,
|
||||
gitignore bool,
|
||||
rootDir string,
|
||||
vars *ast.Vars,
|
||||
location *ast.Location,
|
||||
cache *templater.Cache,
|
||||
@@ -369,7 +370,7 @@ func itemsFromFor(
|
||||
}
|
||||
// Get the list from the task sources
|
||||
if f.From == "sources" {
|
||||
glist, err := fingerprint.Globs(dir, sources, gitignore)
|
||||
glist, err := fingerprint.Globs(dir, sources, gitignore, rootDir)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
@@ -383,7 +384,7 @@ func itemsFromFor(
|
||||
}
|
||||
// Get the list from the task generates
|
||||
if f.From == "generates" {
|
||||
glist, err := fingerprint.Globs(dir, generates, gitignore)
|
||||
glist, err := fingerprint.Globs(dir, generates, gitignore, rootDir)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user