dmitri.shuralyov.com/service/change/fs

Add third commit, merge change in mock data.
dmitshur committed 6 years ago commit 93ac3b3359e4139f30719afe7ad13d35cafbf78a
Showing partial commit. Full Commit
Collapse all
fs/fs.go
@@ -27,18 +27,18 @@ var s = struct {
		Diffs    map[string][]byte
	}{
		{
			Change: change.Change{
				ID:        1,
				State:     change.OpenState,
				State:     change.MergedState,
				Title:     "Initial implementation of woff2.",
				Labels:    nil,
				Author:    shurcool,
				CreatedAt: time.Date(2018, 2, 12, 0, 9, 19, 621031866, time.UTC),
				Replies:   0,
				Replies:   1,

				Commits: 2,
				Commits: 3,
			},
			Timeline: []interface{}{
				change.Comment{
					User:      shurcool,
					CreatedAt: time.Date(2018, 2, 12, 0, 9, 19, 621031866, time.UTC),
@@ -64,10 +64,27 @@ Add basic test coverage.

Helps https://github.com/ConradIrwin/font/issues/1.

For convenience, a ` + "`" + `godoc` + "`" + ` view of this change can be seen [here](https://redpen.io/rk9a75c358f45654a8).`,
				},
				change.Review{
					ID:        1,
					User:      shurcool,
					CreatedAt: time.Date(2018, 2, 20, 21, 49, 35, 536092503, time.UTC),
					State:     change.Approved,
					Body:      "There have been some out-of-band review comments that I've addressed. This will do for the initial version.\n\nLGTM.",
				},
				change.TimelineItem{
					ID:        2,
					Actor:     shurcool,
					CreatedAt: time.Date(2018, 2, 20, 21, 57, 47, 537746502, time.UTC),
					Payload: change.MergedEvent{
						CommitID:      "957792cbbdabb084d484a7dcfd1e5b1a739a0ced",
						CommitHTMLURL: "https://dmitri.shuralyov.com/font/woff2/...$commit/957792cbbdabb084d484a7dcfd1e5b1a739a0ced",
						RefName:       "master",
					},
				},
			},
			Commits: []change.Commit{{
				SHA: "d2568fb6f10921b2d0c84d58bad14b2fadb88aa7",
				Message: `Add initial parser implementation.

@@ -98,15 +115,24 @@ Helps https://github.com/ConradIrwin/font/issues/1.`,

The API had changed earlier, the test wasn't updated for it. This
change fixes that, allowing tests to pass.`,
				Author:     shurcool,
				AuthorTime: time.Date(2018, 2, 12, 20, 22, 29, 674711268, time.UTC),
			}, {
				SHA: "3b528c98b05508322be465a207f5ffd8258b8a96",
				Message: `Add comment describing null-padding check.

Also add a TODO comment to improve this check. It's not compliant with
spec as is. Addressing this will be a part of future changes.`,
				Author:     shurcool,
				AuthorTime: time.Date(2018, 2, 20, 21, 39, 17, 660912242, time.UTC),
			}},
			Diffs: map[string][]byte{
				"all": []byte(diffAll),
				"d2568fb6f10921b2d0c84d58bad14b2fadb88aa7": []byte(diffCommit1),
				"61339d441b319cd6ca35d952522f86cc42ad4b6e": []byte(diffCommit2),
				"3b528c98b05508322be465a207f5ffd8258b8a96": []byte(diffCommit3),
			},
		},
	},
}

@@ -324,10 +350,13 @@ index 0000000..498a4a8
+	pd, err := parsePrivateData(r, hdr)
+	if err != nil {
+		return File{}, err
+	}
+
+	// Check for padding with a maximum of three null bytes.
+	// TODO: This check needs to be moved to Extended Metadata and Private Data blocks,
+	//       and made more precise (i.e., the beginning of those blocks must be 4-byte aligned, etc.).
+	n, err := io.Copy(discardZeroes{}, r)
+	if err != nil {
+		return File{}, fmt.Errorf("Parse: %v", err)
+	}
+	if n > 3 {
@@ -1609,5 +1638,21 @@ index 87545cf..14e2830 100644
+	fmt.Println("CompressedFontData:", len(f.FontData), "bytes (uncompressed size)")
 	fmt.Println("ExtendedMetadata:", f.ExtendedMetadata)
 	fmt.Println("PrivateData:", f.PrivateData)
 }
`

const diffCommit3 = `diff --git a/parse.go b/parse.go
index 498a4a8..0004d27 100644
--- a/parse.go
+++ b/parse.go
@@ -55,6 +55,9 @@ func Parse(r io.Reader) (File, error) {
 		return File{}, err
 	}

+	// Check for padding with a maximum of three null bytes.
+	// TODO: This check needs to be moved to Extended Metadata and Private Data blocks,
+	//       and made more precise (i.e., the beginning of those blocks must be 4-byte aligned, etc.).
 	n, err := io.Copy(discardZeroes{}, r)
 	if err != nil {
 		return File{}, fmt.Errorf("Parse: %v", err)
`