From 8a09d044c7466efae6a84f4c30577e963b3d81d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Sat, 16 Oct 2021 21:12:26 +0200 Subject: [PATCH 01/19] Adding task started and task finished in the verbose otput --- task.go | 2 ++ 1 file changed, 2 insertions(+) diff --git a/task.go b/task.go index 231552aa..6ad253e8 100644 --- a/task.go +++ b/task.go @@ -310,6 +310,7 @@ func (e *Executor) RunTask(ctx context.Context, call taskfile.Call) error { defer release() return e.startExecution(ctx, t, func(ctx context.Context) error { + e.Logger.VerboseErrf(logger.Magenta, `started task: '%s'`, call.Task) if err := e.runDeps(ctx, t); err != nil { return err } @@ -351,6 +352,7 @@ func (e *Executor) RunTask(ctx context.Context, call taskfile.Call) error { return &taskRunError{t.Task, err} } } + e.Logger.VerboseErrf(logger.Magenta, `finished task: '%s'`, call.Task) return nil }) } From 690000254c94795a1235140d5900d41f625cb11d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jes=C3=BAs=20Espino?= Date: Sun, 31 Oct 2021 09:37:23 +0100 Subject: [PATCH 02/19] Apply suggestions from code review Co-authored-by: Andrey Nering --- task.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/task.go b/task.go index 6ad253e8..17f1655b 100644 --- a/task.go +++ b/task.go @@ -310,7 +310,7 @@ func (e *Executor) RunTask(ctx context.Context, call taskfile.Call) error { defer release() return e.startExecution(ctx, t, func(ctx context.Context) error { - e.Logger.VerboseErrf(logger.Magenta, `started task: '%s'`, call.Task) + e.Logger.VerboseErrf(logger.Magenta, `task: "%s" started`, call.Task) if err := e.runDeps(ctx, t); err != nil { return err } @@ -352,7 +352,7 @@ func (e *Executor) RunTask(ctx context.Context, call taskfile.Call) error { return &taskRunError{t.Task, err} } } - e.Logger.VerboseErrf(logger.Magenta, `finished task: '%s'`, call.Task) + e.Logger.VerboseErrf(logger.Magenta, `task: "%s" finished`, call.Task) return nil }) } From bdb97eab86af7ff81cfb978db130035c03a3697c Mon Sep 17 00:00:00 2001 From: Marcello Sylvester Bauer Date: Wed, 3 Nov 2021 12:26:21 +0100 Subject: [PATCH 03/19] task: Check context error Check context error after running dependencies, to prevent false negative precondition errors due to "context canceled". Signed-off-by: Marcello Sylvester Bauer --- task.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/task.go b/task.go index 231552aa..f4347fde 100644 --- a/task.go +++ b/task.go @@ -315,6 +315,10 @@ func (e *Executor) RunTask(ctx context.Context, call taskfile.Call) error { } if !e.Force { + if err := ctx.Err(); err != nil { + return err + } + preCondMet, err := e.areTaskPreconditionsMet(ctx, t) if err != nil { return err From e339a64261426a74bef8c619d3185f84ca816f01 Mon Sep 17 00:00:00 2001 From: Peter Byfield Date: Thu, 25 Nov 2021 14:03:31 +0100 Subject: [PATCH 04/19] Fix quoting of CLI_ARGS Consider a task: test: cmds: - pytest {{.CLI_ARGS}} Running `task test -- -m "not foo"` should be equivalent to running `pytest -m "not foo"`. However, with the current implementation the quoting of CLI_ARGS is lost and the task executes `python -m not foo`, which results in an error. --- cmd/task/task.go | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/cmd/task/task.go b/cmd/task/task.go index b481efe5..0f9f9654 100644 --- a/cmd/task/task.go +++ b/cmd/task/task.go @@ -12,6 +12,7 @@ import ( "syscall" "github.com/spf13/pflag" + "mvdan.cc/sh/v3/syntax" "github.com/go-task/task/v3" "github.com/go-task/task/v3/args" @@ -159,18 +160,22 @@ func main() { } var ( - calls []taskfile.Call - globals *taskfile.Vars - tasksAndVars, cliArgs = getArgs() + calls []taskfile.Call + globals *taskfile.Vars ) + tasksAndVars, cliArgs, err := getArgs() + if err != nil { + log.Fatal(err) + } + if v >= 3.0 { calls, globals = args.ParseV3(tasksAndVars...) } else { calls, globals = args.ParseV2(tasksAndVars...) } - globals.Set("CLI_ARGS", taskfile.Var{Static: strings.Join(cliArgs, " ")}) + globals.Set("CLI_ARGS", taskfile.Var{Static: cliArgs}) e.Taskfile.Vars.Merge(globals) ctx := context.Background() @@ -191,20 +196,25 @@ func main() { } } -func getArgs() (tasksAndVars, cliArgs []string) { +func getArgs() ([]string, string, error) { var ( args = pflag.Args() doubleDashPos = pflag.CommandLine.ArgsLenAtDash() ) - if doubleDashPos != -1 { - tasksAndVars = args[:doubleDashPos] - cliArgs = args[doubleDashPos:] - } else { - tasksAndVars = args + if doubleDashPos == -1 { + return args, "", nil } - return + quotedCliArgs := []string{} + for _, arg := range args[doubleDashPos:] { + quotedCliArg, err := syntax.Quote(arg, syntax.LangBash) + if err != nil { + return []string{}, "", err + } + quotedCliArgs = append(quotedCliArgs, quotedCliArg) + } + return args[:doubleDashPos], strings.Join(quotedCliArgs, " "), nil } func getSignalContext() context.Context { From b6016b244e76e2e0b0040fb8ddfa36f0dc6e152f Mon Sep 17 00:00:00 2001 From: Margus Kerma Date: Fri, 26 Nov 2021 11:20:05 +0200 Subject: [PATCH 05/19] fix(#612): Add nil check for included cmd --- task_test.go | 17 +++++++++-------- taskfile/merge.go | 2 +- .../ignore_nil_elements/includes/Taskfile.yml | 9 +++++++++ testdata/ignore_nil_elements/includes/inc.yml | 7 +++++++ 4 files changed, 26 insertions(+), 9 deletions(-) create mode 100644 testdata/ignore_nil_elements/includes/Taskfile.yml create mode 100644 testdata/ignore_nil_elements/includes/inc.yml diff --git a/task_test.go b/task_test.go index 8ccc92d9..97558950 100644 --- a/task_test.go +++ b/task_test.go @@ -756,14 +756,14 @@ func TestIncludesCallingRoot(t *testing.T) { } func TestIncludesOptional(t *testing.T) { - tt := fileContentTest{ - Dir: "testdata/includes_optional", - Target: "default", - TrimSpace: true, - Files: map[string]string{ - "called_dep.txt": "called_dep", - }} - tt.Run(t) + tt := fileContentTest{ + Dir: "testdata/includes_optional", + Target: "default", + TrimSpace: true, + Files: map[string]string{ + "called_dep.txt": "called_dep", + }} + tt.Run(t) } func TestIncludesOptionalImplicitFalse(t *testing.T) { @@ -1033,6 +1033,7 @@ func TestIgnoreNilElements(t *testing.T) { }{ {"nil cmd", "testdata/ignore_nil_elements/cmds"}, {"nil dep", "testdata/ignore_nil_elements/deps"}, + {"nil include", "testdata/ignore_nil_elements/includes"}, {"nil precondition", "testdata/ignore_nil_elements/preconditions"}, } diff --git a/taskfile/merge.go b/taskfile/merge.go index 93466008..45d40571 100644 --- a/taskfile/merge.go +++ b/taskfile/merge.go @@ -49,7 +49,7 @@ func Merge(t1, t2 *Taskfile, namespaces ...string) error { dep.Task = taskNameWithNamespace(dep.Task, namespaces...) } for _, cmd := range v.Cmds { - if cmd.Task != "" { + if cmd != nil && cmd.Task != "" { cmd.Task = taskNameWithNamespace(cmd.Task, namespaces...) } } diff --git a/testdata/ignore_nil_elements/includes/Taskfile.yml b/testdata/ignore_nil_elements/includes/Taskfile.yml new file mode 100644 index 00000000..a428fa34 --- /dev/null +++ b/testdata/ignore_nil_elements/includes/Taskfile.yml @@ -0,0 +1,9 @@ +version: '3' + +includes: + inc: inc.yml + +tasks: + default: + cmds: + - task: inc:default diff --git a/testdata/ignore_nil_elements/includes/inc.yml b/testdata/ignore_nil_elements/includes/inc.yml new file mode 100644 index 00000000..537bad1d --- /dev/null +++ b/testdata/ignore_nil_elements/includes/inc.yml @@ -0,0 +1,7 @@ +version: '3' + +tasks: + default: + cmds: + - + - echo "string-slice-1" From fbaa7be52edc5807a33b48da5eb161f497563d3d Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sat, 27 Nov 2021 11:03:48 +0000 Subject: [PATCH 06/19] Bump mvdan.cc/sh/v3 from 3.4.0 to 3.4.1 Bumps [mvdan.cc/sh/v3](https://github.com/mvdan/sh) from 3.4.0 to 3.4.1. - [Release notes](https://github.com/mvdan/sh/releases) - [Changelog](https://github.com/mvdan/sh/blob/master/CHANGELOG.md) - [Commits](https://github.com/mvdan/sh/compare/v3.4.0...v3.4.1) --- updated-dependencies: - dependency-name: mvdan.cc/sh/v3 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 3dc56675..92fad497 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/stretchr/testify v1.7.0 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c - mvdan.cc/sh/v3 v3.4.0 + mvdan.cc/sh/v3 v3.4.1 ) go 1.16 diff --git a/go.sum b/go.sum index aa3f09b5..be98ab83 100644 --- a/go.sum +++ b/go.sum @@ -68,5 +68,5 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= mvdan.cc/editorconfig v0.2.0/go.mod h1:lvnnD3BNdBYkhq+B4uBuFFKatfp02eB6HixDvEz91C0= -mvdan.cc/sh/v3 v3.4.0 h1:thPCJ0hffn/Y/vMGs3HVMPYStNTyr2+lQee8LQiPZSU= -mvdan.cc/sh/v3 v3.4.0/go.mod h1:p/tqPPI4Epfk2rICAe2RoaNd8HBSJ8t9Y2DA9yQlbzY= +mvdan.cc/sh/v3 v3.4.1 h1:sY7JU00i7R0mEm7v0g7Z88l1Hf/6K5wVIdA0o4hoSbo= +mvdan.cc/sh/v3 v3.4.1/go.mod h1:p/tqPPI4Epfk2rICAe2RoaNd8HBSJ8t9Y2DA9yQlbzY= From a8767a2b1aebc24122b668985b27e10f620394ec Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 28 Nov 2021 15:38:47 -0300 Subject: [PATCH 07/19] CHANGELOG: Mention mvdan/sh upgrade --- CHANGELOG.md | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e019d034..0253968d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ ## Unreleased +- Upgrade [mvdan/sh](https://github.com/mvdan/sh) which contains two + relevant fixes: + - Fix quote of empty strings in `shellQuote` + ([#609](https://github.com/go-task/task/issues/609), [mvdan/sh#763](https://github.com/mvdan/sh/issues/763)). + - Fix issue of wrong environment variable being picked when there's another + very similar one + ([#586](https://github.com/go-task/task/issues/586), [mndan/sh#745](https://github.com/mvdan/sh/pull/745)). - Install shell completions automatically when installing via Homebrew ([#264](https://github.com/go-task/task/issues/264), [#592](https://github.com/go-task/task/pull/592), [go-task/homebrew-tap#2](https://github.com/go-task/homebrew-tap/pull/2)). From db05059b42b80dc4b4cdd7eceb543432e951e15a Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 28 Nov 2021 15:43:38 -0300 Subject: [PATCH 08/19] CHANGELOG: Add entry for #614 and #612 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 0253968d..2ed89225 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Fix nil pointer when `cmd:` was left empty + ([#612](https://github.com/go-task/task/issues/612), [#614](https://github.com/go-task/task/pull/614)). - Upgrade [mvdan/sh](https://github.com/mvdan/sh) which contains two relevant fixes: - Fix quote of empty strings in `shellQuote` From 01c86636e951217c7c67236a2309c0ac1f1a2f1b Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 28 Nov 2021 15:54:49 -0300 Subject: [PATCH 09/19] Add CHANGELOG and minor changes to #613 --- CHANGELOG.md | 2 ++ cmd/task/task.go | 4 ++-- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2ed89225..e99783ad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Quote each `{{.CLI_ARGS}}` argument to prevent one with spaces to become many + ([#613](https://github.com/go-task/task/pull/613)). - Fix nil pointer when `cmd:` was left empty ([#612](https://github.com/go-task/task/issues/612), [#614](https://github.com/go-task/task/pull/614)). - Upgrade [mvdan/sh](https://github.com/mvdan/sh) which contains two diff --git a/cmd/task/task.go b/cmd/task/task.go index 0f9f9654..2f7a11c0 100644 --- a/cmd/task/task.go +++ b/cmd/task/task.go @@ -206,11 +206,11 @@ func getArgs() ([]string, string, error) { return args, "", nil } - quotedCliArgs := []string{} + var quotedCliArgs []string for _, arg := range args[doubleDashPos:] { quotedCliArg, err := syntax.Quote(arg, syntax.LangBash) if err != nil { - return []string{}, "", err + return nil, "", err } quotedCliArgs = append(quotedCliArgs, quotedCliArg) } From 0dcc1390a608098fb2444d9cb9ddef138a8179fd Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 28 Nov 2021 15:58:41 -0300 Subject: [PATCH 10/19] GitHub: Remove automatic "bug" or "feature" lables in issues --- .github/ISSUE_TEMPLATE/bug_report.md | 1 - .github/ISSUE_TEMPLATE/feature_request.md | 1 - 2 files changed, 2 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 906168e5..705d03fd 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -1,7 +1,6 @@ --- name: Bug Report about: Use the template to report bugs and issues -labels: bug --- - Task version: diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md index 39f3191a..68b9df07 100644 --- a/.github/ISSUE_TEMPLATE/feature_request.md +++ b/.github/ISSUE_TEMPLATE/feature_request.md @@ -1,7 +1,6 @@ --- name: Feature Request about: Use the template to make feature requests -labels: feature --- Describe in detail what feature do you want to see in Task. From 97287377d1ecec943cbf0698dc30b463d78df07a Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 28 Nov 2021 16:12:33 -0300 Subject: [PATCH 11/19] CHANGELOG: Add entries for #597 and #598 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e99783ad..2c8e7cef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Fix an issue with preconditions and context errors + ([#597](https://github.com/go-task/task/issues/597), [#598](https://github.com/go-task/task/pull/598)). - Quote each `{{.CLI_ARGS}}` argument to prevent one with spaces to become many ([#613](https://github.com/go-task/task/pull/613)). - Fix nil pointer when `cmd:` was left empty From 784847f35bb1e4791785a39d6fd2c2b413ca9d3c Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 28 Nov 2021 16:15:54 -0300 Subject: [PATCH 12/19] CHANGELOG: Add entry for #533 and #588 --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c8e7cef..099d803d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Unreleased +- Add logging in verbose mode for when a task starts and finishes + ([#533](https://github.com/go-task/task/issues/533), [#588](https://github.com/go-task/task/pull/588)). - Fix an issue with preconditions and context errors ([#597](https://github.com/go-task/task/issues/597), [#598](https://github.com/go-task/task/pull/598)). - Quote each `{{.CLI_ARGS}}` argument to prevent one with spaces to become many From d9859b18fedb9df13df0b4cedeb4d35676724f8e Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 28 Nov 2021 16:19:30 -0300 Subject: [PATCH 13/19] v3.9.1 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 099d803d..919768f0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Unreleased +## v3.9.1 - 2021-11-28 - Add logging in verbose mode for when a task starts and finishes ([#533](https://github.com/go-task/task/issues/533), [#588](https://github.com/go-task/task/pull/588)). From 168e8c925c152b619c3344b57e5a79b96ad4ff08 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Mon, 29 Nov 2021 12:55:43 -0300 Subject: [PATCH 14/19] CHANGELOG: Fix typo --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 919768f0..a95e6f13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,7 +16,7 @@ ([#609](https://github.com/go-task/task/issues/609), [mvdan/sh#763](https://github.com/mvdan/sh/issues/763)). - Fix issue of wrong environment variable being picked when there's another very similar one - ([#586](https://github.com/go-task/task/issues/586), [mndan/sh#745](https://github.com/mvdan/sh/pull/745)). + ([#586](https://github.com/go-task/task/issues/586), [mvdan/sh#745](https://github.com/mvdan/sh/pull/745)). - Install shell completions automatically when installing via Homebrew ([#264](https://github.com/go-task/task/issues/264), [#592](https://github.com/go-task/task/pull/592), [go-task/homebrew-tap#2](https://github.com/go-task/homebrew-tap/pull/2)). From 290d45fd0566a39bdd69f27eeefa1dc61ac37d21 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 2 Dec 2021 09:42:39 -0300 Subject: [PATCH 15/19] Upgrade mvdan.cc/sh --- CHANGELOG.md | 6 ++++++ go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a95e6f13..b13ce61c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # Changelog +## Unreleased + +- Upgrade [mvdan/sh](https://github.com/mvdan/sh) which contains a fix a for + a important regression on Windows + ([#619](https://github.com/go-task/task/issues/619), [mvdan/sh#768](https://github.com/mvdan/sh/issues/768), [mvdan/sh#769](https://github.com/mvdan/sh/pull/769)). + ## v3.9.1 - 2021-11-28 - Add logging in verbose mode for when a task starts and finishes diff --git a/go.mod b/go.mod index 92fad497..f35f1311 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/stretchr/testify v1.7.0 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c - mvdan.cc/sh/v3 v3.4.1 + mvdan.cc/sh/v3 v3.4.2-0.20211202103622-5ae9d64e1402 ) go 1.16 diff --git a/go.sum b/go.sum index be98ab83..fe1c4130 100644 --- a/go.sum +++ b/go.sum @@ -68,5 +68,5 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= mvdan.cc/editorconfig v0.2.0/go.mod h1:lvnnD3BNdBYkhq+B4uBuFFKatfp02eB6HixDvEz91C0= -mvdan.cc/sh/v3 v3.4.1 h1:sY7JU00i7R0mEm7v0g7Z88l1Hf/6K5wVIdA0o4hoSbo= -mvdan.cc/sh/v3 v3.4.1/go.mod h1:p/tqPPI4Epfk2rICAe2RoaNd8HBSJ8t9Y2DA9yQlbzY= +mvdan.cc/sh/v3 v3.4.2-0.20211202103622-5ae9d64e1402 h1:IhYcaLRZjSJqGoLrn+sXXFq3Xhd40I0wBkoIyg6cSZs= +mvdan.cc/sh/v3 v3.4.2-0.20211202103622-5ae9d64e1402/go.mod h1:p/tqPPI4Epfk2rICAe2RoaNd8HBSJ8t9Y2DA9yQlbzY= From df4e3aea79da52f8dda6ab8bcca04dc28e094472 Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 2 Dec 2021 09:48:30 -0300 Subject: [PATCH 16/19] v3.9.2 --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b13ce61c..679f07ef 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Changelog -## Unreleased +## v3.9.2 - 2021-12-02 - Upgrade [mvdan/sh](https://github.com/mvdan/sh) which contains a fix a for a important regression on Windows From 85232bd70488635dcea288837225e6f392000c1e Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Sun, 19 Dec 2021 22:06:51 -0300 Subject: [PATCH 17/19] Upgrade GitHub actions Closes #633 --- .github/workflows/release.yml | 4 ++-- .github/workflows/test.yml | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 57b89bd8..12d2f0ec 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -10,10 +10,10 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v1 + uses: actions/checkout@v2 - name: Set up Go - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: 1.17.x diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 1e70a295..08684fad 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -10,13 +10,13 @@ jobs: runs-on: ${{matrix.platform}} steps: - name: Set up Go ${{matrix.go-version}} - uses: actions/setup-go@v1 + uses: actions/setup-go@v2 with: go-version: ${{matrix.go-version}} id: go - name: Check out code into the Go module directory - uses: actions/checkout@v1 + uses: actions/checkout@v2 - name: Download Go modules run: go mod download From 9a5d49774ec97a5e57e860d4f519aac79aaab18d Mon Sep 17 00:00:00 2001 From: nichady <57887348+nichady@users.noreply.github.com> Date: Mon, 20 Dec 2021 20:00:34 -0600 Subject: [PATCH 18/19] replace usages of ioutil with io and os --- init.go | 3 +- internal/status/checksum.go | 5 ++-- task_test.go | 56 ++++++++++++++++++------------------- 3 files changed, 31 insertions(+), 33 deletions(-) diff --git a/init.go b/init.go index 642a326c..1c1d043f 100644 --- a/init.go +++ b/init.go @@ -3,7 +3,6 @@ package task import ( "fmt" "io" - "io/ioutil" "os" "path/filepath" ) @@ -30,7 +29,7 @@ func InitTaskfile(w io.Writer, dir string) error { return ErrTaskfileAlreadyExists } - if err := ioutil.WriteFile(f, []byte(defaultTaskfile), 0644); err != nil { + if err := os.WriteFile(f, []byte(defaultTaskfile), 0644); err != nil { return err } fmt.Fprintf(w, "Taskfile.yml created in the current directory\n") diff --git a/internal/status/checksum.go b/internal/status/checksum.go index 2ab6a9ff..ab608a8d 100644 --- a/internal/status/checksum.go +++ b/internal/status/checksum.go @@ -4,7 +4,6 @@ import ( "crypto/md5" "fmt" "io" - "io/ioutil" "os" "path/filepath" "regexp" @@ -30,7 +29,7 @@ func (c *Checksum) IsUpToDate() (bool, error) { checksumFile := c.checksumFilePath() - data, _ := ioutil.ReadFile(checksumFile) + data, _ := os.ReadFile(checksumFile) oldMd5 := strings.TrimSpace(string(data)) sources, err := globs(c.TaskDir, c.Sources) @@ -45,7 +44,7 @@ func (c *Checksum) IsUpToDate() (bool, error) { if !c.Dry { _ = os.MkdirAll(filepath.Join(c.BaseDir, ".task", "checksum"), 0755) - if err = ioutil.WriteFile(checksumFile, []byte(newMd5+"\n"), 0644); err != nil { + if err = os.WriteFile(checksumFile, []byte(newMd5+"\n"), 0644); err != nil { return false, err } } diff --git a/task_test.go b/task_test.go index 97558950..db83a851 100644 --- a/task_test.go +++ b/task_test.go @@ -4,7 +4,7 @@ import ( "bytes" "context" "fmt" - "io/ioutil" + "io" "os" "path/filepath" "runtime" @@ -41,15 +41,15 @@ func (fct fileContentTest) Run(t *testing.T) { e := &task.Executor{ Dir: fct.Dir, - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, + Stdout: io.Discard, + Stderr: io.Discard, } assert.NoError(t, e.Setup(), "e.Setup()") assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: fct.Target}), "e.Run(target)") for name, expectContent := range fct.Files { t.Run(fct.name(name), func(t *testing.T) { - b, err := ioutil.ReadFile(filepath.Join(fct.Dir, name)) + b, err := os.ReadFile(filepath.Join(fct.Dir, name)) assert.NoError(t, err, "Error reading file") s := string(b) if fct.TrimSpace { @@ -63,8 +63,8 @@ func (fct fileContentTest) Run(t *testing.T) { func TestEmptyTask(t *testing.T) { e := &task.Executor{ Dir: "testdata/empty_task", - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, + Stdout: io.Discard, + Stderr: io.Discard, } assert.NoError(t, e.Setup(), "e.Setup()") assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "default"})) @@ -168,8 +168,8 @@ func TestVarsInvalidTmpl(t *testing.T) { e := &task.Executor{ Dir: dir, - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, + Stdout: io.Discard, + Stderr: io.Discard, } assert.NoError(t, e.Setup(), "e.Setup()") assert.EqualError(t, e.Run(context.Background(), taskfile.Call{Task: target}), expectError, "e.Run(target)") @@ -183,8 +183,8 @@ func TestConcurrency(t *testing.T) { e := &task.Executor{ Dir: dir, - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, + Stdout: io.Discard, + Stderr: io.Discard, Concurrency: 1, } assert.NoError(t, e.Setup(), "e.Setup()") @@ -236,8 +236,8 @@ func TestDeps(t *testing.T) { e := &task.Executor{ Dir: dir, - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, + Stdout: io.Discard, + Stderr: io.Discard, } assert.NoError(t, e.Setup()) assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "default"})) @@ -557,7 +557,7 @@ func TestInit(t *testing.T) { t.Errorf("Taskfile.yml should not exist") } - if err := task.InitTaskfile(ioutil.Discard, dir); err != nil { + if err := task.InitTaskfile(io.Discard, dir); err != nil { t.Error(err) } @@ -571,8 +571,8 @@ func TestCyclicDep(t *testing.T) { e := task.Executor{ Dir: dir, - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, + Stdout: io.Discard, + Stderr: io.Discard, } assert.NoError(t, e.Setup()) assert.IsType(t, &task.MaximumTaskCallExceededError{}, e.Run(context.Background(), taskfile.Call{Task: "task-1"})) @@ -590,8 +590,8 @@ func TestTaskVersion(t *testing.T) { t.Run(test.Dir, func(t *testing.T) { e := task.Executor{ Dir: test.Dir, - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, + Stdout: io.Discard, + Stderr: io.Discard, } assert.NoError(t, e.Setup()) assert.Equal(t, test.Version, e.Taskfile.Version) @@ -605,8 +605,8 @@ func TestTaskIgnoreErrors(t *testing.T) { e := task.Executor{ Dir: dir, - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, + Stdout: io.Discard, + Stderr: io.Discard, } assert.NoError(t, e.Setup()) @@ -668,8 +668,8 @@ func TestDryChecksum(t *testing.T) { e := task.Executor{ Dir: dir, - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, + Stdout: io.Discard, + Stderr: io.Discard, Dry: true, } assert.NoError(t, e.Setup()) @@ -769,8 +769,8 @@ func TestIncludesOptional(t *testing.T) { func TestIncludesOptionalImplicitFalse(t *testing.T) { e := task.Executor{ Dir: "testdata/includes_optional_implicit_false", - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, + Stdout: io.Discard, + Stderr: io.Discard, } err := e.Setup() @@ -781,8 +781,8 @@ func TestIncludesOptionalImplicitFalse(t *testing.T) { func TestIncludesOptionalExplicitFalse(t *testing.T) { e := task.Executor{ Dir: "testdata/includes_optional_explicit_false", - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, + Stdout: io.Discard, + Stderr: io.Discard, } err := e.Setup() @@ -804,7 +804,7 @@ func TestSummary(t *testing.T) { assert.NoError(t, e.Setup()) assert.NoError(t, e.Run(context.Background(), taskfile.Call{Task: "task-with-summary"}, taskfile.Call{Task: "other-task-with-summary"})) - data, err := ioutil.ReadFile(filepath.Join(dir, "task-with-summary.txt")) + data, err := os.ReadFile(filepath.Join(dir, "task-with-summary.txt")) assert.NoError(t, err) expectedOutput := string(data) @@ -895,8 +895,8 @@ func TestDynamicVariablesShouldRunOnTheTaskDir(t *testing.T) { func TestDisplaysErrorOnUnsupportedVersion(t *testing.T) { e := task.Executor{ Dir: "testdata/version/v1", - Stdout: ioutil.Discard, - Stderr: ioutil.Discard, + Stdout: io.Discard, + Stderr: io.Discard, } err := e.Setup() assert.Error(t, err) From d5d198411625c638084326dd3a4d21504e9e44fb Mon Sep 17 00:00:00 2001 From: Andrey Nering Date: Thu, 30 Dec 2021 16:45:08 -0300 Subject: [PATCH 19/19] Pin released vetsion of mvdan/sh v3.4.2 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index f35f1311..1dcfa15f 100644 --- a/go.mod +++ b/go.mod @@ -11,7 +11,7 @@ require ( github.com/stretchr/testify v1.7.0 golang.org/x/sync v0.0.0-20210220032951-036812b2e83c gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c - mvdan.cc/sh/v3 v3.4.2-0.20211202103622-5ae9d64e1402 + mvdan.cc/sh/v3 v3.4.2 ) go 1.16 diff --git a/go.sum b/go.sum index fe1c4130..b947276c 100644 --- a/go.sum +++ b/go.sum @@ -68,5 +68,5 @@ gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= mvdan.cc/editorconfig v0.2.0/go.mod h1:lvnnD3BNdBYkhq+B4uBuFFKatfp02eB6HixDvEz91C0= -mvdan.cc/sh/v3 v3.4.2-0.20211202103622-5ae9d64e1402 h1:IhYcaLRZjSJqGoLrn+sXXFq3Xhd40I0wBkoIyg6cSZs= -mvdan.cc/sh/v3 v3.4.2-0.20211202103622-5ae9d64e1402/go.mod h1:p/tqPPI4Epfk2rICAe2RoaNd8HBSJ8t9Y2DA9yQlbzY= +mvdan.cc/sh/v3 v3.4.2 h1:d3TKODXfZ1bjWU/StENN+GDg5xOzNu5+C8AEu405E5U= +mvdan.cc/sh/v3 v3.4.2/go.mod h1:p/tqPPI4Epfk2rICAe2RoaNd8HBSJ8t9Y2DA9yQlbzY=