mirror of
				https://github.com/go-task/task.git
				synced 2025-10-30 23:58:01 +02:00 
			
		
		
		
	feat: enforce gofumpt linter
This commit is contained in:
		
				
					committed by
					
						 Andrey Nering
						Andrey Nering
					
				
			
			
				
	
			
			
			
						parent
						
							aab51c331f
						
					
				
				
					commit
					09c9094a6b
				
			| @@ -7,6 +7,7 @@ linters: | ||||
|   enable: | ||||
|     - goimports | ||||
|     - gofmt | ||||
|     - gofumpt | ||||
|  | ||||
| linters-settings: | ||||
|   goimports: | ||||
|   | ||||
							
								
								
									
										11
									
								
								CHANGELOG.md
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								CHANGELOG.md
									
									
									
									
									
								
							| @@ -5,10 +5,19 @@ | ||||
| - Add `.hg` (Mercurial) to the list of ignored directories when using | ||||
|   `--watch` (#1098 from @misery). | ||||
| - More improvements to the release tool (#1096 by @pd93) | ||||
| - Enforce [gofumpt](https://github.com/mvdan/gofumpt) linter (#1099 by @pd93) | ||||
|  | ||||
| ## v3.23.0 - 2023-03-26 | ||||
|  | ||||
| Task now has an [official extension for Visual Studio Code](https://marketplace.visualstudio.com/items?itemName=task.vscode-task) contributed by @pd93! :tada: The extension is maintained in a [new repository](https://github.com/go-task/vscode-task) under the `go-task` organization. We're looking to gather feedback from the community so please give it a go and let us know what you think via a [discussion](https://github.com/go-task/vscode-task/discussions), [issue](https://github.com/go-task/vscode-task/issues) or on our [Discord](https://discord.gg/6TY36E39UK)! | ||||
| Task now has an [official extension for Visual Studio | ||||
| Code](https://marketplace.visualstudio.com/items?itemName=task.vscode-task) | ||||
| contributed by @pd93! :tada: The extension is maintained in a [new | ||||
| repository](https://github.com/go-task/vscode-task) under the `go-task` | ||||
| organization. We're looking to gather feedback from the community so please give | ||||
| it a go and let us know what you think via a | ||||
| [discussion](https://github.com/go-task/vscode-task/discussions), | ||||
| [issue](https://github.com/go-task/vscode-task/issues) or on our | ||||
| [Discord](https://discord.gg/6TY36E39UK)! | ||||
|  | ||||
| > **NOTE:** | ||||
| > The extension _requires_ v3.23.0 to be installed in order to work. | ||||
|   | ||||
| @@ -62,6 +62,14 @@ tasks: | ||||
|     cmds: | ||||
|       - golangci-lint run | ||||
|  | ||||
|   lint:fix: | ||||
|     desc: Runs golangci-lint and fixes any issues | ||||
|     sources: | ||||
|       - './**/*.go' | ||||
|       - .golangci.yml | ||||
|     cmds: | ||||
|       - golangci-lint run --fix | ||||
|  | ||||
|   sleepit:build: | ||||
|     desc: Builds the sleepit test helper | ||||
|     sources: | ||||
|   | ||||
| @@ -9,7 +9,7 @@ import ( | ||||
| // ParseV3 parses command line argument: tasks and global variables | ||||
| func ParseV3(args ...string) ([]taskfile.Call, *taskfile.Vars) { | ||||
| 	var calls []taskfile.Call | ||||
| 	var globals = &taskfile.Vars{} | ||||
| 	globals := &taskfile.Vars{} | ||||
|  | ||||
| 	for _, arg := range args { | ||||
| 		if !strings.Contains(arg, "=") { | ||||
| @@ -31,7 +31,7 @@ func ParseV3(args ...string) ([]taskfile.Call, *taskfile.Vars) { | ||||
| // ParseV2 parses command line argument: tasks and vars of each task | ||||
| func ParseV2(args ...string) ([]taskfile.Call, *taskfile.Vars) { | ||||
| 	var calls []taskfile.Call | ||||
| 	var globals = &taskfile.Vars{} | ||||
| 	globals := &taskfile.Vars{} | ||||
|  | ||||
| 	for _, arg := range args { | ||||
| 		if !strings.Contains(arg, "=") { | ||||
|   | ||||
| @@ -203,7 +203,6 @@ func TestArgsV2(t *testing.T) { | ||||
| 			if test.ExpectedGlobals.Len() > 0 || globals.Len() > 0 { | ||||
| 				assert.Equal(t, test.ExpectedGlobals, globals) | ||||
| 			} | ||||
|  | ||||
| 		}) | ||||
| 	} | ||||
| } | ||||
|   | ||||
| @@ -104,7 +104,7 @@ func changelog(version *semver.Version) error { | ||||
| 	changelog = changelogReleaseRegex.ReplaceAllString(changelog, fmt.Sprintf("## v%s - %s", version, date)) | ||||
|  | ||||
| 	// Write the changelog to the source file | ||||
| 	if err := os.WriteFile(changelogSource, []byte(changelog), 0644); err != nil { | ||||
| 	if err := os.WriteFile(changelogSource, []byte(changelog), 0o644); err != nil { | ||||
| 		return err | ||||
| 	} | ||||
|  | ||||
| @@ -116,7 +116,7 @@ func changelog(version *semver.Version) error { | ||||
| 	changelog = changelogIssueRegex.ReplaceAllString(changelog, "[#$1](https://github.com/go-task/task/issues/$1)") | ||||
|  | ||||
| 	// Write the changelog to the target file | ||||
| 	return os.WriteFile(changelogTarget, []byte(changelog), 0644) | ||||
| 	return os.WriteFile(changelogTarget, []byte(changelog), 0o644) | ||||
| } | ||||
|  | ||||
| func setJSONVersion(fileName string, version *semver.Version) error { | ||||
| @@ -130,5 +130,5 @@ func setJSONVersion(fileName string, version *semver.Version) error { | ||||
| 	new := versionRegex.ReplaceAllString(string(b), fmt.Sprintf(`  "version": "%s",`, version.String())) | ||||
|  | ||||
| 	// Write the JSON file | ||||
| 	return os.WriteFile(fileName, []byte(new), 0644) | ||||
| 	return os.WriteFile(fileName, []byte(new), 0o644) | ||||
| } | ||||
|   | ||||
| @@ -19,10 +19,8 @@ Commands | ||||
|   handle      Handle signals: on reception of SIGINT perform cleanup before exiting | ||||
|   version     Show the sleepit version` | ||||
|  | ||||
| var ( | ||||
| // Filled by the linker. | ||||
| 	fullVersion = "unknown" // example: v0.0.9-8-g941583d027-dirty | ||||
| ) | ||||
| var fullVersion = "unknown" // example: v0.0.9-8-g941583d027-dirty | ||||
|  | ||||
| func main() { | ||||
| 	os.Exit(run(os.Args[1:])) | ||||
|   | ||||
| @@ -181,7 +181,7 @@ func main() { | ||||
| 		OutputStyle: output, | ||||
| 	} | ||||
|  | ||||
| 	var listOptions = task.NewListOptions(list, listAll, listJson) | ||||
| 	listOptions := task.NewListOptions(list, listAll, listJson) | ||||
| 	if err := listOptions.Validate(); err != nil { | ||||
| 		log.Fatal(err) | ||||
| 	} | ||||
|   | ||||
| @@ -30,9 +30,12 @@ invest your time into a PR. | ||||
| ## 2. Making changes | ||||
|  | ||||
| - **Code style** - Try to maintain the existing code style where possible and | ||||
|   ensure that code is formatted by `gofmt`. We use `golangci-lint` in our CI to | ||||
|   enforce a consistent style and best-practice. There's a `lint` command in | ||||
|   the Taskfile to run this locally. | ||||
|   ensure that code is formatted by | ||||
|   [`gofumpt`](https://github.com/mvdan/gofumpt). We use | ||||
|   [`golangci-lint`](https://golangci-lint.run/) in our CI to enforce a | ||||
|   consistent style and best-practice. You can use the `task lint` command to run | ||||
|   this locally and the `task lint:fix` command to automatically fix any issues | ||||
|   that are found. | ||||
| - **Documentation** - Ensure that you add/update any relevant documentation. See | ||||
|   the [updating documentation](#updating-documentation) section below. | ||||
| - **Tests** - Ensure that you add/update any relevant tests and that all tests | ||||
| @@ -60,9 +63,9 @@ documentation and any examples are up-to-date. Ensure that any examples follow | ||||
| the [Taskfile Styleguide](./styleguide.md). | ||||
|  | ||||
| If you added a new field, command or flag, ensure that you add it to the [API | ||||
| Reference](./api_reference.md). New fields also need to be added to the | ||||
| [JSON Schema]. The descriptions for fields in the API | ||||
| reference and the schema should match. | ||||
| Reference](./api_reference.md). New fields also need to be added to the [JSON | ||||
| Schema]. The descriptions for fields in the API reference and the schema should | ||||
| match. | ||||
|  | ||||
| ### Writing tests | ||||
|  | ||||
| @@ -74,13 +77,13 @@ required to run the tests are stored. | ||||
| When making a changes, consider whether new tests are required. These tests | ||||
| should ensure that the functionality you are adding will continue to work in the | ||||
| future. Existing tests may also need updating if you have changed Task's | ||||
| behaviour. | ||||
| behavior. | ||||
|  | ||||
| ## 3. Committing your code | ||||
|  | ||||
| Try to write meaningful commit messages and avoid having too many commits on | ||||
| the PR. Most PRs should likely have a single commit (although for bigger PRs it | ||||
| may be reasonable to split it in a few). Git squash and rebase is your friend! | ||||
| Try to write meaningful commit messages and avoid having too many commits on the | ||||
| PR. Most PRs should likely have a single commit (although for bigger PRs it may | ||||
| be reasonable to split it in a few). Git squash and rebase is your friend! | ||||
|  | ||||
| ## 4. Submitting a PR | ||||
|  | ||||
| @@ -117,8 +120,10 @@ If you have questions, feel free to ask them in the `#help` forum channel on our | ||||
| [Node.js]: https://nodejs.org/en/ | ||||
| [Yarn]: https://yarnpkg.com/ | ||||
| [Docusaurus]: https://docusaurus.io | ||||
| [JSON Schema]: https://github.com/go-task/task/blob/master/docs/static/schema.json | ||||
| [JSON Schema]: | ||||
|     https://github.com/go-task/task/blob/master/docs/static/schema.json | ||||
| [open issues]: https://github.com/go-task/task/issues | ||||
| [good first issue]: https://github.com/go-task/task/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22 | ||||
| [good first issue]: | ||||
|     https://github.com/go-task/task/issues?q=is%3Aissue+is%3Aopen+label%3A%22good+first+issue%22 | ||||
| [Discord server]: https://discord.gg/6TY36E39UK | ||||
| [Discussion]: https://github.com/go-task/task/discussions | ||||
|   | ||||
| @@ -8,10 +8,8 @@ import ( | ||||
| 	"mvdan.cc/sh/v3/interp" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| // ErrTaskfileAlreadyExists is returned on creating a Taskfile if one already exists | ||||
| 	ErrTaskfileAlreadyExists = errors.New("task: A Taskfile already exists") | ||||
| ) | ||||
| var ErrTaskfileAlreadyExists = errors.New("task: A Taskfile already exists") | ||||
|  | ||||
| type taskNotFoundError struct { | ||||
| 	taskName   string | ||||
|   | ||||
| @@ -28,10 +28,8 @@ type RunCommandOptions struct { | ||||
| 	Stderr    io.Writer | ||||
| } | ||||
|  | ||||
| var ( | ||||
| // ErrNilOptions is returned when a nil options is given | ||||
| 	ErrNilOptions = errors.New("execext: nil options given") | ||||
| ) | ||||
| var ErrNilOptions = errors.New("execext: nil options given") | ||||
|  | ||||
| // RunCommand runs a shell command | ||||
| func RunCommand(ctx context.Context, opts *RunCommandOptions) error { | ||||
|   | ||||
| @@ -8,27 +8,35 @@ import ( | ||||
| 	"github.com/fatih/color" | ||||
| ) | ||||
|  | ||||
| type Color func() PrintFunc | ||||
| type PrintFunc func(io.Writer, string, ...any) | ||||
| type ( | ||||
| 	Color     func() PrintFunc | ||||
| 	PrintFunc func(io.Writer, string, ...any) | ||||
| ) | ||||
|  | ||||
| func Default() PrintFunc { | ||||
| 	return color.New(envColor("TASK_COLOR_RESET", color.Reset)).FprintfFunc() | ||||
| } | ||||
|  | ||||
| func Blue() PrintFunc { | ||||
| 	return color.New(envColor("TASK_COLOR_BLUE", color.FgBlue)).FprintfFunc() | ||||
| } | ||||
|  | ||||
| func Green() PrintFunc { | ||||
| 	return color.New(envColor("TASK_COLOR_GREEN", color.FgGreen)).FprintfFunc() | ||||
| } | ||||
|  | ||||
| func Cyan() PrintFunc { | ||||
| 	return color.New(envColor("TASK_COLOR_CYAN", color.FgCyan)).FprintfFunc() | ||||
| } | ||||
|  | ||||
| func Yellow() PrintFunc { | ||||
| 	return color.New(envColor("TASK_COLOR_YELLOW", color.FgYellow)).FprintfFunc() | ||||
| } | ||||
|  | ||||
| func Magenta() PrintFunc { | ||||
| 	return color.New(envColor("TASK_COLOR_MAGENTA", color.FgMagenta)).FprintfFunc() | ||||
| } | ||||
|  | ||||
| func Red() PrintFunc { | ||||
| 	return color.New(envColor("TASK_COLOR_RED", color.FgRed)).FprintfFunc() | ||||
| } | ||||
| @@ -41,7 +49,6 @@ func envColor(env string, defaultColor color.Attribute) color.Attribute { | ||||
| 	override, err := strconv.Atoi(os.Getenv(env)) | ||||
| 	if err == nil { | ||||
| 		return color.Attribute(override) | ||||
|  | ||||
| 	} | ||||
| 	return defaultColor | ||||
| } | ||||
|   | ||||
| @@ -17,7 +17,7 @@ import ( | ||||
| func TestInterleaved(t *testing.T) { | ||||
| 	var b bytes.Buffer | ||||
| 	var o output.Output = output.Interleaved{} | ||||
| 	var w, _, _ = o.WrapWriter(&b, io.Discard, "", nil) | ||||
| 	w, _, _ := o.WrapWriter(&b, io.Discard, "", nil) | ||||
|  | ||||
| 	fmt.Fprintln(w, "foo\nbar") | ||||
| 	assert.Equal(t, "foo\nbar\n", b.String()) | ||||
| @@ -28,7 +28,7 @@ func TestInterleaved(t *testing.T) { | ||||
| func TestGroup(t *testing.T) { | ||||
| 	var b bytes.Buffer | ||||
| 	var o output.Output = output.Group{} | ||||
| 	var stdOut, stdErr, cleanup = o.WrapWriter(&b, io.Discard, "", nil) | ||||
| 	stdOut, stdErr, cleanup := o.WrapWriter(&b, io.Discard, "", nil) | ||||
|  | ||||
| 	fmt.Fprintln(stdOut, "out\nout") | ||||
| 	assert.Equal(t, "", b.String()) | ||||
| @@ -59,7 +59,7 @@ func TestGroupWithBeginEnd(t *testing.T) { | ||||
| 	} | ||||
| 	t.Run("simple", func(t *testing.T) { | ||||
| 		var b bytes.Buffer | ||||
| 		var w, _, cleanup = o.WrapWriter(&b, io.Discard, "", &tmpl) | ||||
| 		w, _, cleanup := o.WrapWriter(&b, io.Discard, "", &tmpl) | ||||
|  | ||||
| 		fmt.Fprintln(w, "foo\nbar") | ||||
| 		assert.Equal(t, "", b.String()) | ||||
| @@ -70,7 +70,7 @@ func TestGroupWithBeginEnd(t *testing.T) { | ||||
| 	}) | ||||
| 	t.Run("no output", func(t *testing.T) { | ||||
| 		var b bytes.Buffer | ||||
| 		var _, _, cleanup = o.WrapWriter(&b, io.Discard, "", &tmpl) | ||||
| 		_, _, cleanup := o.WrapWriter(&b, io.Discard, "", &tmpl) | ||||
| 		assert.NoError(t, cleanup(nil)) | ||||
| 		assert.Equal(t, "", b.String()) | ||||
| 	}) | ||||
| @@ -81,7 +81,7 @@ func TestGroupErrorOnlySwallowsOutputOnNoError(t *testing.T) { | ||||
| 	var o output.Output = output.Group{ | ||||
| 		ErrorOnly: true, | ||||
| 	} | ||||
| 	var stdOut, stdErr, cleanup = o.WrapWriter(&b, io.Discard, "", nil) | ||||
| 	stdOut, stdErr, cleanup := o.WrapWriter(&b, io.Discard, "", nil) | ||||
|  | ||||
| 	_, _ = fmt.Fprintln(stdOut, "std-out") | ||||
| 	_, _ = fmt.Fprintln(stdErr, "std-err") | ||||
| @@ -89,12 +89,13 @@ func TestGroupErrorOnlySwallowsOutputOnNoError(t *testing.T) { | ||||
| 	assert.NoError(t, cleanup(nil)) | ||||
| 	assert.Empty(t, b.String()) | ||||
| } | ||||
|  | ||||
| func TestGroupErrorOnlyShowsOutputOnError(t *testing.T) { | ||||
| 	var b bytes.Buffer | ||||
| 	var o output.Output = output.Group{ | ||||
| 		ErrorOnly: true, | ||||
| 	} | ||||
| 	var stdOut, stdErr, cleanup = o.WrapWriter(&b, io.Discard, "", nil) | ||||
| 	stdOut, stdErr, cleanup := o.WrapWriter(&b, io.Discard, "", nil) | ||||
|  | ||||
| 	_, _ = fmt.Fprintln(stdOut, "std-out") | ||||
| 	_, _ = fmt.Fprintln(stdErr, "std-err") | ||||
| @@ -106,7 +107,7 @@ func TestGroupErrorOnlyShowsOutputOnError(t *testing.T) { | ||||
| func TestPrefixed(t *testing.T) { | ||||
| 	var b bytes.Buffer | ||||
| 	var o output.Output = output.Prefixed{} | ||||
| 	var w, _, cleanup = o.WrapWriter(&b, io.Discard, "prefix", nil) | ||||
| 	w, _, cleanup := o.WrapWriter(&b, io.Discard, "prefix", nil) | ||||
|  | ||||
| 	t.Run("simple use cases", func(t *testing.T) { | ||||
| 		b.Reset() | ||||
|   | ||||
| @@ -147,7 +147,6 @@ func TestPrintDescriptionAsFallback(t *testing.T) { | ||||
| 	summary.PrintTask(&l, taskWithoutSummaryOrDescription) | ||||
|  | ||||
| 	assert.Contains(t, buffer.String(), "\n(task does not have description or summary)\n") | ||||
|  | ||||
| } | ||||
|  | ||||
| func TestPrintAllWithSpaces(t *testing.T) { | ||||
| @@ -169,5 +168,4 @@ func TestPrintAllWithSpaces(t *testing.T) { | ||||
| 	assert.True(t, strings.HasPrefix(buffer.String(), "task: t1")) | ||||
| 	assert.Contains(t, buffer.String(), "\n(task does not have description or summary)\n\n\ntask: t2") | ||||
| 	assert.Contains(t, buffer.String(), "\n(task does not have description or summary)\n\n\ntask: t3") | ||||
|  | ||||
| } | ||||
|   | ||||
| @@ -11,9 +11,7 @@ import ( | ||||
| 	"mvdan.cc/sh/v3/syntax" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| 	templateFuncs template.FuncMap | ||||
| ) | ||||
| var templateFuncs template.FuncMap | ||||
|  | ||||
| func init() { | ||||
| 	taskFuncs := template.FuncMap{ | ||||
|   | ||||
| @@ -10,10 +10,8 @@ import ( | ||||
| 	"github.com/go-task/task/v3/taskfile" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| // ErrPreconditionFailed is returned when a precondition fails | ||||
| 	ErrPreconditionFailed = errors.New("task: precondition not met") | ||||
| ) | ||||
| var ErrPreconditionFailed = errors.New("task: precondition not met") | ||||
|  | ||||
| func (e *Executor) areTaskPreconditionsMet(ctx context.Context, t *taskfile.Task) (bool, error) { | ||||
| 	for _, p := range t.Preconditions { | ||||
| @@ -22,7 +20,6 @@ func (e *Executor) areTaskPreconditionsMet(ctx context.Context, t *taskfile.Task | ||||
| 			Dir:     t.Dir, | ||||
| 			Env:     env.Get(t), | ||||
| 		}) | ||||
|  | ||||
| 		if err != nil { | ||||
| 			e.Logger.Errf(logger.Magenta, "task: %s", p.Msg) | ||||
| 			return false, ErrPreconditionFailed | ||||
|   | ||||
							
								
								
									
										1
									
								
								task.go
									
									
									
									
									
								
							
							
						
						
									
										1
									
								
								task.go
									
									
									
									
									
								
							| @@ -404,7 +404,6 @@ func (e *Executor) GetTaskList(filters ...FilterFunc) ([]*taskfile.Task, error) | ||||
| 	for key := range e.Taskfile.Tasks { | ||||
| 		task := e.Taskfile.Tasks[key] | ||||
| 		g.Go(func() error { | ||||
|  | ||||
| 			// Check if we should filter the task | ||||
| 			for _, filter := range filters { | ||||
| 				if filter(task) { | ||||
|   | ||||
							
								
								
									
										13
									
								
								task_test.go
									
									
									
									
									
								
							
							
						
						
									
										13
									
								
								task_test.go
									
									
									
									
									
								
							| @@ -397,7 +397,7 @@ func TestGenerates(t *testing.T) { | ||||
| 		fileWithSpaces = "my text file.txt" | ||||
| 	) | ||||
|  | ||||
| 	var srcFile = filepathext.SmartJoin(dir, srcTask) | ||||
| 	srcFile := filepathext.SmartJoin(dir, srcTask) | ||||
|  | ||||
| 	for _, task := range []string{srcTask, relTask, absTask, fileWithSpaces} { | ||||
| 		path := filepathext.SmartJoin(dir, task) | ||||
| @@ -416,8 +416,8 @@ func TestGenerates(t *testing.T) { | ||||
| 	assert.NoError(t, e.Setup()) | ||||
|  | ||||
| 	for _, theTask := range []string{relTask, absTask, fileWithSpaces} { | ||||
| 		var destFile = filepathext.SmartJoin(dir, theTask) | ||||
| 		var upToDate = fmt.Sprintf("task: Task \"%s\" is up to date\n", srcTask) + | ||||
| 		destFile := filepathext.SmartJoin(dir, theTask) | ||||
| 		upToDate := fmt.Sprintf("task: Task \"%s\" is up to date\n", srcTask) + | ||||
| 			fmt.Sprintf("task: Task \"%s\" is up to date\n", theTask) | ||||
|  | ||||
| 		// Run task for the first time. | ||||
| @@ -704,7 +704,7 @@ func TestStatusVariables(t *testing.T) { | ||||
|  | ||||
| func TestInit(t *testing.T) { | ||||
| 	const dir = "testdata/init" | ||||
| 	var file = filepathext.SmartJoin(dir, "Taskfile.yml") | ||||
| 	file := filepathext.SmartJoin(dir, "Taskfile.yml") | ||||
|  | ||||
| 	_ = os.Remove(file) | ||||
| 	if _, err := os.Stat(file); err == nil { | ||||
| @@ -964,7 +964,8 @@ func TestIncludesOptional(t *testing.T) { | ||||
| 		TrimSpace: true, | ||||
| 		Files: map[string]string{ | ||||
| 			"called_dep.txt": "called_dep", | ||||
| 		}} | ||||
| 		}, | ||||
| 	} | ||||
| 	tt.Run(t) | ||||
| } | ||||
|  | ||||
| @@ -1327,7 +1328,6 @@ func TestDisplaysErrorOnUnsupportedVersion(t *testing.T) { | ||||
| 	err := e.Setup() | ||||
| 	assert.Error(t, err) | ||||
| 	assert.Equal(t, "task: Taskfile versions prior to v2 are not supported anymore", err.Error()) | ||||
|  | ||||
| } | ||||
|  | ||||
| func TestShortTaskNotation(t *testing.T) { | ||||
| @@ -1576,6 +1576,7 @@ Bye! | ||||
| 	t.Log(buff.String()) | ||||
| 	assert.Equal(t, strings.TrimSpace(buff.String()), expectedOutputOrder) | ||||
| } | ||||
|  | ||||
| func TestOutputGroupErrorOnlySwallowsOutputOnSuccess(t *testing.T) { | ||||
| 	const dir = "testdata/output_group_error_only" | ||||
| 	var buff bytes.Buffer | ||||
|   | ||||
| @@ -32,7 +32,6 @@ type IncludedTaskfiles struct { | ||||
| // UnmarshalYAML implements the yaml.Unmarshaler interface. | ||||
| func (tfs *IncludedTaskfiles) UnmarshalYAML(node *yaml.Node) error { | ||||
| 	switch node.Kind { | ||||
|  | ||||
| 	case yaml.MappingNode: | ||||
| 		// NOTE(@andreynering): on this style of custom unmarshalling, | ||||
| 		// even number contains the keys, while odd numbers contains | ||||
|   | ||||
| @@ -7,10 +7,8 @@ import ( | ||||
| 	"gopkg.in/yaml.v3" | ||||
| ) | ||||
|  | ||||
| var ( | ||||
| // ErrCantUnmarshalPrecondition is returned for invalid precond YAML. | ||||
| 	ErrCantUnmarshalPrecondition = errors.New("task: Can't unmarshal precondition value") | ||||
| ) | ||||
| var ErrCantUnmarshalPrecondition = errors.New("task: Can't unmarshal precondition value") | ||||
|  | ||||
| // Precondition represents a precondition necessary for a task to run | ||||
| type Precondition struct { | ||||
|   | ||||
| @@ -25,14 +25,16 @@ func TestPreconditionParse(t *testing.T) { | ||||
| 			&taskfile.Precondition{}, | ||||
| 			&taskfile.Precondition{Sh: "[ 1 = 0 ]", Msg: "[ 1 = 0 ] failed"}, | ||||
| 		}, | ||||
| 		{` | ||||
| 		{ | ||||
| 			` | ||||
| sh: "[ 1 = 2 ]" | ||||
| msg: "1 is not 2" | ||||
| `, | ||||
| 			&taskfile.Precondition{}, | ||||
| 			&taskfile.Precondition{Sh: "[ 1 = 2 ]", Msg: "1 is not 2"}, | ||||
| 		}, | ||||
| 		{` | ||||
| 		{ | ||||
| 			` | ||||
| sh: "[ 1 = 2 ]" | ||||
| msg: "1 is not 2" | ||||
| `, | ||||
|   | ||||
| @@ -263,8 +263,8 @@ func checkCircularIncludes(node *ReaderNode) error { | ||||
| 	if node.Parent == nil { | ||||
| 		return errors.New("task: failed to check for include cycle: node.Parent was nil") | ||||
| 	} | ||||
| 	var curNode = node | ||||
| 	var basePath = filepathext.SmartJoin(node.Dir, node.Entrypoint) | ||||
| 	curNode := node | ||||
| 	basePath := filepathext.SmartJoin(node.Dir, node.Entrypoint) | ||||
| 	for curNode.Parent != nil { | ||||
| 		curNode = curNode.Parent | ||||
| 		curPath := filepathext.SmartJoin(curNode.Dir, curNode.Entrypoint) | ||||
|   | ||||
| @@ -34,7 +34,6 @@ type Taskfile struct { | ||||
|  | ||||
| func (tf *Taskfile) UnmarshalYAML(node *yaml.Node) error { | ||||
| 	switch node.Kind { | ||||
|  | ||||
| 	case yaml.MappingNode: | ||||
| 		var taskfile struct { | ||||
| 			Version    *semver.Version | ||||
|   | ||||
| @@ -15,7 +15,6 @@ type Vars struct { | ||||
|  | ||||
| func (vs *Vars) UnmarshalYAML(node *yaml.Node) error { | ||||
| 	switch node.Kind { | ||||
|  | ||||
| 	case yaml.MappingNode: | ||||
| 		// NOTE(@andreynering): on this style of custom unmarshalling, | ||||
| 		// even number contains the keys, while odd numbers contains | ||||
|   | ||||
		Reference in New Issue
	
	Block a user