Skip to content

Commit

Permalink
Merge pull request #24 from mach6/mach6_fix_paths
Browse files Browse the repository at this point in the history
Fix for `@cron` triggers
  • Loading branch information
foosinn authored May 26, 2020
2 parents 329d467 + 42e76e7 commit 13b4955
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
9 changes: 1 addition & 8 deletions plugin/configloader.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package plugin
import (
"context"
"path"
"strings"

"github.com/sirupsen/logrus"
"gopkg.in/yaml.v2"
Expand All @@ -15,14 +14,8 @@ func (p *Plugin) getConfigForChanges(ctx context.Context, req *request, changedF
configData = ""
cache := map[string]bool{}
for _, file := range changedFiles {
if !strings.HasPrefix(file, "/") {
file = "/" + file
}

done := false
dir := file
for !done {
done = bool(dir == "/")
for dir != "." {
dir = path.Join(dir, "..")
file := path.Join(dir, req.Repo.Config)

Expand Down
4 changes: 2 additions & 2 deletions plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,10 @@ func (p *Plugin) Find(ctx context.Context, droneRequest *config.Request) (*drone
configData, err = p.getConfigForChanges(ctx, &req, changedFiles)
} else if req.Build.Trigger == "@cron" {
logrus.Warnf("%s @cron, rebuilding all", req.UUID)
configData, err = p.getConfigForTree(ctx, &req, "/", 0)
configData, err = p.getConfigForTree(ctx, &req, "", 0)
} else if p.fallback {
logrus.Warnf("%s no changed files and fallback enabled, rebuilding all", req.UUID)
configData, err = p.getConfigForTree(ctx, &req, "/", 0)
configData, err = p.getConfigForTree(ctx, &req, "", 0)
}
if err != nil {
return nil, err
Expand Down

0 comments on commit 13b4955

Please sign in to comment.