Run of fresh-snapshots for golang-github-neelance-sourcemap

Try this locally (using silver-platter):

debian-svp new-upstream --snapshot golang-github-neelance-sourcemap 

Merge these changes:

git pull https://janitor.debian.net/git/golang-github-neelance-sourcemap fresh-snapshots/main

Summary

Merged new upstream version: 0.0~git20200213.0.2833bce (was: 0.0~git20151028.0.8c68805).

Diff

=== modified file 'debian/changelog'
--- a/debian/changelog	2020-04-06 18:03:15 +0000
+++ b/debian/changelog	2020-04-21 20:08:20 +0000
@@ -1,3 +1,9 @@
+golang-github-neelance-sourcemap (0.0~git20200213.0.2833bce-1) UNRELEASED; urgency=medium
+
+  * New upstream snapshot.
+
+ -- Debian Janitor <janitor@jelmer.uk>  Tue, 21 Apr 2020 20:07:55 +0000
+
 golang-github-neelance-sourcemap (0.0~git20151028.0.8c68805-5) unstable; urgency=medium
 
   * new maintainer/uploader (Closes: #889220)

=== modified file 'sourcemap.go'
--- a/sourcemap.go	2017-03-28 16:00:34 +0000
+++ b/sourcemap.go	2020-04-21 20:08:20 +0000
@@ -12,8 +12,8 @@
 	Version         int      `json:"version"`
 	File            string   `json:"file,omitempty"`
 	SourceRoot      string   `json:"sourceRoot,omitempty"`
-	Sources         []string `json:"sources,omitempty"`
-	Names           []string `json:"names,omitempty"`
+	Sources         []string `json:"sources"`
+	Names           []string `json:"names"`
 	Mappings        string   `json:"mappings"`
 	decodedMappings []*Mapping
 }
@@ -223,6 +223,12 @@
 	if m.decodedMappings != nil {
 		m.EncodeMappings()
 	}
+	if m.Names == nil {
+		m.Names = make([]string, 0)
+	}
+	if m.Sources == nil {
+		m.Sources = make([]string, 0)
+	}
 	enc := json.NewEncoder(w)
 	return enc.Encode(m)
 }

=== modified file 'sourcemap_test.go'
--- a/sourcemap_test.go	2017-03-28 16:00:34 +0000
+++ b/sourcemap_test.go	2020-04-21 20:08:20 +0000
@@ -7,6 +7,8 @@
 )
 
 const testFile = `{"version":3,"file":"min.js","sourceRoot":"/the/root","sources":["one.js","two.js"],"names":["bar","baz","n"],"mappings":"CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA"}` + "\n"
+const testFileWithoutNames = `{"version":3,"file":"min.js","sourceRoot":"/the/root","sources":["one.js","two.js"],"mappings":"CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA"}` + "\n"
+const testFileWithoutSources = `{"version":3,"file":"min.js","sourceRoot":"/the/root","names":["bar","baz","n"],"mappings":"CAAC,IAAI,IAAM,SAAUA,GAClB,OAAOC,IAAID;CCDb,IAAI,IAAM,SAAUE,GAClB,OAAOA"}`
 
 func TestReadFrom(t *testing.T) {
 	m, err := ReadFrom(strings.NewReader(testFile))
@@ -58,3 +60,38 @@
 		t.Error(b.String())
 	}
 }
+
+func TestWriteToShouldIncludeEmptyNames(t *testing.T) {
+	m, err := ReadFrom(strings.NewReader(testFileWithoutNames))
+	if err != nil {
+		t.Fatal(err)
+	}
+	if m.Names != nil {
+		t.Error("Names expected to be nil")
+	}
+	b := bytes.NewBuffer(nil)
+	if err := m.WriteTo(b); err != nil {
+		t.Fatal(err)
+	}
+	if !strings.Contains(b.String(), `"names":[]`) {
+		t.Error(`Source map expected to include '"names":[]'`, "\n", b.String())
+	}
+}
+
+func TestWriteToShouldIncludeEmptySources(t *testing.T) {
+
+	m, err := ReadFrom(strings.NewReader(testFileWithoutSources))
+	if err != nil {
+		t.Fatal(err)
+	}
+	if m.Sources != nil {
+		t.Error("Sources expected to be nil")
+	}
+	b := bytes.NewBuffer(nil)
+	if err := m.WriteTo(b); err != nil {
+		t.Fatal(err)
+	}
+	if !strings.Contains(b.String(), `"sources":[]`) {
+		t.Error(`Source map expected to include '"sources":[]'`, "\n", b.String())
+	}
+}

Full build log Full worker log