1
0
mirror of https://github.com/go-task/task.git synced 2025-02-09 13:47:06 +02:00

refactor: orderedmap package -> omap

This commit is contained in:
Pete Davison 2024-01-04 00:31:24 +00:00
parent 1a03c3fbaf
commit 7cb45a23b6
8 changed files with 20 additions and 20 deletions

View File

@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/go-task/task/v3/args" "github.com/go-task/task/v3/args"
"github.com/go-task/task/v3/internal/orderedmap" "github.com/go-task/task/v3/internal/omap"
"github.com/go-task/task/v3/taskfile/ast" "github.com/go-task/task/v3/taskfile/ast"
) )
@ -33,7 +33,7 @@ func TestArgs(t *testing.T) {
{Task: "task-c"}, {Task: "task-c"},
}, },
ExpectedGlobals: &ast.Vars{ ExpectedGlobals: &ast.Vars{
OrderedMap: orderedmap.FromMapWithOrder( OrderedMap: omap.FromMapWithOrder(
map[string]ast.Var{ map[string]ast.Var{
"FOO": {Value: "bar"}, "FOO": {Value: "bar"},
"BAR": {Value: "baz"}, "BAR": {Value: "baz"},
@ -49,7 +49,7 @@ func TestArgs(t *testing.T) {
{Task: "task-a"}, {Task: "task-a"},
}, },
ExpectedGlobals: &ast.Vars{ ExpectedGlobals: &ast.Vars{
OrderedMap: orderedmap.FromMapWithOrder( OrderedMap: omap.FromMapWithOrder(
map[string]ast.Var{ map[string]ast.Var{
"CONTENT": {Value: "with some spaces"}, "CONTENT": {Value: "with some spaces"},
}, },
@ -64,7 +64,7 @@ func TestArgs(t *testing.T) {
{Task: "task-b"}, {Task: "task-b"},
}, },
ExpectedGlobals: &ast.Vars{ ExpectedGlobals: &ast.Vars{
OrderedMap: orderedmap.FromMapWithOrder( OrderedMap: omap.FromMapWithOrder(
map[string]ast.Var{ map[string]ast.Var{
"FOO": {Value: "bar"}, "FOO": {Value: "bar"},
}, },
@ -84,7 +84,7 @@ func TestArgs(t *testing.T) {
Args: []string{"FOO=bar", "BAR=baz"}, Args: []string{"FOO=bar", "BAR=baz"},
ExpectedCalls: []ast.Call{}, ExpectedCalls: []ast.Call{},
ExpectedGlobals: &ast.Vars{ ExpectedGlobals: &ast.Vars{
OrderedMap: orderedmap.FromMapWithOrder( OrderedMap: omap.FromMapWithOrder(
map[string]ast.Var{ map[string]ast.Var{
"FOO": {Value: "bar"}, "FOO": {Value: "bar"},
"BAR": {Value: "baz"}, "BAR": {Value: "baz"},

View File

@ -1,4 +1,4 @@
package orderedmap package omap
import ( import (
"fmt" "fmt"

View File

@ -1,4 +1,4 @@
package orderedmap package omap
import ( import (
"testing" "testing"

View File

@ -10,7 +10,7 @@ import (
"github.com/stretchr/testify/assert" "github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"github.com/go-task/task/v3/internal/orderedmap" "github.com/go-task/task/v3/internal/omap"
"github.com/go-task/task/v3/internal/output" "github.com/go-task/task/v3/internal/output"
"github.com/go-task/task/v3/internal/templater" "github.com/go-task/task/v3/internal/templater"
"github.com/go-task/task/v3/taskfile/ast" "github.com/go-task/task/v3/taskfile/ast"
@ -48,7 +48,7 @@ func TestGroup(t *testing.T) {
func TestGroupWithBeginEnd(t *testing.T) { func TestGroupWithBeginEnd(t *testing.T) {
tmpl := templater.Templater{ tmpl := templater.Templater{
Vars: &ast.Vars{ Vars: &ast.Vars{
OrderedMap: orderedmap.FromMap(map[string]ast.Var{ OrderedMap: omap.FromMap(map[string]ast.Var{
"VAR1": {Value: "example-value"}, "VAR1": {Value: "example-value"},
}), }),
}, },

View File

@ -7,7 +7,7 @@ import (
"github.com/go-task/task/v3/internal/execext" "github.com/go-task/task/v3/internal/execext"
"github.com/go-task/task/v3/internal/filepathext" "github.com/go-task/task/v3/internal/filepathext"
"github.com/go-task/task/v3/internal/orderedmap" omap "github.com/go-task/task/v3/internal/omap"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
) )
@ -27,7 +27,7 @@ type Include struct {
// Includes represents information about included tasksfiles // Includes represents information about included tasksfiles
type Includes struct { type Includes struct {
orderedmap.OrderedMap[string, Include] omap.OrderedMap[string, Include]
} }
// UnmarshalYAML implements the yaml.Unmarshaler interface. // UnmarshalYAML implements the yaml.Unmarshaler interface.

View File

@ -7,7 +7,7 @@ import (
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"github.com/go-task/task/v3/internal/orderedmap" "github.com/go-task/task/v3/internal/omap"
"github.com/go-task/task/v3/taskfile/ast" "github.com/go-task/task/v3/taskfile/ast"
) )
@ -39,7 +39,7 @@ vars:
&ast.Cmd{}, &ast.Cmd{},
&ast.Cmd{ &ast.Cmd{
Task: "another-task", Vars: &ast.Vars{ Task: "another-task", Vars: &ast.Vars{
OrderedMap: orderedmap.FromMapWithOrder( OrderedMap: omap.FromMapWithOrder(
map[string]ast.Var{ map[string]ast.Var{
"PARAM1": {Value: "VALUE1"}, "PARAM1": {Value: "VALUE1"},
"PARAM2": {Value: "VALUE2"}, "PARAM2": {Value: "VALUE2"},
@ -59,7 +59,7 @@ vars:
&ast.Cmd{}, &ast.Cmd{},
&ast.Cmd{ &ast.Cmd{
Task: "some_task", Vars: &ast.Vars{ Task: "some_task", Vars: &ast.Vars{
OrderedMap: orderedmap.FromMapWithOrder( OrderedMap: omap.FromMapWithOrder(
map[string]ast.Var{ map[string]ast.Var{
"PARAM1": {Value: "var"}, "PARAM1": {Value: "var"},
}, },
@ -79,7 +79,7 @@ vars:
&ast.Dep{}, &ast.Dep{},
&ast.Dep{ &ast.Dep{
Task: "another-task", Vars: &ast.Vars{ Task: "another-task", Vars: &ast.Vars{
OrderedMap: orderedmap.FromMapWithOrder( OrderedMap: omap.FromMapWithOrder(
map[string]ast.Var{ map[string]ast.Var{
"PARAM1": {Value: "VALUE1"}, "PARAM1": {Value: "VALUE1"},
"PARAM2": {Value: "VALUE2"}, "PARAM2": {Value: "VALUE2"},

View File

@ -5,18 +5,18 @@ import (
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"github.com/go-task/task/v3/internal/orderedmap" "github.com/go-task/task/v3/internal/omap"
) )
// Tasks represents a group of tasks // Tasks represents a group of tasks
type Tasks struct { type Tasks struct {
orderedmap.OrderedMap[string, *Task] omap.OrderedMap[string, *Task]
} }
func (t *Tasks) UnmarshalYAML(node *yaml.Node) error { func (t *Tasks) UnmarshalYAML(node *yaml.Node) error {
switch node.Kind { switch node.Kind {
case yaml.MappingNode: case yaml.MappingNode:
tasks := orderedmap.New[string, *Task]() tasks := omap.New[string, *Task]()
if err := node.Decode(&tasks); err != nil { if err := node.Decode(&tasks); err != nil {
return err return err
} }

View File

@ -7,12 +7,12 @@ import (
"gopkg.in/yaml.v3" "gopkg.in/yaml.v3"
"github.com/go-task/task/v3/internal/experiments" "github.com/go-task/task/v3/internal/experiments"
"github.com/go-task/task/v3/internal/orderedmap" "github.com/go-task/task/v3/internal/omap"
) )
// Vars is a string[string] variables map. // Vars is a string[string] variables map.
type Vars struct { type Vars struct {
orderedmap.OrderedMap[string, Var] omap.OrderedMap[string, Var]
} }
// ToCacheMap converts Vars to a map containing only the static // ToCacheMap converts Vars to a map containing only the static