Skip to content

Commit 96789e3

Browse files
remove protobuf types (#51)
They are unused, so we can keep the generated output. Additionally this remove a dependency on pbtypes.Timestamp
1 parent 7024450 commit 96789e3

File tree

9 files changed

+91
-1188
lines changed

9 files changed

+91
-1188
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
sudo: false
22
language: go
33
go:
4-
- "1.12.x"
4+
- "1.14.x"
55
script:
66
- GO111MODULE=on go get -t -v ./...
77
- diff -u <(echo -n) <(gofmt -d -s .)

diff/diff.go

+57-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,64 @@
11
package diff
22

3-
import "bytes"
3+
import (
4+
"bytes"
5+
"time"
6+
)
47

5-
// NOTE: types are code-generated in diff.pb.go.
8+
// A FileDiff represents a unified diff for a single file.
9+
//
10+
// A file unified diff has a header that resembles the following:
11+
//
12+
// --- oldname 2009-10-11 15:12:20.000000000 -0700
13+
// +++ newname 2009-10-11 15:12:30.000000000 -0700
14+
type FileDiff struct {
15+
// the original name of the file
16+
OrigName string
17+
// the original timestamp (nil if not present)
18+
OrigTime *time.Time
19+
// the new name of the file (often same as OrigName)
20+
NewName string
21+
// the new timestamp (nil if not present)
22+
NewTime *time.Time
23+
// extended header lines (e.g., git's "new mode <mode>", "rename from <path>", etc.)
24+
Extended []string
25+
// hunks that were changed from orig to new
26+
Hunks []*Hunk
27+
}
628

7-
//go:generate protoc -I../../../.. -I ../../../../github.com/gogo/protobuf/protobuf -I. --gogo_out=. diff.proto
29+
// A Hunk represents a series of changes (additions or deletions) in a file's
30+
// unified diff.
31+
type Hunk struct {
32+
// starting line number in original file
33+
OrigStartLine int32
34+
// number of lines the hunk applies to in the original file
35+
OrigLines int32
36+
// if > 0, then the original file had a 'No newline at end of file' mark at this offset
37+
OrigNoNewlineAt int32
38+
// starting line number in new file
39+
NewStartLine int32
40+
// number of lines the hunk applies to in the new file
41+
NewLines int32
42+
// optional section heading
43+
Section string
44+
// 0-indexed line offset in unified file diff (including section headers); this is
45+
// only set when Hunks are read from entire file diff (i.e., when ReadAllHunks is
46+
// called) This accounts for hunk headers, too, so the StartPosition of the first
47+
// hunk will be 1.
48+
StartPosition int32
49+
// hunk body (lines prefixed with '-', '+', or ' ')
50+
Body []byte
51+
}
52+
53+
// A Stat is a diff stat that represents the number of lines added/changed/deleted.
54+
type Stat struct {
55+
// number of lines added
56+
Added int32
57+
// number of lines changed
58+
Changed int32
59+
// number of lines deleted
60+
Deleted int32
61+
}
862

963
// Stat computes the number of lines added/changed/deleted in all
1064
// hunks in this file's diff.

0 commit comments

Comments
 (0)