mirror of
https://github.com/aptly-dev/aptly.git
synced 2026-07-16 12:08:04 +00:00
Merge pull request #1588 from aptly-dev/fix/source-package-list
fix empty line in Source PackageList
This commit is contained in:
+5
-2
@@ -291,8 +291,11 @@ func (c *ControlFileReader) ReadStanza() (Stanza, error) {
|
|||||||
lastField = canonicalCase(parts[0])
|
lastField = canonicalCase(parts[0])
|
||||||
lastFieldMultiline = isMultilineField(lastField, c.isRelease)
|
lastFieldMultiline = isMultilineField(lastField, c.isRelease)
|
||||||
if lastFieldMultiline {
|
if lastFieldMultiline {
|
||||||
stanza[lastField] = parts[1]
|
// Trim trailing whitespace from the inline value so that
|
||||||
if parts[1] != "" {
|
// "Package-List: " does not add empty line
|
||||||
|
inlineVal := strings.TrimRight(parts[1], " \t")
|
||||||
|
stanza[lastField] = inlineVal
|
||||||
|
if inlineVal != "" {
|
||||||
stanza[lastField] += "\n"
|
stanza[lastField] += "\n"
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -128,6 +128,35 @@ func (s *ControlFileSuite) TestReadWriteStanza(c *C) {
|
|||||||
c.Assert(strings.HasPrefix(str, "Package: "), Equals, true)
|
c.Assert(strings.HasPrefix(str, "Package: "), Equals, true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Sources may contain "Package-List: " with a trailing space.
|
||||||
|
// That trailing space must not be preserved and re-emitted
|
||||||
|
// as a spurious blank continuation line when the stanza is written back out.
|
||||||
|
func (s *ControlFileSuite) TestPackageListTrailingSpace(c *C) {
|
||||||
|
input := "Package-List: \n" +
|
||||||
|
" bash deb shells required arch=any\n" +
|
||||||
|
" bash-doc deb doc optional arch=all\n"
|
||||||
|
|
||||||
|
r := NewControlFileReader(bytes.NewBufferString(input), false, false)
|
||||||
|
stanza, err := r.ReadStanza()
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
|
||||||
|
c.Check(stanza["Package-List"], Equals,
|
||||||
|
" bash deb shells required arch=any\n"+
|
||||||
|
" bash-doc deb doc optional arch=all\n")
|
||||||
|
|
||||||
|
buf := &bytes.Buffer{}
|
||||||
|
w := bufio.NewWriter(buf)
|
||||||
|
err = stanza.Copy().WriteTo(w, true, false, false)
|
||||||
|
c.Assert(err, IsNil)
|
||||||
|
c.Assert(w.Flush(), IsNil)
|
||||||
|
|
||||||
|
written := buf.String()
|
||||||
|
c.Assert(strings.Contains(written, "Package-List:\n \n"), Equals, false,
|
||||||
|
Commentf("spurious blank continuation line found in written output:\n%s", written))
|
||||||
|
c.Assert(strings.Contains(written, "Package-List:\n bash"), Equals, true,
|
||||||
|
Commentf("expected Package-List entries not found in written output:\n%s", written))
|
||||||
|
}
|
||||||
|
|
||||||
func (s *ControlFileSuite) TestReadWriteInstallerStanza(c *C) {
|
func (s *ControlFileSuite) TestReadWriteInstallerStanza(c *C) {
|
||||||
s.reader = bytes.NewBufferString(installerFile)
|
s.reader = bytes.NewBufferString(installerFile)
|
||||||
r := NewControlFileReader(s.reader, false, true)
|
r := NewControlFileReader(s.reader, false, true)
|
||||||
|
|||||||
Reference in New Issue
Block a user