Skip to content

Commit

Permalink
Fix fake change event (#18)
Browse files Browse the repository at this point in the history
  • Loading branch information
mokiat authored Mar 18, 2021
1 parent 3c65d16 commit 23d0f38
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
8 changes: 6 additions & 2 deletions internal/command/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,14 @@ func run(ctx context.Context, cfg runConfig) error {
}
} else {
log.Printf("digest mismatch (%s != %s), will build from scratch.", digest, storedDigest)
fakeChangeEvent = &pipeline.ChangeEvent{}
fakeChangeEvent = &pipeline.ChangeEvent{
Paths: []string{pipeline.ForceBuildPath},
}
}
} else {
fakeChangeEvent = &pipeline.ChangeEvent{}
fakeChangeEvent = &pipeline.ChangeEvent{
Paths: []string{pipeline.ForceBuildPath},
}
}

log.Println("starting pipeline...")
Expand Down
6 changes: 5 additions & 1 deletion internal/pipeline/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import (
"github.com/mokiat/gocrane/internal/project"
)

const ForceBuildPath = "/gocrane/fake/forced/build"

func Build(
ctx context.Context,
mainDir string,
Expand All @@ -36,6 +38,7 @@ func Build(
}()

builder := project.NewBuilder(mainDir, buildArgs)
forceBuildFilter := location.PathFilter(ForceBuildPath)

return func() error {
var lastBinary string
Expand All @@ -46,7 +49,8 @@ func Build(

var changeEvent ChangeEvent
for in.Pop(ctx, &changeEvent) {
shouldBuild := location.MatchAny(rebuildFilter, changeEvent.Paths)
shouldBuild := location.MatchAny(rebuildFilter, changeEvent.Paths) ||
location.MatchAny(forceBuildFilter, changeEvent.Paths)
shouldRestart := location.MatchAny(restartFilter, changeEvent.Paths)

// Skip this change event. The changed files are not of relevance.
Expand Down

0 comments on commit 23d0f38

Please sign in to comment.