diff --git a/dev-tools/mage/module_changeset.go b/dev-tools/mage/module_changeset.go index 5eef73ec5d65..fb2d1460695e 100644 --- a/dev-tools/mage/module_changeset.go +++ b/dev-tools/mage/module_changeset.go @@ -19,18 +19,16 @@ package mage import ( "fmt" + "github.com/magefile/mage/sh" "log" "os" - "os/exec" "regexp" "strings" ) func DefineModules() { - beatPath := os.Getenv("BEAT_PATH") - if beatPath == "" { - panic(fmt.Errorf("argument required: beatPath")) - } + beatPath, err := os.Getwd() + //beatPath := os.Getenv("BEAT_PATH") var modulePattern string modulePattern = fmt.Sprintf("^%s\\/module\\/([^\\/]+)\\/.*", beatPath) @@ -57,7 +55,14 @@ func DefineModules() { i++ } - err = os.Setenv("MODULE", strings.Join(keys, ",")) + moduleVar := strings.Join(keys, ",") + + err = os.Setenv("MODULE", moduleVar) + if err != nil { + return + } + + fmt.Fprintf(os.Stderr, "Detected changes on module(s) %s", moduleVar) } func isAsciiOrPng(file string) bool { @@ -66,14 +71,8 @@ func isAsciiOrPng(file string) bool { func getDiff() []string { commitRange := getCommitRange() - cmd := exec.Command("git", "diff", "--name-only", commitRange) - output, err := cmd.Output() - if err != nil { - fmt.Printf("Failed to execute 'git diff --name-only %s': %s", commitRange, err) - os.Exit(1) - } - - return strings.Split(string(output), "\n") + var output, _ = sh.Output("git", "diff", "--name-only", commitRange) + return strings.Split(output, "\n") } func getFromCommit() string { @@ -98,14 +97,15 @@ func getFromCommit() string { } func getPreviousCommit() string { - cmd := exec.Command("git", "rev-parse", "HEAD^") - output, err := cmd.Output() - if err != nil { - fmt.Println("Failed to execute 'git rev-parse HEAD^': ", err) - os.Exit(1) - } - - return strings.TrimSpace(string(output)) + var output, _ = sh.Output("git", "rev-parse", "HEAD^") + //cmd := exec.Command("git", "rev-parse", "HEAD^") + //output, err := cmd.Output() + //if err != nil { + // fmt.Println("Failed to execute 'git rev-parse HEAD^': ", err) + // os.Exit(1) + //} + + return strings.TrimSpace(output) } func getCommitRange() string { diff --git a/x-pack/metricbeat/module/cloudfoundry/cloudfoundry.go b/x-pack/metricbeat/module/cloudfoundry/cloudfoundry.go index 574e88587aaa..4626cfc9361e 100644 --- a/x-pack/metricbeat/module/cloudfoundry/cloudfoundry.go +++ b/x-pack/metricbeat/module/cloudfoundry/cloudfoundry.go @@ -18,6 +18,7 @@ import ( const ModuleName = "cloudfoundry" func init() { + fmt.Println("DELETEME") if err := mb.Registry.AddModule(ModuleName, newModule); err != nil { panic(err) }