From 4f31911e275c5d6b838923f5a7a8575bdad40ce9 Mon Sep 17 00:00:00 2001 From: Marko Mikulicic Date: Thu, 28 Nov 2019 18:33:35 +0100 Subject: [PATCH 1/2] Go really wants to update go.mod --- go.mod | 2 ++ 1 file changed, 2 insertions(+) diff --git a/go.mod b/go.mod index b7d9a48..7e956c3 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,5 @@ module github.com/rogpeppe/apipe require 9fans.net/go v0.0.0-20180727211846-5d4fa602e1e8 + +go 1.13 From 3903f9760144e420776c18a72f38ce543d41b983 Mon Sep 17 00:00:00 2001 From: Marko Mikulicic Date: Thu, 28 Nov 2019 18:46:41 +0100 Subject: [PATCH 2/2] Support files that don't end with newline WHen `diff` compares files where one lacks a trailing newline, it emits: ``` \ No newline at end of file ``` apipe emitted an error because it expected a `---` prefix --- apply.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/apply.go b/apply.go index d5ada7a..ff5605a 100644 --- a/apply.go +++ b/apply.go @@ -208,7 +208,11 @@ func eatLines(scan *bufio.Scanner, prefix string, n int) error { if !scan.Scan() { return io.ErrUnexpectedEOF } - if !bytes.HasPrefix(scan.Bytes(), bprefix) { + // diff can inject comments in lines beginning with a backslash, like when + // highlighting that the original line had no trailing newline + if bytes.HasPrefix(scan.Bytes(), []byte("\\ ")) { + i-- + } else if !bytes.HasPrefix(scan.Bytes(), bprefix) { return fmt.Errorf("line %q does not have expected prefix %q", scan.Bytes(), bprefix) } }