Skip to content

Commit 66cb877

Browse files
committed
use int32 (for protobuf support)
1 parent 07b377a commit 66cb877

File tree

3 files changed

+21
-21
lines changed

3 files changed

+21
-21
lines changed

diff/diff.pb.go

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

diff/diff.proto

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,19 +35,19 @@ message FileDiff {
3535
// unified diff.
3636
message Hunk {
3737
// starting line number in original file
38-
int32 orig_start_line = 1 [(gogoproto.customtype) = "int"];
38+
int32 orig_start_line = 1;
3939

4040
// number of lines the hunk applies to in the original file
41-
int32 orig_lines = 2 [(gogoproto.customtype) = "int"];
41+
int32 orig_lines = 2;
4242

4343
// if > 0, then the original file had a 'No newline at end of file' mark at this offset
44-
int32 orig_no_newline_at = 3 [(gogoproto.customtype) = "int"];
44+
int32 orig_no_newline_at = 3;
4545

4646
// starting line number in new file
47-
int32 new_start_line = 4 [(gogoproto.customtype) = "int"];
47+
int32 new_start_line = 4;
4848

4949
// number of lines the hunk applies to in the new file
50-
int32 new_lines = 5 [(gogoproto.customtype) = "int"];
50+
int32 new_lines = 5;
5151

5252
// optional section heading
5353
string section = 6;
@@ -56,7 +56,7 @@ message Hunk {
5656
// only set when Hunks are read from entire file diff (i.e., when ReadAllHunks is
5757
// called) This accounts for hunk headers, too, so the StartPosition of the first
5858
// hunk will be 1.
59-
int32 start_position = 7 [(gogoproto.customtype) = "int"];
59+
int32 start_position = 7;
6060

6161
// hunk body (lines prefixed with '-', '+', or ' ')
6262
bytes body = 8;
@@ -65,12 +65,12 @@ message Hunk {
6565
// A Stat is a diff stat that represents the number of lines added/changed/deleted.
6666
message Stat {
6767
// number of lines added
68-
int32 added = 1 [(gogoproto.customtype) = "int"];
68+
int32 added = 1;
6969

7070
// number of lines changed
71-
int32 changed = 2 [(gogoproto.customtype) = "int"];
71+
int32 changed = 2;
7272

7373
// number of lines deleted
74-
int32 deleted = 3 [(gogoproto.customtype) = "int"];
74+
int32 deleted = 3;
7575
}
7676

diff/parse.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ func (r *HunksReader) ReadHunk() (*Hunk, error) {
418418
// the the next line of the new file, which is not
419419
// validly formatted) but record that the orig had
420420
// no newline.
421-
r.hunk.OrigNoNewlineAt = len(r.hunk.Body)
421+
r.hunk.OrigNoNewlineAt = int32(len(r.hunk.Body))
422422
} else {
423423
// Remove previous line's newline.
424424
if len(r.hunk.Body) != 0 {
@@ -503,7 +503,7 @@ func normalizeHeader(header string) (string, string, error) {
503503
// reported.
504504
func (r *HunksReader) ReadAllHunks() ([]*Hunk, error) {
505505
var hunks []*Hunk
506-
linesRead := 0
506+
linesRead := int32(0)
507507
for {
508508
hunk, err := r.ReadHunk()
509509
if err == io.EOF {
@@ -513,7 +513,7 @@ func (r *HunksReader) ReadAllHunks() ([]*Hunk, error) {
513513
linesRead++ // account for the hunk header line
514514
hunk.StartPosition = linesRead
515515
hunks = append(hunks, hunk)
516-
linesRead += bytes.Count(hunk.Body, []byte{'\n'})
516+
linesRead += int32(bytes.Count(hunk.Body, []byte{'\n'}))
517517
}
518518
if err != nil {
519519
return hunks, err

0 commit comments

Comments
 (0)