nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: goreleaser/nfpm
Pull request #554 (2022-09-29 14:38:43)

fix: dont modify slices in a loop

codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/nfpm/pull/554?src=pr&el=h1&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) Report
> Merging [#554](https://codecov.io/gh/goreleaser/nfpm/pull/554?src=pr&el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) (d0fc946) into [main](https://codecov.io/gh/goreleaser/nfpm/commit/62aac74fddbef3b32c7c7e18e35846be80f90535?el=desc&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) (62aac74) will **decrease** coverage by `0.01%`.
> The diff coverage is `100.00%`.

```diff
@@            Coverage Diff             @@
##             main     #554      +/-   ##
==========================================
- Coverage   69.40%   69.39%   -0.02%     
==========================================
  Files          20       20              
  Lines        2579     2578       -1     
==========================================
- Hits         1790     1789       -1     
  Misses        612      612              
  Partials      177      177              
```


| [Impacted Files](https://codecov.io/gh/goreleaser/nfpm/pull/554?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser) | Coverage Δ | |
|---|---|---|
| [nfpm.go](https://codecov.io/gh/goreleaser/nfpm/pull/554/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser#diff-bmZwbS5nbw==) | `87.87% <100.00%> (-0.07%)` | :arrow_down: |

Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=goreleaser)


Patch:
diff --git a/nfpm.go b/nfpm.go
index 9f6301d..c7dbcda 100644
--- a/nfpm.go
+++ b/nfpm.go
@@ -149,18 +149,15 @@ func (c *Config) Validate() error {
 	return nil
 }
 
-func remove(slice []string, s int) []string {
-	return append(slice[:s], slice[s+1:]...)
-}
-
 func (c *Config) expandEnvVarsStringSlice(items []string) []string {
 	for i, dep := range items {
 		val := strings.TrimSpace(os.Expand(dep, c.envMappingFunc))
 		items[i] = val
 	}
-	for i, val := range items {
-		if val == "" {
-			items = remove(items, i)
+	for i := 0; i < len(items); i++ {
+		if items[i] == "" {
+			items = append(items[:i], items[i+1:]...)
+			i-- // Since we just deleted items[i], we must redo that index
 		}
 	}
 


Test patch:
diff --git a/nfpm_test.go b/nfpm_test.go
index 437dbbe..68fce5c 100644
--- a/nfpm_test.go
+++ b/nfpm_test.go
@@ -352,6 +352,8 @@ overrides:
     depends:
     - ${PKG}
     - package (= ${VERSION})
+    - ${PKG}
+    - ${PKG}
   rpm:
     depends:
     - package = ${VERSION}
Repository: goreleaser/nfpm
Pull request #742 (2023-11-24 22:07:51)

fix(deb): blank line in package description
Blank lines in the deb's control file description are valid but need to be encoded with a space followed by a dot (`.`).

See https://www.debian.org/doc/debian-policy/ch-controlfields.html#s-f-description.
> Those containing a single space followed by a single full stop character. These are rendered as blank lines. This is the only way to get a blank line.

I used nfpm to package one of my apps and it was broken as it did not add the dots onto the blank lines. This PR fixes that.


Patch:
diff --git a/deb/deb.go b/deb/deb.go
index 92938de..b127874 100644
--- a/deb/deb.go
+++ b/deb/deb.go
@@ -3,6 +3,7 @@ package deb
 
 import (
 	"archive/tar"
+	"bufio"
 	"bytes"
 	"compress/gzip"
 	"crypto/md5" // nolint:gas
@@ -762,8 +763,20 @@ func writeControl(w io.Writer, data controlData) error {
 			return strings.Trim(strings.Join(strs, ", "), " ")
 		},
 		"multiline": func(strs string) string {
-			ret := strings.ReplaceAll(strs, "\n", "\n ")
-			return strings.Trim(ret, " \n")
+			var b strings.Builder
+			s := bufio.NewScanner(strings.NewReader(strings.TrimSpace(strs)))
+			s.Scan()
+			b.Write(bytes.TrimSpace(s.Bytes()))
+			for s.Scan() {
+				b.WriteString("\n ")
+				l := bytes.TrimSpace(s.Bytes())
+				if len(l) == 0 {
+					b.WriteByte('.')
+				} else {
+					b.Write(l)
+				}
+			}
+			return b.String()
 		},
 		"nonEmpty": func(strs []string) []string {
 			var result []string


Test patch:
diff --git a/deb/deb_test.go b/deb/deb_test.go
index 83ad3b8..68fbd58 100644
--- a/deb/deb_test.go
+++ b/deb/deb_test.go
@@ -523,7 +523,7 @@ func TestMultilineFields(t *testing.T) {
 		Info: nfpm.WithDefaults(&nfpm.Info{
 			Name:        "multiline",
 			Arch:        "riscv64",
-			Description: "This field is a\nmultiline field\nthat should work.",
+			Description: "This field is a\nmultiline field\n\nthat should work.",
 			Priority:    "extra",
 			Version:     "1.0.0",
 			Section:     "default",
diff --git a/deb/testdata/multiline.golden b/deb/testdata/multiline.golden
index 2e8dde1..24d871e 100644
--- a/deb/testdata/multiline.golden
+++ b/deb/testdata/multiline.golden
@@ -6,4 +6,5 @@ Architecture: riscv64
 Installed-Size: 0
 Description: This field is a
  multiline field
+ .
  that should work.