nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: openllb/hlb
Pull request #155 (2020-05-22 16:46:55)

[#153] trim trailing newlines from localRun output


Patch:
diff --git a/codegen/chain.go b/codegen/chain.go
index f3639e0..412ea0d 100644
--- a/codegen/chain.go
+++ b/codegen/chain.go
@@ -997,7 +997,7 @@ func (cg *CodeGen) EmitStringChainStmt(ctx context.Context, scope *parser.Scope,
 			return nil, err
 		}
 		return func(_ string) (string, error) {
-			return buf.String(), nil
+			return strings.TrimRight(buf.String(), "\n"), nil
 		}, nil
 	case "template":
 		text, err := cg.EmitStringExpr(ctx, scope, args[0])
diff --git a/mkdocs.hlb b/mkdocs.hlb
index ddc6e53..88e90b8 100644
--- a/mkdocs.hlb
+++ b/mkdocs.hlb
@@ -107,14 +107,13 @@ fs _runBuiltinGen() {
 }
 
 fs staticGoBuild(string package, fs src) {
-	go.build src package option::template {
+	go.buildWithOptions src package option::template {
 		stringField "goBuildFlags" <<~EOM
 			-ldflags "-extldflags -static"
 		EOM
 		stringField "platform" "linux"
 		stringField "arch" "amd64"
-		stringField "cgoEnabled" "0"
-	}
+	} option::run{}
 }
 
 # TODO add this to a generic util module?


Test patch:
diff --git a/codegen/codegen_test.go b/codegen/codegen_test.go
index ba24097..5e27d5a 100644
--- a/codegen/codegen_test.go
+++ b/codegen/codegen_test.go
@@ -2,7 +2,6 @@ package codegen
 
 import (
 	"context"
-	"fmt"
 	"os"
 	"strings"
 	"testing"
@@ -725,17 +724,17 @@ func TestCodeGen(t *testing.T) {
 		`,
 		func(t *testing.T, cg *CodeGen) solver.Request {
 			return Expect(t, llb.Scratch().File(
-				llb.Mkfile("just-stdout", os.FileMode(0644), []byte("stdout\n")),
+				llb.Mkfile("just-stdout", os.FileMode(0644), []byte("stdout")),
 			).File(
-				llb.Mkfile("just-stderr", os.FileMode(0644), []byte("stderr\n")),
+				llb.Mkfile("just-stderr", os.FileMode(0644), []byte("stderr")),
 			).File(
-				llb.Mkfile("stdio", os.FileMode(0644), []byte("stdout\nstderr\n")),
+				llb.Mkfile("stdio", os.FileMode(0644), []byte("stdout\nstderr")),
 			).File(
-				llb.Mkfile("goterror", os.FileMode(0644), []byte("stdout\n")),
+				llb.Mkfile("goterror", os.FileMode(0644), []byte("stdout")),
 			).File(
-				llb.Mkfile("noshlex", os.FileMode(0644), []byte(fmt.Sprintf("%s\n", os.Getenv("HOME")))),
+				llb.Mkfile("noshlex", os.FileMode(0644), []byte(os.Getenv("HOME"))),
 			).File(
-				llb.Mkfile("shlex", os.FileMode(0644), []byte("$HOME\n")),
+				llb.Mkfile("shlex", os.FileMode(0644), []byte("$HOME")),
 			))
 		},
 	}, {
Repository: openllb/hlb
Pull request #189 (2020-09-29 16:38:37)

Fix heredoc string interpolation
Source:
```hlb
fs default() {
	run <<~repro
                $k
        repro
}
```

Before:
```
❯ hlb format foo.hlb
foo.hlb:3:17: no lexer rules in state "Heredoc" matched input text "$k\n        repro..."
exit status 1
```

After:
```sh
❯ hlb format foo.hlb
fs default() {
	run <<~repro
                $k
        repro
}
```


Patch:
diff --git a/parser/cst.go b/parser/cst.go
index 92ad297..d706659 100644
--- a/parser/cst.go
+++ b/parser/cst.go
@@ -52,7 +52,7 @@ var (
 			{"HeredocEnd", `\b\1\b`, stateful.Pop()},
 			{"Whitespace", `\s+`, nil},
 			{"Interpolated", `\${`, stateful.Push("Interpolated")},
-			{"Text", `[^\s$]+`, nil},
+			{"Text", `\$|[^\s$]+`, nil},
 		},
 		"RawHeredoc": {
 			{"RawHeredocEnd", `\b\1\b`, stateful.Pop()},


Test patch:
diff --git a/unparse_test.go b/unparse_test.go
index 29e9b74..c6e893b 100644
--- a/unparse_test.go
+++ b/unparse_test.go
@@ -475,7 +475,8 @@ func TestUnparse(t *testing.T) {
 
 			fs bar() { scratch }
 			`,
-		}, {
+		},
+		{
 			`heredoc`,
 			`
 			string heredocTest() {
@@ -516,6 +517,36 @@ func TestUnparse(t *testing.T) {
 			}
 			`,
 		},
+		{
+			`string interpolation`,
+			`
+			string default() {
+				"$k"
+			}
+			`,
+			`
+			string default() {
+				"$k"
+			}
+			`,
+		},
+		{
+			`heredoc interpolation`,
+			`
+			fs default() {
+				run <<~repro
+					$k
+				repro
+			}
+			`,
+			`
+			fs default() {
+				run <<~repro
+					$k
+				repro
+			}
+			`,
+		},
 		{
 			`multi-line params`,
 			`
Repository: openllb/hlb
Pull request #209 (2020-11-18 19:58:01)

Allow pipelines to run any non-option functions
This will allow non-fs functions to be run as a pipeline (e.g. `string localRun` that has side effects).

```
pipeline default() {
    stage localRun("echo msg > foo")
    stage local("foo")
}
```

Another example, where a tarball is made locally before running a build that depends on the tarball made.
```
pipeline default() {
    stage localRun("./make-tarball.sh")
    stage buildDependingOnTarball
}
```


Patch:
diff --git a/checker/checker.go b/checker/checker.go
index 1b4e60e..4f83d3e 100644
--- a/checker/checker.go
+++ b/checker/checker.go
@@ -381,7 +381,13 @@ func (c *checker) checkCall(scope *parser.Scope, kset *parser.KindSet, ie *parse
 
 func (c *checker) checkExpr(scope *parser.Scope, kset *parser.KindSet, expr *parser.Expr) error {
 	if kset.Has(parser.Pipeline) {
-		kset = parser.NewKindSet(append(kset.Kinds(), parser.Filesystem)...)
+		kset = parser.NewKindSet(append(
+			kset.Kinds(),
+			parser.String,
+			parser.Int,
+			parser.Bool,
+			parser.Filesystem,
+		)...)
 	}
 	switch {
 	case expr.FuncLit != nil:
diff --git a/codegen/value.go b/codegen/value.go
index 87d44f3..c926a3b 100644
--- a/codegen/value.go
+++ b/codegen/value.go
@@ -118,7 +118,7 @@ func (v *nilValue) Option() (Option, error) {
 }
 
 func (v *nilValue) Request() (solver.Request, error) {
-	return nil, fmt.Errorf("cannot coerce to pipeline")
+	return solver.NilRequest(), nil
 }
 
 func (v *nilValue) Reflect(t reflect.Type) (reflect.Value, error) {


Test patch:
diff --git a/checker/checker_test.go b/checker/checker_test.go
index 75413ef..2e76784 100644
--- a/checker/checker_test.go
+++ b/checker/checker_test.go
@@ -323,14 +323,14 @@ func TestChecker_Check(t *testing.T) {
 		"basic pipeline support",
 		`
 		pipeline default() {
-			stage pipelineA fs { image "b"; }
+			stage pipelineA image("b")
 			pipelineC
 		}
 		pipeline pipelineA() {
-			stage fs { image "a"; }
+			stage image("a")
 		}
 		pipeline pipelineC() {
-			stage fs { image "c"; }
+			stage localRun("c")
 		}
 		`,
 		nil,