Skip to content

Commit

Permalink
Accept mixed tagging in magefiles folder
Browse files Browse the repository at this point in the history
When mixed tagging is found within a magefiles folder, opt to use all files
  • Loading branch information
perrito666 committed Mar 11, 2022
1 parent 3ab41f0 commit 1c2ef11
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 8 deletions.
8 changes: 4 additions & 4 deletions mage/main.go
Expand Up @@ -501,8 +501,8 @@ func Magefiles(magePath, goos, goarch, goCmd string, stderr io.Writer, isMagefil
debug.Println("getting all non-mage files in", magePath)
}

// // first, grab all the files with no build tags specified.. this is actually
// // our exclude list of things without the mage build tag.
// first, grab all the files with no build tags specified..
// this is actually our exclude list of things without the mage build tag.
exclude := map[string]bool{}

goFiles, err := listGoFiles(magePath, goCmd, "", env)
Expand All @@ -522,8 +522,8 @@ func Magefiles(magePath, goos, goarch, goCmd string, stderr io.Writer, isMagefil
return nil, fmt.Errorf("listing mage files: %v", err)
}

// there are only mage tagged files
if len(exclude) == len(goFiles) && isMagefilesDirectory {
// we accept mixed tagging within a magefiles folder, all files are used.
if isMagefilesDirectory {
exclude = map[string]bool{}
}

Expand Down
2 changes: 1 addition & 1 deletion mage/main_test.go
Expand Up @@ -431,7 +431,7 @@ func TestMixedTaggingMagefilesFolder(t *testing.T) {
if code != 0 {
t.Errorf("expected to exit with code 0, but got %v, stderr: %s", code, stderr)
}
expected := "Targets:\n build \n"
expected := "Targets:\n build \n untaggedBuild \n"
actual := stdout.String()
if actual != expected {
t.Fatalf("expected %q but got %q", expected, actual)
Expand Down
Expand Up @@ -4,6 +4,4 @@

package main

func main() {}

func Build() {}
func UntaggedBuild() {}

0 comments on commit 1c2ef11

Please sign in to comment.