1
0
mirror of https://github.com/go-task/task.git synced 2025-08-10 22:42:19 +02:00

Merge branch 'master' into v3

This commit is contained in:
Andrey Nering
2020-05-20 22:26:45 -03:00
9 changed files with 56 additions and 24 deletions

View File

@@ -36,10 +36,16 @@
commands are green, errors are red, etc commands are green, errors are red, etc
([#207](https://github.com/go-task/task/pull/207)). ([#207](https://github.com/go-task/task/pull/207)).
## Unreleased ## v2.8.1 - 2019-05-20
- Fix error code for the `--help` flag
([#300](https://github.com/go-task/task/issues/300), [#330](https://github.com/go-task/task/pull/330)).
- Print version to stdout instead of stderr
([#299](https://github.com/go-task/task/issues/299), [#329](https://github.com/go-task/task/pull/329)).
- Supress `context` errors when using the `--watch` flag - Supress `context` errors when using the `--watch` flag
([#313](https://github.com/go-task/task/issues/313), [#317](https://github.com/go-task/task/pull/317)). ([#313](https://github.com/go-task/task/issues/313), [#317](https://github.com/go-task/task/pull/317)).
- Support templating on description
([#276](https://github.com/go-task/task/issues/276), [#283](https://github.com/go-task/task/pull/283)).
## v2.8.0 - 2019-12-07 ## v2.8.0 - 2019-12-07

View File

@@ -5,4 +5,4 @@
- [Examples](examples.md) - [Examples](examples.md)
- [Releasing Task](releasing_task.md) - [Releasing Task](releasing_task.md)
- [Alternative Task Runners](alternative_task_runners.md) - [Alternative Task Runners](alternative_task_runners.md)
- [![Github](https://icongram.jgog.in/simple/github.svg?color=808080&size=16)Github](https://github.com/go-task/task) - [![GitHub](https://icongram.jgog.in/simple/github.svg?color=808080&size=16)GitHub](https://github.com/go-task/task)

2
go.mod
View File

@@ -10,7 +10,7 @@ require (
github.com/stretchr/testify v1.5.1 github.com/stretchr/testify v1.5.1
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c
mvdan.cc/sh/v3 v3.1.0 mvdan.cc/sh/v3 v3.1.1
) )
go 1.13 go 1.13

4
go.sum
View File

@@ -62,5 +62,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 h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
mvdan.cc/editorconfig v0.1.1-0.20200121172147-e40951bde157/go.mod h1:Ge4atmRUYqueGppvJ7JNrtqpqokoJEFxYbP0Z+WeKS8= mvdan.cc/editorconfig v0.1.1-0.20200121172147-e40951bde157/go.mod h1:Ge4atmRUYqueGppvJ7JNrtqpqokoJEFxYbP0Z+WeKS8=
mvdan.cc/sh/v3 v3.1.0 h1:bFxsEzIubuABloc8G1Ko78rbZZ0JspNN9e9+R/w3z5k= mvdan.cc/sh/v3 v3.1.1 h1:niuYC5Ug0KzLuN6CNX3ru37v4MkVD5Wm9T4Mk2eJr9A=
mvdan.cc/sh/v3 v3.1.0/go.mod h1:F+Vm4ZxPJxDKExMLhvjuI50oPnedVXpfjNSrusiTOno= mvdan.cc/sh/v3 v3.1.1/go.mod h1:F+Vm4ZxPJxDKExMLhvjuI50oPnedVXpfjNSrusiTOno=

2
vendor/modules.txt vendored
View File

@@ -39,7 +39,7 @@ golang.org/x/xerrors
golang.org/x/xerrors/internal golang.org/x/xerrors/internal
# gopkg.in/yaml.v2 v2.2.2 # gopkg.in/yaml.v2 v2.2.2
gopkg.in/yaml.v2 gopkg.in/yaml.v2
# mvdan.cc/sh/v3 v3.1.0 # mvdan.cc/sh/v3 v3.1.1
mvdan.cc/sh/v3/expand mvdan.cc/sh/v3/expand
mvdan.cc/sh/v3/interp mvdan.cc/sh/v3/interp
mvdan.cc/sh/v3/pattern mvdan.cc/sh/v3/pattern

View File

@@ -41,6 +41,18 @@ func (o overlayEnviron) Each(f func(name string, vr expand.Variable) bool) {
func execEnv(env expand.Environ) []string { func execEnv(env expand.Environ) []string {
list := make([]string, 0, 64) list := make([]string, 0, 64)
env.Each(func(name string, vr expand.Variable) bool { env.Each(func(name string, vr expand.Variable) bool {
if !vr.IsSet() {
// If a variable is set globally but unset in the
// runner, we need to ensure it's not part of the final
// list. Seems like zeroing the element is enough.
// This is a linear search, but this scenario should be
// rare, and the number of variables shouldn't be large.
for i, kv := range list {
if strings.HasPrefix(kv, name+"=") {
list[i] = ""
}
}
}
if vr.Exported { if vr.Exported {
list = append(list, name+"="+vr.String()) list = append(list, name+"="+vr.String())
} }

View File

@@ -993,7 +993,7 @@ func (p *Parser) advanceLitRe(r rune) {
p.quote = noState p.quote = noState
return return
} }
case ' ', '\t', '\r', '\n': case ' ', '\t', '\r', '\n', ';', '&', '>', '<':
if p.rxOpenParens <= 0 { if p.rxOpenParens <= 0 {
p.tok, p.val = _LitWord, p.endLit() p.tok, p.val = _LitWord, p.endLit()
p.quote = noState p.quote = noState
@@ -1002,7 +1002,7 @@ func (p *Parser) advanceLitRe(r rune) {
case '"', '\'', '$', '`': case '"', '\'', '$', '`':
p.tok, p.val = _Lit, p.endLit() p.tok, p.val = _Lit, p.endLit()
return return
case utf8.RuneSelf, ';', '&', '>', '<': case utf8.RuneSelf:
p.tok, p.val = _LitWord, p.endLit() p.tok, p.val = _LitWord, p.endLit()
p.quote = noState p.quote = noState
return return

View File

@@ -545,12 +545,26 @@ func (p *Parser) doHeredocs() {
if i > 0 && p.r == '\n' { if i > 0 && p.r == '\n' {
p.rune() p.rune()
} }
lastLine := p.npos.line
if quoted { if quoted {
r.Hdoc = p.quotedHdocWord() r.Hdoc = p.quotedHdocWord()
} else { } else {
p.next() p.next()
r.Hdoc = p.getWord() r.Hdoc = p.getWord()
} }
if r.Hdoc != nil {
lastLine = r.Hdoc.End().line
}
if lastLine < p.npos.line {
// TODO: It seems like this triggers more often than it
// should. Look into it.
l := p.lit(p.npos, "")
if r.Hdoc == nil {
r.Hdoc = p.word(p.wps(l))
} else {
r.Hdoc.Parts = append(r.Hdoc.Parts, l)
}
}
if stop := p.hdocStops[len(p.hdocStops)-1]; stop != nil { if stop := p.hdocStops[len(p.hdocStops)-1]; stop != nil {
p.posErr(r.Pos(), "unclosed here-document '%s'", stop) p.posErr(r.Pos(), "unclosed here-document '%s'", stop)
} }

View File

@@ -165,26 +165,26 @@ type colCounter struct {
lineStart bool lineStart bool
} }
func (c *colCounter) WriteByte(b byte) error { func (c *colCounter) addByte(b byte) {
switch b { switch b {
case '\n': case '\n':
c.column = 0 c.column = 0
c.lineStart = true c.lineStart = true
case '\t', ' ': case '\t', ' ', tabwriter.Escape:
default: default:
c.lineStart = false c.lineStart = false
} }
c.column++ c.column++
}
func (c *colCounter) WriteByte(b byte) error {
c.addByte(b)
return c.Writer.WriteByte(b) return c.Writer.WriteByte(b)
} }
func (c *colCounter) WriteString(s string) (int, error) { func (c *colCounter) WriteString(s string) (int, error) {
c.lineStart = false for _, b := range []byte(s) {
for _, r := range s { c.addByte(b)
if r == '\n' {
c.column = 0
}
c.column++
} }
return c.Writer.WriteString(s) return c.Writer.WriteString(s)
} }
@@ -269,15 +269,15 @@ func (p *Printer) space() {
} }
func (p *Printer) spacePad(pos Pos) { func (p *Printer) spacePad(pos Pos) {
if p.wantSpace {
p.WriteByte(' ')
p.wantSpace = false
}
if p.cols.lineStart { if p.cols.lineStart {
// Never add padding at the start of a line, since this may // Never add padding at the start of a line, since this may
// result in broken indentation or mixing of spaces and tabs. // result in broken indentation or mixing of spaces and tabs.
return return
} }
if p.wantSpace {
p.WriteByte(' ')
p.wantSpace = false
}
for !p.cols.lineStart && p.cols.column > 0 && p.cols.column < int(pos.col) { for !p.cols.lineStart && p.cols.column > 0 && p.cols.column < int(pos.col) {
p.WriteByte(' ') p.WriteByte(' ')
} }
@@ -331,7 +331,7 @@ func (p *Printer) writeLit(s string) {
p.WriteString(s) p.WriteString(s)
return return
} }
p.WriteByte('\xff') p.WriteByte(tabwriter.Escape)
for i := 0; i < len(s); i++ { for i := 0; i < len(s); i++ {
b := s[i] b := s[i]
if b != '\t' { if b != '\t' {
@@ -340,7 +340,7 @@ func (p *Printer) writeLit(s string) {
} }
p.WriteByte(b) p.WriteByte(b)
} }
p.WriteByte('\xff') p.WriteByte(tabwriter.Escape)
} }
func (p *Printer) incLevel() { func (p *Printer) incLevel() {
@@ -370,11 +370,11 @@ func (p *Printer) indent() {
switch { switch {
case p.level == 0: case p.level == 0:
case p.indentSpaces == 0: case p.indentSpaces == 0:
p.WriteByte('\xff') p.WriteByte(tabwriter.Escape)
for i := uint(0); i < p.level; i++ { for i := uint(0); i < p.level; i++ {
p.WriteByte('\t') p.WriteByte('\t')
} }
p.WriteByte('\xff') p.WriteByte(tabwriter.Escape)
default: default:
p.spaces(p.indentSpaces * p.level) p.spaces(p.indentSpaces * p.level)
} }