Skip to content

removed pbtypes.Timestamp #51

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Sep 4, 2020
Merged
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
sudo: false
language: go
go:
- "1.12.x"
- "1.14.x"
script:
- GO111MODULE=on go get -t -v ./...
- diff -u <(echo -n) <(gofmt -d -s .)
Expand Down
60 changes: 57 additions & 3 deletions diff/diff.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,64 @@
package diff

import "bytes"
import (
"bytes"
"time"
)

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

//go:generate protoc -I../../../.. -I ../../../../github.com/gogo/protobuf/protobuf -I. --gogo_out=. diff.proto
// A Hunk represents a series of changes (additions or deletions) in a file's
// unified diff.
type Hunk struct {
// starting line number in original file
OrigStartLine int32
// number of lines the hunk applies to in the original file
OrigLines int32
// if > 0, then the original file had a 'No newline at end of file' mark at this offset
OrigNoNewlineAt int32
// starting line number in new file
NewStartLine int32
// number of lines the hunk applies to in the new file
NewLines int32
// optional section heading
Section string
// 0-indexed line offset in unified file diff (including section headers); this is
// only set when Hunks are read from entire file diff (i.e., when ReadAllHunks is
// called) This accounts for hunk headers, too, so the StartPosition of the first
// hunk will be 1.
StartPosition int32
// hunk body (lines prefixed with '-', '+', or ' ')
Body []byte
}

// A Stat is a diff stat that represents the number of lines added/changed/deleted.
type Stat struct {
// number of lines added
Added int32
// number of lines changed
Changed int32
// number of lines deleted
Deleted int32
}

// Stat computes the number of lines added/changed/deleted in all
// hunks in this file's diff.
Expand Down
Loading