initial work - diff stats, (files changed)

jobatzil/rename
Enver Bisevac 2023-02-13 13:07:37 +01:00
parent a85df2b43a
commit 7546f2cd6b
21 changed files with 1433 additions and 235 deletions

1
.gitignore vendored
View File

@ -9,6 +9,7 @@ web/node_modules
web/dist/files
release
.idea
.vscode/settings.json
coverage.out
gitness.session.sql

12
.vscode/settings.json vendored
View File

@ -1,12 +0,0 @@
{
"go.testTags": "sqlite_fts5",
"sqltools.useNodeRuntime": true,
"sqltools.connections": [
{
"previewLimit": 50,
"driver": "SQLite",
"name": "gitness",
"database": "${workspaceFolder:gitness}/cmd/gitness/database.sqlite3"
}
]
}

View File

@ -5,8 +5,6 @@
package gitrpc
import (
"errors"
"github.com/harness/gitness/gitrpc/rpc"
)
@ -17,7 +15,7 @@ type ReadParams struct {
func (p ReadParams) Validate() error {
if p.RepoUID == "" {
return errors.New("repository id cannot be empty")
return ErrInvalidArgumentf("repository id cannot be empty")
}
return nil
}

View File

@ -9,6 +9,7 @@ import (
"errors"
"fmt"
"io"
"path"
"github.com/harness/gitness/gitrpc/internal/streamio"
"github.com/harness/gitness/gitrpc/internal/types"
@ -22,6 +23,7 @@ type DiffParams struct {
BaseRef string
HeadRef string
MergeBase bool
IncludePatch bool
}
func (p DiffParams) Validate() error {
@ -30,7 +32,7 @@ func (p DiffParams) Validate() error {
}
if p.HeadRef == "" {
return errors.New("head ref cannot be empty")
return ErrInvalidArgumentf("head ref cannot be empty")
}
return nil
}
@ -274,3 +276,73 @@ func (c *Client) DiffCut(ctx context.Context, params *DiffCutParams) (DiffCutOut
LatestSourceSHA: result.LatestSourceSha,
}, nil
}
type FileDiff struct {
SHA string `json:"sha"`
OldSHA string `json:"old_sha,omitempty"`
Path string `json:"path"`
OldPath string `json:"old_path,omitempty"`
Status string `json:"status"`
Additions int64 `json:"additions"`
Deletions int64 `json:"deletions"`
Changes int64 `json:"changes"`
ContentURL string `json:"content_url"`
Patch []byte `json:"patch,omitempty"`
IsBinary bool `json:"is_binary"`
IsSubmodule bool `json:"is_submodule"`
}
func (c *Client) Diff(ctx context.Context, params *DiffParams, baseURL string) (<-chan *FileDiff, <-chan error) {
ch := make(chan *FileDiff)
// needs to be buffered so it is not blocking on receiver side when all data is sent
cherr := make(chan error, 1)
go func() {
defer close(ch)
defer close(cherr)
if err := params.Validate(); err != nil {
cherr <- err
return
}
stream, err := c.diffService.Diff(ctx, &rpc.DiffRequest{
Base: mapToRPCReadRequest(params.ReadParams),
BaseRef: params.BaseRef,
HeadRef: params.HeadRef,
MergeBase: params.MergeBase,
IncludePatch: params.IncludePatch,
})
if err != nil {
return
}
for {
resp, err := stream.Recv()
if err != nil {
if errors.Is(err, io.EOF) {
break
}
cherr <- processRPCErrorf(err, "failed to get git diff file from stream")
return
}
ch <- &FileDiff{
SHA: resp.Sha,
OldSHA: resp.OldSha,
Path: resp.Path,
OldPath: resp.OldPath,
Status: resp.Status.String(),
Additions: int64(resp.Additions),
Deletions: int64(resp.Deletions),
Changes: int64(resp.Changes),
ContentURL: path.Join(baseURL, resp.Path),
Patch: resp.Patch,
IsBinary: resp.IsBinary,
IsSubmodule: resp.IsSubmodule,
}
}
}()
return ch, cherr
}

496
gitrpc/diff/diff.go Normal file
View File

@ -0,0 +1,496 @@
// Copyright 2022 Harness Inc. All rights reserved.
// Use of this source code is governed by the Polyform Free Trial License
// that can be found in the LICENSE.md file for this repository.
package diff
import (
"bufio"
"bytes"
"errors"
"fmt"
"io"
"strconv"
"strings"
"github.com/harness/gitness/gitrpc/enum"
)
// Predefine []byte variables to avoid runtime allocations.
var (
escapedSlash = []byte(`\\`)
regularSlash = []byte(`\`)
escapedTab = []byte(`\t`)
regularTab = []byte("\t")
)
// LineType is the line type in diff.
type LineType uint8
// A list of different line types.
const (
DiffLinePlain LineType = iota + 1
DiffLineAdd
DiffLineDelete
DiffLineSection
)
// FileType is the file status in diff.
type FileType uint8
// A list of different file statuses.
const (
FileAdd FileType = iota
FileChange
FileDelete
FileRename
)
// Line represents a line in diff.
type Line struct {
Type LineType // The type of the line
Content string // The content of the line
LeftLine int // The left line number
RightLine int // The right line number
}
// Section represents a section in diff.
type Section struct {
Lines []*Line // lines in the section
numAdditions int
numDeletions int
}
// NumLines returns the number of lines in the section.
func (s *Section) NumLines() int {
return len(s.Lines)
}
// Line returns a specific line by given type and line number in a section.
func (s *Section) Line(lineType LineType, line int) *Line {
var (
difference = 0
addCount = 0
delCount = 0
matchedDiffLine *Line
)
loop:
for _, diffLine := range s.Lines {
switch diffLine.Type {
case DiffLineAdd:
addCount++
case DiffLineDelete:
delCount++
default:
if matchedDiffLine != nil {
break loop
}
difference = diffLine.RightLine - diffLine.LeftLine
addCount = 0
delCount = 0
}
switch lineType {
case DiffLineDelete:
if diffLine.RightLine == 0 && diffLine.LeftLine == line-difference {
matchedDiffLine = diffLine
}
case DiffLineAdd:
if diffLine.LeftLine == 0 && diffLine.RightLine == line+difference {
matchedDiffLine = diffLine
}
}
}
if addCount == delCount {
return matchedDiffLine
}
return nil
}
// File represents a file in diff.
type File struct {
// The name and path of the file.
Path string
// The old name and path of the file.
OldPath string
// The type of the file.
Type FileType
// The index (SHA1 hash) of the file. For a changed/new file, it is the new SHA,
// and for a deleted file it becomes "000000".
SHA string
// OldSHA is the old index (SHA1 hash) of the file.
OldSHA string
// The sections in the file.
Sections []*Section
numAdditions int
numDeletions int
mode enum.EntryMode
oldMode enum.EntryMode
IsBinary bool
IsSubmodule bool
}
func (f *File) Status() string {
switch {
case f.Type == FileAdd:
return "added"
case f.Type == FileDelete:
return "deleted"
case f.Type == FileRename:
return "renamed"
case f.Type == FileChange:
return "changed"
default:
return "unchanged"
}
}
// NumSections returns the number of sections in the file.
func (f *File) NumSections() int {
return len(f.Sections)
}
// NumAdditions returns the number of additions in the file.
func (f *File) NumAdditions() int {
return f.numAdditions
}
// NumChanges returns the number of additions and deletions in the file.
func (f *File) NumChanges() int {
return f.numAdditions + f.numDeletions
}
// NumDeletions returns the number of deletions in the file.
func (f *File) NumDeletions() int {
return f.numDeletions
}
// Mode returns the mode of the file.
func (f *File) Mode() enum.EntryMode {
return f.mode
}
// OldMode returns the old mode of the file if it's changed.
func (f *File) OldMode() enum.EntryMode {
return f.oldMode
}
func (f *File) IsEmpty() bool {
return f.Path == "" && f.OldPath == ""
}
type Parser struct {
*bufio.Reader
// The next line that hasn't been processed. It is used to determine what kind
// of process should go in.
buffer []byte
isEOF bool
}
func (p *Parser) readLine() error {
if p.buffer != nil {
return nil
}
var err error
p.buffer, err = p.ReadBytes('\n')
if err != nil {
if err != io.EOF {
return fmt.Errorf("read string: %v", err)
}
p.isEOF = true
}
// Remove line break
if len(p.buffer) > 0 && p.buffer[len(p.buffer)-1] == '\n' {
p.buffer = p.buffer[:len(p.buffer)-1]
}
return nil
}
var diffHead = []byte("diff --git ")
func (p *Parser) parseFileHeader() (*File, error) {
submoduleMode := " 160000"
line := string(p.buffer)
p.buffer = nil
// NOTE: In case file name is surrounded by double quotes (it happens only in
// git-shell). e.g. diff --git "a/xxx" "b/xxx"
hasQuote := line[len(diffHead)] == '"'
middle := strings.Index(line, ` b/`)
if hasQuote {
middle = strings.Index(line, ` "b/`)
}
beg := len(diffHead)
a := line[beg+2 : middle]
b := line[middle+3:]
if hasQuote {
a = string(UnescapeChars([]byte(a[1 : len(a)-1])))
b = string(UnescapeChars([]byte(b[1 : len(b)-1])))
}
file := &File{
Path: a,
OldPath: b,
Type: FileChange,
}
// Check file diff type and submodule
var err error
checkType:
for !p.isEOF {
if err = p.readLine(); err != nil {
return nil, err
}
line := string(p.buffer)
p.buffer = nil
if len(line) == 0 {
continue
}
switch {
case strings.HasPrefix(line, enum.DiffExtHeaderNewFileMode):
file.Type = FileAdd
file.IsSubmodule = strings.HasSuffix(line, submoduleMode)
fields := strings.Fields(line)
if len(fields) > 0 {
mode, _ := strconv.ParseUint(fields[len(fields)-1], 8, 64)
file.mode = enum.EntryMode(mode)
if file.oldMode == 0 {
file.oldMode = file.mode
}
}
case strings.HasPrefix(line, enum.DiffExtHeaderDeletedFileMode):
file.Type = FileDelete
file.IsSubmodule = strings.HasSuffix(line, submoduleMode)
fields := strings.Fields(line)
if len(fields) > 0 {
mode, _ := strconv.ParseUint(fields[len(fields)-1], 8, 64)
file.mode = enum.EntryMode(mode)
if file.oldMode == 0 {
file.oldMode = file.mode
}
}
case strings.HasPrefix(line, enum.DiffExtHeaderIndex): // e.g. index ee791be..9997571 100644
fields := strings.Fields(line[6:])
shas := strings.Split(fields[0], "..")
if len(shas) != 2 {
return nil, errors.New("malformed index: expect two SHAs in the form of <old>..<new>")
}
file.OldSHA = shas[0]
file.SHA = shas[1]
if len(fields) > 1 {
mode, _ := strconv.ParseUint(fields[1], 8, 64)
file.mode = enum.EntryMode(mode)
file.oldMode = enum.EntryMode(mode)
}
break checkType
case strings.HasPrefix(line, enum.DiffExtHeaderSimilarity):
file.Type = FileRename
file.OldPath = a
file.Path = b
// No need to look for index if it's a pure rename
if strings.HasSuffix(line, "100%") {
break checkType
}
case strings.HasPrefix(line, enum.DiffExtHeaderNewMode):
fields := strings.Fields(line)
if len(fields) > 0 {
mode, _ := strconv.ParseUint(fields[len(fields)-1], 8, 64)
file.mode = enum.EntryMode(mode)
}
case strings.HasPrefix(line, enum.DiffExtHeaderOldMode):
fields := strings.Fields(line)
if len(fields) > 0 {
mode, _ := strconv.ParseUint(fields[len(fields)-1], 8, 64)
file.oldMode = enum.EntryMode(mode)
}
}
}
return file, nil
}
func (p *Parser) parseSection() (*Section, error) {
line := string(p.buffer)
p.buffer = nil
section := &Section{
Lines: []*Line{
{
Type: DiffLineSection,
Content: line,
},
},
}
// Parse line number, e.g. @@ -0,0 +1,3 @@
var leftLine, rightLine int
ss := strings.Split(line, "@@")
ranges := strings.Split(ss[1][1:], " ")
leftLine, _ = strconv.Atoi(strings.Split(ranges[0], ",")[0][1:])
if len(ranges) > 1 {
rightLine, _ = strconv.Atoi(strings.Split(ranges[1], ",")[0])
} else {
rightLine = leftLine
}
var err error
for !p.isEOF {
if err = p.readLine(); err != nil {
return nil, err
}
if len(p.buffer) == 0 {
p.buffer = nil
continue
}
// Make sure we're still in the section. If not, we're done with this section.
if p.buffer[0] != ' ' &&
p.buffer[0] != '+' &&
p.buffer[0] != '-' {
// No new line indicator
if p.buffer[0] == '\\' &&
bytes.HasPrefix(p.buffer, []byte(`\ No newline at end of file`)) {
p.buffer = nil
continue
}
return section, nil
}
line := string(p.buffer)
p.buffer = nil
switch line[0] {
case ' ':
section.Lines = append(section.Lines, &Line{
Type: DiffLinePlain,
Content: line,
LeftLine: leftLine,
RightLine: rightLine,
})
leftLine++
rightLine++
case '+':
section.Lines = append(section.Lines, &Line{
Type: DiffLineAdd,
Content: line,
RightLine: rightLine,
})
section.numAdditions++
rightLine++
case '-':
section.Lines = append(section.Lines, &Line{
Type: DiffLineDelete,
Content: line,
LeftLine: leftLine,
})
section.numDeletions++
if leftLine > 0 {
leftLine++
}
}
}
return section, nil
}
func (p *Parser) Parse(f func(f *File)) error {
file := new(File)
currentFileLines := 0
additions := 0
deletions := 0
var (
err error
)
for !p.isEOF {
if err = p.readLine(); err != nil {
return err
}
if len(p.buffer) == 0 ||
bytes.HasPrefix(p.buffer, []byte("+++ ")) ||
bytes.HasPrefix(p.buffer, []byte("--- ")) {
p.buffer = nil
continue
}
// Found new file
if bytes.HasPrefix(p.buffer, diffHead) {
// stream previous file
if !file.IsEmpty() && f != nil {
f(file)
}
file, err = p.parseFileHeader()
if err != nil {
return err
}
currentFileLines = 0
continue
}
if file == nil {
p.buffer = nil
continue
}
if bytes.HasPrefix(p.buffer, []byte("Binary")) {
p.buffer = nil
file.IsBinary = true
continue
}
// Loop until we found section header
if p.buffer[0] != '@' {
p.buffer = nil
continue
}
section, err := p.parseSection()
if err != nil {
return err
}
file.Sections = append(file.Sections, section)
file.numAdditions += section.numAdditions
file.numDeletions += section.numDeletions
additions += section.numAdditions
deletions += section.numDeletions
currentFileLines += section.NumLines()
}
// stream last file
if !file.IsEmpty() && f != nil {
f(file)
}
return nil
}
// UnescapeChars reverses escaped characters.
func UnescapeChars(in []byte) []byte {
if bytes.ContainsAny(in, "\\\t") {
return in
}
out := bytes.Replace(in, escapedSlash, regularSlash, -1)
out = bytes.Replace(out, escapedTab, regularTab, -1)
return out
}

14
gitrpc/enum/entry.go Normal file
View File

@ -0,0 +1,14 @@
package enum
// EntryMode is the unix file mode of a tree entry.
type EntryMode int
// There are only a few file modes in Git. They look like unix file modes, but
// they can only be one of these.
const (
EntryTree EntryMode = 0040000
EntryBlob EntryMode = 0100644
EntryExec EntryMode = 0100755
EntrySymlink EntryMode = 0120000
EntryCommit EntryMode = 0160000
)

View File

@ -49,6 +49,7 @@ type Interface interface {
* Diff services
*/
RawDiff(ctx context.Context, in *DiffParams, w io.Writer) error
Diff(ctx context.Context, in *DiffParams, baseURL string) (<-chan *FileDiff, <-chan error)
DiffShortStat(ctx context.Context, params *DiffParams) (DiffShortStatOutput, error)
DiffStats(ctx context.Context, params *DiffParams) (DiffStatsOutput, error)

View File

@ -5,9 +5,13 @@
package service
import (
"bufio"
"bytes"
"context"
"fmt"
"io"
"github.com/harness/gitness/gitrpc/diff"
"github.com/harness/gitness/gitrpc/internal/streamio"
"github.com/harness/gitness/gitrpc/internal/types"
"github.com/harness/gitness/gitrpc/rpc"
@ -29,28 +33,31 @@ func NewDiffService(adapter GitAdapter, reposRoot string, reposTempDir string) (
}
func (s DiffService) RawDiff(request *rpc.DiffRequest, stream rpc.DiffService_RawDiffServer) error {
err := validateDiffRequest(request)
if err != nil {
return err
}
ctx := stream.Context()
base := request.GetBase()
sw := streamio.NewWriter(func(p []byte) error {
return stream.Send(&rpc.RawDiffResponse{Data: p})
})
return s.rawDiff(stream.Context(), request, sw)
}
func (s DiffService) rawDiff(ctx context.Context, request *rpc.DiffRequest, w io.Writer) error {
err := validateDiffRequest(request)
if err != nil {
return err
}
base := request.GetBase()
repoPath := getFullPathForRepo(s.reposRoot, base.GetRepoUid())
args := []string{}
args := make([]string, 0, 4)
args = append(args, "--full-index")
if request.GetMergeBase() {
args = []string{
"--merge-base",
}
args = append(args, "--merge-base")
}
return s.adapter.RawDiff(ctx, repoPath, request.GetBaseRef(), request.GetHeadRef(), sw, args...)
return s.adapter.RawDiff(ctx, repoPath, request.GetBaseRef(), request.GetHeadRef(), w, args...)
}
func validateDiffRequest(in *rpc.DiffRequest) error {
@ -155,3 +162,66 @@ func (s DiffService) DiffCut(
LatestSourceSha: sourceCommits[0],
}, nil
}
func (s DiffService) Diff(request *rpc.DiffRequest, stream rpc.DiffService_DiffServer) error {
done := make(chan bool)
defer close(done)
pr, pw := io.Pipe()
defer pr.Close()
parser := diff.Parser{
Reader: bufio.NewReader(pr),
}
go func() {
defer pw.Close()
err := s.rawDiff(stream.Context(), request, pw)
if err != nil {
return
}
}()
return parser.Parse(func(f *diff.File) {
streamDiffFile(f, request.IncludePatch, stream)
})
}
func streamDiffFile(f *diff.File, includePatch bool, stream rpc.DiffService_DiffServer) {
var status rpc.DiffResponse_FileStatus
switch f.Type {
case diff.FileAdd:
status = rpc.DiffResponse_ADDED
case diff.FileChange:
status = rpc.DiffResponse_MODIFIED
case diff.FileDelete:
status = rpc.DiffResponse_DELETED
case diff.FileRename:
status = rpc.DiffResponse_RENAMED
default:
status = rpc.DiffResponse_UNDEFINED
}
patch := bytes.Buffer{}
if includePatch {
for _, sec := range f.Sections {
for _, line := range sec.Lines {
if line.Type != diff.DiffLinePlain {
patch.WriteString(line.Content)
}
}
}
}
stream.Send(&rpc.DiffResponse{
Path: f.Path,
OldPath: f.OldPath,
Sha: f.SHA,
OldSha: f.OldSHA,
Status: status,
Additions: int32(f.NumAdditions()),
Deletions: int32(f.NumDeletions()),
Changes: int32(f.NumChanges()),
Patch: patch.Bytes(),
})
}

View File

@ -52,13 +52,40 @@ type GitAdapter interface {
Merge(ctx context.Context, pr *types.PullRequest, mergeMethod enum.MergeMethod, baseBranch, trackingBranch string,
tmpBasePath string, mergeMsg string, env []string, identity *types.Identity) error
GetMergeBase(ctx context.Context, repoPath, remote, base, head string) (string, string, error)
GetDiffTree(ctx context.Context, repoPath, baseBranch, headBranch string) (string, error)
RawDiff(ctx context.Context, repoPath, base, head string, w io.Writer, args ...string) error
DiffShortStat(ctx context.Context, repoPath string,
baseRef string, headRef string, direct bool) (types.DiffShortStat, error)
GetDiffHunkHeaders(ctx context.Context, repoPath, targetRef, sourceRef string) ([]*types.DiffFileHunkHeaders, error)
DiffCut(ctx context.Context, repoPath, targetRef, sourceRef, path string,
params types.DiffCutParams) (types.HunkHeader, types.Hunk, error)
Blame(ctx context.Context, repoPath, rev, file string, lineFrom, lineTo int) types.BlameReader
Sync(ctx context.Context, repoPath string, source string) error
//
// Diff operations
//
GetDiffTree(ctx context.Context,
repoPath,
baseBranch,
headBranch string) (string, error)
RawDiff(ctx context.Context,
repoPath,
base,
head string,
w io.Writer,
args ...string) error
DiffShortStat(ctx context.Context,
repoPath string,
baseRef string,
headRef string,
direct bool) (types.DiffShortStat, error)
GetDiffHunkHeaders(ctx context.Context,
repoPath string,
targetRef string,
sourceRef string) ([]*types.DiffFileHunkHeaders, error)
DiffCut(ctx context.Context,
repoPath string,
targetRef string,
sourceRef string,
path string,
params types.DiffCutParams) (types.HunkHeader, types.Hunk, error)
}

View File

@ -9,6 +9,7 @@ import "shared.proto";
// introduced between a set of commits.
service DiffService {
rpc RawDiff(DiffRequest) returns (stream RawDiffResponse) {}
rpc Diff(DiffRequest) returns (stream DiffResponse) {}
rpc DiffShortStat(DiffRequest) returns (DiffShortStatResponse) {}
rpc GetDiffHunkHeaders(GetDiffHunkHeadersRequest) returns (GetDiffHunkHeadersResponse) {}
rpc DiffCut(DiffCutRequest) returns (DiffCutResponse) {}
@ -23,6 +24,8 @@ message DiffRequest {
// merge_base used only in branch comparison, if merge_base is true
// it will show diff from the commit where branch is created and head branch
bool merge_base = 4;
// include_patch
bool include_patch = 5;
}
message RawDiffResponse {
@ -84,3 +87,42 @@ message DiffCutResponse {
string merge_base_sha = 4;
string latest_source_sha = 5;
}
message DiffResponse {
// A list of different file statuses
enum FileStatus {
// undefined
UNDEFINED = 0;
// file has been added
ADDED = 1;
// file has been changed
MODIFIED = 2;
// file has been deleted
DELETED = 3;
// the file has been renamed
RENAMED = 4;
}
// The path and name of the file
string path = 1;
// The old path and name of the file
string old_path = 2;
// sha (SHA1 hash) of the file. For a changed/new file, it is the new SHA,
// and for a deleted file it becomes "000000".
string sha = 3;
// old_sha is the old index (SHA1 hash) of the file.
string old_sha = 4;
// status of the file.
FileStatus status = 5;
// total number of additions in the file
int32 additions = 6;
// total number of deletions in the file
int32 deletions = 7;
// number of changes in the file
int32 changes = 8;
// patch from the file diff
bytes patch = 9;
// is binary file
bool is_binary = 10;
// is submodule
bool is_submodule = 11;
}

View File

@ -20,6 +20,67 @@ const (
_ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20)
)
// A list of different file statuses
type DiffResponse_FileStatus int32
const (
// undefined
DiffResponse_UNDEFINED DiffResponse_FileStatus = 0
// file has been added
DiffResponse_ADDED DiffResponse_FileStatus = 1
// file has been changed
DiffResponse_MODIFIED DiffResponse_FileStatus = 2
// file has been deleted
DiffResponse_DELETED DiffResponse_FileStatus = 3
// the file has been renamed
DiffResponse_RENAMED DiffResponse_FileStatus = 4
)
// Enum value maps for DiffResponse_FileStatus.
var (
DiffResponse_FileStatus_name = map[int32]string{
0: "UNDEFINED",
1: "ADDED",
2: "MODIFIED",
3: "DELETED",
4: "RENAMED",
}
DiffResponse_FileStatus_value = map[string]int32{
"UNDEFINED": 0,
"ADDED": 1,
"MODIFIED": 2,
"DELETED": 3,
"RENAMED": 4,
}
)
func (x DiffResponse_FileStatus) Enum() *DiffResponse_FileStatus {
p := new(DiffResponse_FileStatus)
*p = x
return p
}
func (x DiffResponse_FileStatus) String() string {
return protoimpl.X.EnumStringOf(x.Descriptor(), protoreflect.EnumNumber(x))
}
func (DiffResponse_FileStatus) Descriptor() protoreflect.EnumDescriptor {
return file_diff_proto_enumTypes[0].Descriptor()
}
func (DiffResponse_FileStatus) Type() protoreflect.EnumType {
return &file_diff_proto_enumTypes[0]
}
func (x DiffResponse_FileStatus) Number() protoreflect.EnumNumber {
return protoreflect.EnumNumber(x)
}
// Deprecated: Use DiffResponse_FileStatus.Descriptor instead.
func (DiffResponse_FileStatus) EnumDescriptor() ([]byte, []int) {
return file_diff_proto_rawDescGZIP(), []int{10, 0}
}
type DiffRequest struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -33,6 +94,8 @@ type DiffRequest struct {
// merge_base used only in branch comparison, if merge_base is true
// it will show diff from the commit where branch is created and head branch
MergeBase bool `protobuf:"varint,4,opt,name=merge_base,json=mergeBase,proto3" json:"merge_base,omitempty"`
// include_patch
IncludePatch bool `protobuf:"varint,5,opt,name=include_patch,json=includePatch,proto3" json:"include_patch,omitempty"`
}
func (x *DiffRequest) Reset() {
@ -95,6 +158,13 @@ func (x *DiffRequest) GetMergeBase() bool {
return false
}
func (x *DiffRequest) GetIncludePatch() bool {
if x != nil {
return x.IncludePatch
}
return false
}
type RawDiffResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
@ -710,12 +780,151 @@ func (x *DiffCutResponse) GetLatestSourceSha() string {
return ""
}
type DiffResponse struct {
state protoimpl.MessageState
sizeCache protoimpl.SizeCache
unknownFields protoimpl.UnknownFields
// The path and name of the file
Path string `protobuf:"bytes,1,opt,name=path,proto3" json:"path,omitempty"`
// The old path and name of the file
OldPath string `protobuf:"bytes,2,opt,name=old_path,json=oldPath,proto3" json:"old_path,omitempty"`
// sha (SHA1 hash) of the file. For a changed/new file, it is the new SHA,
// and for a deleted file it becomes "000000".
Sha string `protobuf:"bytes,3,opt,name=sha,proto3" json:"sha,omitempty"`
// old_sha is the old index (SHA1 hash) of the file.
OldSha string `protobuf:"bytes,4,opt,name=old_sha,json=oldSha,proto3" json:"old_sha,omitempty"`
// status of the file.
Status DiffResponse_FileStatus `protobuf:"varint,5,opt,name=status,proto3,enum=rpc.DiffResponse_FileStatus" json:"status,omitempty"`
// total number of additions in the file
Additions int32 `protobuf:"varint,6,opt,name=additions,proto3" json:"additions,omitempty"`
// total number of deletions in the file
Deletions int32 `protobuf:"varint,7,opt,name=deletions,proto3" json:"deletions,omitempty"`
// number of changes in the file
Changes int32 `protobuf:"varint,8,opt,name=changes,proto3" json:"changes,omitempty"`
// patch from the file diff
Patch []byte `protobuf:"bytes,9,opt,name=patch,proto3" json:"patch,omitempty"`
// is binary file
IsBinary bool `protobuf:"varint,10,opt,name=is_binary,json=isBinary,proto3" json:"is_binary,omitempty"`
// is submodule
IsSubmodule bool `protobuf:"varint,11,opt,name=is_submodule,json=isSubmodule,proto3" json:"is_submodule,omitempty"`
}
func (x *DiffResponse) Reset() {
*x = DiffResponse{}
if protoimpl.UnsafeEnabled {
mi := &file_diff_proto_msgTypes[10]
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
ms.StoreMessageInfo(mi)
}
}
func (x *DiffResponse) String() string {
return protoimpl.X.MessageStringOf(x)
}
func (*DiffResponse) ProtoMessage() {}
func (x *DiffResponse) ProtoReflect() protoreflect.Message {
mi := &file_diff_proto_msgTypes[10]
if protoimpl.UnsafeEnabled && x != nil {
ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x))
if ms.LoadMessageInfo() == nil {
ms.StoreMessageInfo(mi)
}
return ms
}
return mi.MessageOf(x)
}
// Deprecated: Use DiffResponse.ProtoReflect.Descriptor instead.
func (*DiffResponse) Descriptor() ([]byte, []int) {
return file_diff_proto_rawDescGZIP(), []int{10}
}
func (x *DiffResponse) GetPath() string {
if x != nil {
return x.Path
}
return ""
}
func (x *DiffResponse) GetOldPath() string {
if x != nil {
return x.OldPath
}
return ""
}
func (x *DiffResponse) GetSha() string {
if x != nil {
return x.Sha
}
return ""
}
func (x *DiffResponse) GetOldSha() string {
if x != nil {
return x.OldSha
}
return ""
}
func (x *DiffResponse) GetStatus() DiffResponse_FileStatus {
if x != nil {
return x.Status
}
return DiffResponse_UNDEFINED
}
func (x *DiffResponse) GetAdditions() int32 {
if x != nil {
return x.Additions
}
return 0
}
func (x *DiffResponse) GetDeletions() int32 {
if x != nil {
return x.Deletions
}
return 0
}
func (x *DiffResponse) GetChanges() int32 {
if x != nil {
return x.Changes
}
return 0
}
func (x *DiffResponse) GetPatch() []byte {
if x != nil {
return x.Patch
}
return nil
}
func (x *DiffResponse) GetIsBinary() bool {
if x != nil {
return x.IsBinary
}
return false
}
func (x *DiffResponse) GetIsSubmodule() bool {
if x != nil {
return x.IsSubmodule
}
return false
}
var File_diff_proto protoreflect.FileDescriptor
var file_diff_proto_rawDesc = []byte{
0x0a, 0x0a, 0x64, 0x69, 0x66, 0x66, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x03, 0x72, 0x70,
0x63, 0x1a, 0x0c, 0x73, 0x68, 0x61, 0x72, 0x65, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x22,
0x88, 0x01, 0x0a, 0x0b, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0xad, 0x01, 0x0a, 0x0b, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12,
0x24, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e,
0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52,
0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x72, 0x65,
@ -723,119 +932,150 @@ var file_diff_proto_rawDesc = []byte{
0x12, 0x19, 0x0a, 0x08, 0x68, 0x65, 0x61, 0x64, 0x5f, 0x72, 0x65, 0x66, 0x18, 0x03, 0x20, 0x01,
0x28, 0x09, 0x52, 0x07, 0x68, 0x65, 0x61, 0x64, 0x52, 0x65, 0x66, 0x12, 0x1d, 0x0a, 0x0a, 0x6d,
0x65, 0x72, 0x67, 0x65, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52,
0x09, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x22, 0x25, 0x0a, 0x0f, 0x52, 0x61,
0x77, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a,
0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c, 0x52, 0x04, 0x64, 0x61, 0x74,
0x61, 0x22, 0x69, 0x0a, 0x15, 0x44, 0x69, 0x66, 0x66, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x53, 0x74,
0x61, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x14, 0x0a, 0x05, 0x66, 0x69,
0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73,
0x12, 0x1c, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x02, 0x20,
0x01, 0x28, 0x05, 0x52, 0x09, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1c,
0x0a, 0x09, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x01, 0x28,
0x05, 0x52, 0x09, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x22, 0x8c, 0x01, 0x0a,
0x0a, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x19, 0x0a, 0x08, 0x6f,
0x6c, 0x64, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6f,
0x6c, 0x64, 0x4c, 0x69, 0x6e, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x6c, 0x64, 0x5f, 0x73, 0x70,
0x61, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6f, 0x6c, 0x64, 0x53, 0x70, 0x61,
0x6e, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x65, 0x77, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x03, 0x20,
0x01, 0x28, 0x05, 0x52, 0x07, 0x6e, 0x65, 0x77, 0x4c, 0x69, 0x6e, 0x65, 0x12, 0x19, 0x0a, 0x08,
0x6e, 0x65, 0x77, 0x5f, 0x73, 0x70, 0x61, 0x6e, 0x18, 0x04, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07,
0x6e, 0x65, 0x77, 0x53, 0x70, 0x61, 0x6e, 0x12, 0x12, 0x0a, 0x04, 0x74, 0x65, 0x78, 0x74, 0x18,
0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74, 0x22, 0xdc, 0x01, 0x0a, 0x0e,
0x44, 0x69, 0x66, 0x66, 0x46, 0x69, 0x6c, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x22,
0x0a, 0x0d, 0x6f, 0x6c, 0x64, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18,
0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6f, 0x6c, 0x64, 0x46, 0x69, 0x6c, 0x65, 0x4e, 0x61,
0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x6e, 0x65, 0x77, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x6e,
0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6e, 0x65, 0x77, 0x46, 0x69,
0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x43, 0x0a, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73,
0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x23, 0x2e, 0x72, 0x70, 0x63,
0x2e, 0x44, 0x69, 0x66, 0x66, 0x46, 0x69, 0x6c, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x2e,
0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x52,
0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x1a, 0x3d, 0x0a, 0x0f, 0x45,
0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e, 0x74, 0x72, 0x79, 0x12, 0x10,
0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x6b, 0x65, 0x79,
0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22, 0x7f, 0x0a, 0x13, 0x44, 0x69,
0x66, 0x66, 0x46, 0x69, 0x6c, 0x65, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72,
0x73, 0x12, 0x34, 0x0a, 0x0b, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66,
0x66, 0x46, 0x69, 0x6c, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0a, 0x66, 0x69, 0x6c,
0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x32, 0x0a, 0x0c, 0x68, 0x75, 0x6e, 0x6b, 0x5f,
0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x0f, 0x2e,
0x72, 0x70, 0x63, 0x2e, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0b,
0x68, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x22, 0x99, 0x01, 0x0a, 0x19,
0x09, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x12, 0x23, 0x0a, 0x0d, 0x69, 0x6e,
0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x70, 0x61, 0x74, 0x63, 0x68, 0x18, 0x05, 0x20, 0x01, 0x28,
0x08, 0x52, 0x0c, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x50, 0x61, 0x74, 0x63, 0x68, 0x22,
0x25, 0x0a, 0x0f, 0x52, 0x61, 0x77, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e,
0x73, 0x65, 0x12, 0x12, 0x0a, 0x04, 0x64, 0x61, 0x74, 0x61, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0c,
0x52, 0x04, 0x64, 0x61, 0x74, 0x61, 0x22, 0x69, 0x0a, 0x15, 0x44, 0x69, 0x66, 0x66, 0x53, 0x68,
0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x14, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x05,
0x66, 0x69, 0x6c, 0x65, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f,
0x6e, 0x73, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69,
0x6f, 0x6e, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6f, 0x6e, 0x73,
0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x64, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6f, 0x6e,
0x73, 0x22, 0x8c, 0x01, 0x0a, 0x0a, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72,
0x12, 0x19, 0x0a, 0x08, 0x6f, 0x6c, 0x64, 0x5f, 0x6c, 0x69, 0x6e, 0x65, 0x18, 0x01, 0x20, 0x01,
0x28, 0x05, 0x52, 0x07, 0x6f, 0x6c, 0x64, 0x4c, 0x69, 0x6e, 0x65, 0x12, 0x19, 0x0a, 0x08, 0x6f,
0x6c, 0x64, 0x5f, 0x73, 0x70, 0x61, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6f,
0x6c, 0x64, 0x53, 0x70, 0x61, 0x6e, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x65, 0x77, 0x5f, 0x6c, 0x69,
0x6e, 0x65, 0x18, 0x03, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6e, 0x65, 0x77, 0x4c, 0x69, 0x6e,
0x65, 0x12, 0x19, 0x0a, 0x08, 0x6e, 0x65, 0x77, 0x5f, 0x73, 0x70, 0x61, 0x6e, 0x18, 0x04, 0x20,
0x01, 0x28, 0x05, 0x52, 0x07, 0x6e, 0x65, 0x77, 0x53, 0x70, 0x61, 0x6e, 0x12, 0x12, 0x0a, 0x04,
0x74, 0x65, 0x78, 0x74, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x74, 0x65, 0x78, 0x74,
0x22, 0xdc, 0x01, 0x0a, 0x0e, 0x44, 0x69, 0x66, 0x66, 0x46, 0x69, 0x6c, 0x65, 0x48, 0x65, 0x61,
0x64, 0x65, 0x72, 0x12, 0x22, 0x0a, 0x0d, 0x6f, 0x6c, 0x64, 0x5f, 0x66, 0x69, 0x6c, 0x65, 0x5f,
0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6f, 0x6c, 0x64, 0x46,
0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x22, 0x0a, 0x0d, 0x6e, 0x65, 0x77, 0x5f, 0x66,
0x69, 0x6c, 0x65, 0x5f, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b,
0x6e, 0x65, 0x77, 0x46, 0x69, 0x6c, 0x65, 0x4e, 0x61, 0x6d, 0x65, 0x12, 0x43, 0x0a, 0x0a, 0x65,
0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x0b, 0x32,
0x23, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x46, 0x69, 0x6c, 0x65, 0x48, 0x65,
0x61, 0x64, 0x65, 0x72, 0x2e, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45,
0x6e, 0x74, 0x72, 0x79, 0x52, 0x0a, 0x65, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73,
0x1a, 0x3d, 0x0a, 0x0f, 0x45, 0x78, 0x74, 0x65, 0x6e, 0x73, 0x69, 0x6f, 0x6e, 0x73, 0x45, 0x6e,
0x74, 0x72, 0x79, 0x12, 0x10, 0x0a, 0x03, 0x6b, 0x65, 0x79, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
0x52, 0x03, 0x6b, 0x65, 0x79, 0x12, 0x14, 0x0a, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x18, 0x02,
0x20, 0x01, 0x28, 0x09, 0x52, 0x05, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x3a, 0x02, 0x38, 0x01, 0x22,
0x7f, 0x0a, 0x13, 0x44, 0x69, 0x66, 0x66, 0x46, 0x69, 0x6c, 0x65, 0x48, 0x75, 0x6e, 0x6b, 0x48,
0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x34, 0x0a, 0x0b, 0x66, 0x69, 0x6c, 0x65, 0x5f, 0x68,
0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x13, 0x2e, 0x72, 0x70,
0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x46, 0x69, 0x6c, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72,
0x52, 0x0a, 0x66, 0x69, 0x6c, 0x65, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x32, 0x0a, 0x0c,
0x68, 0x75, 0x6e, 0x6b, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x18, 0x02, 0x20, 0x03,
0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61,
0x64, 0x65, 0x72, 0x52, 0x0b, 0x68, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73,
0x22, 0x99, 0x01, 0x0a, 0x19, 0x47, 0x65, 0x74, 0x44, 0x69, 0x66, 0x66, 0x48, 0x75, 0x6e, 0x6b,
0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24,
0x0a, 0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72,
0x70, 0x63, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04,
0x62, 0x61, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x11, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63,
0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x73, 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x68, 0x61,
0x12, 0x2a, 0x0a, 0x11, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69,
0x74, 0x5f, 0x73, 0x68, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x61, 0x72,
0x67, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x68, 0x61, 0x22, 0x4c, 0x0a, 0x1a,
0x47, 0x65, 0x74, 0x44, 0x69, 0x66, 0x66, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65,
0x72, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x62, 0x61, 0x73,
0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65,
0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12,
0x2a, 0x0a, 0x11, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74,
0x5f, 0x73, 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x6f, 0x75, 0x72,
0x63, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x68, 0x61, 0x12, 0x2a, 0x0a, 0x11, 0x74,
0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x73, 0x68, 0x61,
0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x43, 0x6f,
0x6d, 0x6d, 0x69, 0x74, 0x53, 0x68, 0x61, 0x22, 0x4c, 0x0a, 0x1a, 0x47, 0x65, 0x74, 0x44, 0x69,
0x66, 0x66, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65, 0x73,
0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x18, 0x01,
0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x46,
0x69, 0x6c, 0x65, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x52, 0x05,
0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0xee, 0x02, 0x0a, 0x0e, 0x44, 0x69, 0x66, 0x66, 0x43, 0x75,
0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a, 0x04, 0x62, 0x61, 0x73, 0x65,
0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x65, 0x61,
0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62, 0x61, 0x73, 0x65, 0x12, 0x2a,
0x0a, 0x11, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f,
0x73, 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x73, 0x6f, 0x75, 0x72, 0x63,
0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x68, 0x61, 0x12, 0x23, 0x0a, 0x0d, 0x73, 0x6f,
0x75, 0x72, 0x63, 0x65, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x03, 0x20, 0x01, 0x28,
0x09, 0x52, 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x12,
0x2a, 0x0a, 0x11, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x63, 0x6f, 0x6d, 0x6d, 0x69, 0x74,
0x5f, 0x73, 0x68, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x74, 0x61, 0x72, 0x67,
0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x68, 0x61, 0x12, 0x23, 0x0a, 0x0d, 0x74,
0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68, 0x18, 0x05, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0c, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x42, 0x72, 0x61, 0x6e, 0x63, 0x68,
0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04,
0x70, 0x61, 0x74, 0x68, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x73, 0x74, 0x61,
0x72, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x6c, 0x69, 0x6e, 0x65, 0x53, 0x74,
0x61, 0x72, 0x74, 0x12, 0x24, 0x0a, 0x0e, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x73, 0x74, 0x61, 0x72,
0x74, 0x5f, 0x6e, 0x65, 0x77, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0c, 0x6c, 0x69, 0x6e,
0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x4e, 0x65, 0x77, 0x12, 0x19, 0x0a, 0x08, 0x6c, 0x69, 0x6e,
0x65, 0x5f, 0x65, 0x6e, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x6c, 0x69, 0x6e,
0x65, 0x45, 0x6e, 0x64, 0x12, 0x20, 0x0a, 0x0c, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x65, 0x6e, 0x64,
0x5f, 0x6e, 0x65, 0x77, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0a, 0x6c, 0x69, 0x6e, 0x65,
0x45, 0x6e, 0x64, 0x4e, 0x65, 0x77, 0x22, 0xce, 0x01, 0x0a, 0x0f, 0x44, 0x69, 0x66, 0x66, 0x43,
0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x30, 0x0a, 0x0b, 0x68, 0x75,
0x6e, 0x6b, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32,
0x0f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72,
0x52, 0x0a, 0x68, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12, 0x21, 0x0a, 0x0c,
0x6c, 0x69, 0x6e, 0x65, 0x73, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x02, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0b, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x12,
0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x05,
0x6c, 0x69, 0x6e, 0x65, 0x73, 0x12, 0x24, 0x0a, 0x0e, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x5f, 0x62,
0x61, 0x73, 0x65, 0x5f, 0x73, 0x68, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x6d,
0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x53, 0x68, 0x61, 0x12, 0x2a, 0x0a, 0x11, 0x6c,
0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x73, 0x68, 0x61,
0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x53, 0x6f,
0x75, 0x72, 0x63, 0x65, 0x53, 0x68, 0x61, 0x32, 0x96, 0x02, 0x0a, 0x0b, 0x44, 0x69, 0x66, 0x66,
0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x35, 0x0a, 0x07, 0x52, 0x61, 0x77, 0x44, 0x69,
0x66, 0x66, 0x12, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x61, 0x77, 0x44, 0x69,
0x66, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01, 0x12, 0x3f,
0x0a, 0x0d, 0x44, 0x69, 0x66, 0x66, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x12,
0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73,
0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x53, 0x68, 0x6f, 0x72,
0x74, 0x53, 0x74, 0x61, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12,
0x57, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x44, 0x69, 0x66, 0x66, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65,
0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x1e, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x44,
0x69, 0x66, 0x66, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65,
0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47, 0x65, 0x74, 0x44,
0x69, 0x66, 0x66, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x52, 0x65,
0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x36, 0x0a, 0x07, 0x44, 0x69, 0x66, 0x66,
0x43, 0x75, 0x74, 0x12, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x43, 0x75,
0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44,
0x69, 0x66, 0x66, 0x43, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00,
0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x68,
0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67,
0x69, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f,
0x33,
0x72, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x2e, 0x0a, 0x05, 0x66, 0x69,
0x6c, 0x65, 0x73, 0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x18, 0x2e, 0x72, 0x70, 0x63, 0x2e,
0x44, 0x69, 0x66, 0x66, 0x46, 0x69, 0x6c, 0x65, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64,
0x65, 0x72, 0x73, 0x52, 0x05, 0x66, 0x69, 0x6c, 0x65, 0x73, 0x22, 0xee, 0x02, 0x0a, 0x0e, 0x44,
0x69, 0x66, 0x66, 0x43, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x24, 0x0a,
0x04, 0x62, 0x61, 0x73, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x10, 0x2e, 0x72, 0x70,
0x63, 0x2e, 0x52, 0x65, 0x61, 0x64, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x52, 0x04, 0x62,
0x61, 0x73, 0x65, 0x12, 0x2a, 0x0a, 0x11, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x63, 0x6f,
0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x73, 0x68, 0x61, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f,
0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x68, 0x61, 0x12,
0x23, 0x0a, 0x0d, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63, 0x68,
0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x73, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x42, 0x72,
0x61, 0x6e, 0x63, 0x68, 0x12, 0x2a, 0x0a, 0x11, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x63,
0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x5f, 0x73, 0x68, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
0x0f, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x43, 0x6f, 0x6d, 0x6d, 0x69, 0x74, 0x53, 0x68, 0x61,
0x12, 0x23, 0x0a, 0x0d, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x5f, 0x62, 0x72, 0x61, 0x6e, 0x63,
0x68, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0c, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x42,
0x72, 0x61, 0x6e, 0x63, 0x68, 0x12, 0x12, 0x0a, 0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x06, 0x20,
0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74, 0x68, 0x12, 0x1d, 0x0a, 0x0a, 0x6c, 0x69, 0x6e,
0x65, 0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09, 0x6c,
0x69, 0x6e, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x12, 0x24, 0x0a, 0x0e, 0x6c, 0x69, 0x6e, 0x65,
0x5f, 0x73, 0x74, 0x61, 0x72, 0x74, 0x5f, 0x6e, 0x65, 0x77, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08,
0x52, 0x0c, 0x6c, 0x69, 0x6e, 0x65, 0x53, 0x74, 0x61, 0x72, 0x74, 0x4e, 0x65, 0x77, 0x12, 0x19,
0x0a, 0x08, 0x6c, 0x69, 0x6e, 0x65, 0x5f, 0x65, 0x6e, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x05,
0x52, 0x07, 0x6c, 0x69, 0x6e, 0x65, 0x45, 0x6e, 0x64, 0x12, 0x20, 0x0a, 0x0c, 0x6c, 0x69, 0x6e,
0x65, 0x5f, 0x65, 0x6e, 0x64, 0x5f, 0x6e, 0x65, 0x77, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52,
0x0a, 0x6c, 0x69, 0x6e, 0x65, 0x45, 0x6e, 0x64, 0x4e, 0x65, 0x77, 0x22, 0xce, 0x01, 0x0a, 0x0f,
0x44, 0x69, 0x66, 0x66, 0x43, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12,
0x30, 0x0a, 0x0b, 0x68, 0x75, 0x6e, 0x6b, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65, 0x72, 0x18, 0x01,
0x20, 0x01, 0x28, 0x0b, 0x32, 0x0f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x48, 0x75, 0x6e, 0x6b, 0x48,
0x65, 0x61, 0x64, 0x65, 0x72, 0x52, 0x0a, 0x68, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65,
0x72, 0x12, 0x21, 0x0a, 0x0c, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x5f, 0x68, 0x65, 0x61, 0x64, 0x65,
0x72, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0b, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x48, 0x65,
0x61, 0x64, 0x65, 0x72, 0x12, 0x14, 0x0a, 0x05, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x18, 0x03, 0x20,
0x03, 0x28, 0x09, 0x52, 0x05, 0x6c, 0x69, 0x6e, 0x65, 0x73, 0x12, 0x24, 0x0a, 0x0e, 0x6d, 0x65,
0x72, 0x67, 0x65, 0x5f, 0x62, 0x61, 0x73, 0x65, 0x5f, 0x73, 0x68, 0x61, 0x18, 0x04, 0x20, 0x01,
0x28, 0x09, 0x52, 0x0c, 0x6d, 0x65, 0x72, 0x67, 0x65, 0x42, 0x61, 0x73, 0x65, 0x53, 0x68, 0x61,
0x12, 0x2a, 0x0a, 0x11, 0x6c, 0x61, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63,
0x65, 0x5f, 0x73, 0x68, 0x61, 0x18, 0x05, 0x20, 0x01, 0x28, 0x09, 0x52, 0x0f, 0x6c, 0x61, 0x74,
0x65, 0x73, 0x74, 0x53, 0x6f, 0x75, 0x72, 0x63, 0x65, 0x53, 0x68, 0x61, 0x22, 0x9a, 0x03, 0x0a,
0x0c, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x12, 0x0a,
0x04, 0x70, 0x61, 0x74, 0x68, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x70, 0x61, 0x74,
0x68, 0x12, 0x19, 0x0a, 0x08, 0x6f, 0x6c, 0x64, 0x5f, 0x70, 0x61, 0x74, 0x68, 0x18, 0x02, 0x20,
0x01, 0x28, 0x09, 0x52, 0x07, 0x6f, 0x6c, 0x64, 0x50, 0x61, 0x74, 0x68, 0x12, 0x10, 0x0a, 0x03,
0x73, 0x68, 0x61, 0x18, 0x03, 0x20, 0x01, 0x28, 0x09, 0x52, 0x03, 0x73, 0x68, 0x61, 0x12, 0x17,
0x0a, 0x07, 0x6f, 0x6c, 0x64, 0x5f, 0x73, 0x68, 0x61, 0x18, 0x04, 0x20, 0x01, 0x28, 0x09, 0x52,
0x06, 0x6f, 0x6c, 0x64, 0x53, 0x68, 0x61, 0x12, 0x34, 0x0a, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75,
0x73, 0x18, 0x05, 0x20, 0x01, 0x28, 0x0e, 0x32, 0x1c, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69,
0x66, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x2e, 0x46, 0x69, 0x6c, 0x65, 0x53,
0x74, 0x61, 0x74, 0x75, 0x73, 0x52, 0x06, 0x73, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x1c, 0x0a,
0x09, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x05,
0x52, 0x09, 0x61, 0x64, 0x64, 0x69, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x1c, 0x0a, 0x09, 0x64,
0x65, 0x6c, 0x65, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x18, 0x07, 0x20, 0x01, 0x28, 0x05, 0x52, 0x09,
0x64, 0x65, 0x6c, 0x65, 0x74, 0x69, 0x6f, 0x6e, 0x73, 0x12, 0x18, 0x0a, 0x07, 0x63, 0x68, 0x61,
0x6e, 0x67, 0x65, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x05, 0x52, 0x07, 0x63, 0x68, 0x61, 0x6e,
0x67, 0x65, 0x73, 0x12, 0x14, 0x0a, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x18, 0x09, 0x20, 0x01,
0x28, 0x0c, 0x52, 0x05, 0x70, 0x61, 0x74, 0x63, 0x68, 0x12, 0x1b, 0x0a, 0x09, 0x69, 0x73, 0x5f,
0x62, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x18, 0x0a, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x69, 0x73,
0x42, 0x69, 0x6e, 0x61, 0x72, 0x79, 0x12, 0x21, 0x0a, 0x0c, 0x69, 0x73, 0x5f, 0x73, 0x75, 0x62,
0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x18, 0x0b, 0x20, 0x01, 0x28, 0x08, 0x52, 0x0b, 0x69, 0x73,
0x53, 0x75, 0x62, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x22, 0x4e, 0x0a, 0x0a, 0x46, 0x69, 0x6c,
0x65, 0x53, 0x74, 0x61, 0x74, 0x75, 0x73, 0x12, 0x0d, 0x0a, 0x09, 0x55, 0x4e, 0x44, 0x45, 0x46,
0x49, 0x4e, 0x45, 0x44, 0x10, 0x00, 0x12, 0x09, 0x0a, 0x05, 0x41, 0x44, 0x44, 0x45, 0x44, 0x10,
0x01, 0x12, 0x0c, 0x0a, 0x08, 0x4d, 0x4f, 0x44, 0x49, 0x46, 0x49, 0x45, 0x44, 0x10, 0x02, 0x12,
0x0b, 0x0a, 0x07, 0x44, 0x45, 0x4c, 0x45, 0x54, 0x45, 0x44, 0x10, 0x03, 0x12, 0x0b, 0x0a, 0x07,
0x52, 0x45, 0x4e, 0x41, 0x4d, 0x45, 0x44, 0x10, 0x04, 0x32, 0xc7, 0x02, 0x0a, 0x0b, 0x44, 0x69,
0x66, 0x66, 0x53, 0x65, 0x72, 0x76, 0x69, 0x63, 0x65, 0x12, 0x35, 0x0a, 0x07, 0x52, 0x61, 0x77,
0x44, 0x69, 0x66, 0x66, 0x12, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x52,
0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x52, 0x61, 0x77,
0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30, 0x01,
0x12, 0x2f, 0x0a, 0x04, 0x44, 0x69, 0x66, 0x66, 0x12, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44,
0x69, 0x66, 0x66, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x11, 0x2e, 0x72, 0x70, 0x63,
0x2e, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x30,
0x01, 0x12, 0x3f, 0x0a, 0x0d, 0x44, 0x69, 0x66, 0x66, 0x53, 0x68, 0x6f, 0x72, 0x74, 0x53, 0x74,
0x61, 0x74, 0x12, 0x10, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x52, 0x65, 0x71,
0x75, 0x65, 0x73, 0x74, 0x1a, 0x1a, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x53,
0x68, 0x6f, 0x72, 0x74, 0x53, 0x74, 0x61, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65,
0x22, 0x00, 0x12, 0x57, 0x0a, 0x12, 0x47, 0x65, 0x74, 0x44, 0x69, 0x66, 0x66, 0x48, 0x75, 0x6e,
0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72, 0x73, 0x12, 0x1e, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47,
0x65, 0x74, 0x44, 0x69, 0x66, 0x66, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72,
0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x1f, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x47,
0x65, 0x74, 0x44, 0x69, 0x66, 0x66, 0x48, 0x75, 0x6e, 0x6b, 0x48, 0x65, 0x61, 0x64, 0x65, 0x72,
0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x22, 0x00, 0x12, 0x36, 0x0a, 0x07, 0x44,
0x69, 0x66, 0x66, 0x43, 0x75, 0x74, 0x12, 0x13, 0x2e, 0x72, 0x70, 0x63, 0x2e, 0x44, 0x69, 0x66,
0x66, 0x43, 0x75, 0x74, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x72, 0x70,
0x63, 0x2e, 0x44, 0x69, 0x66, 0x66, 0x43, 0x75, 0x74, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73,
0x65, 0x22, 0x00, 0x42, 0x27, 0x5a, 0x25, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f,
0x6d, 0x2f, 0x68, 0x61, 0x72, 0x6e, 0x65, 0x73, 0x73, 0x2f, 0x67, 0x69, 0x74, 0x6e, 0x65, 0x73,
0x73, 0x2f, 0x67, 0x69, 0x74, 0x72, 0x70, 0x63, 0x2f, 0x72, 0x70, 0x63, 0x62, 0x06, 0x70, 0x72,
0x6f, 0x74, 0x6f, 0x33,
}
var (
@ -850,43 +1090,49 @@ func file_diff_proto_rawDescGZIP() []byte {
return file_diff_proto_rawDescData
}
var file_diff_proto_msgTypes = make([]protoimpl.MessageInfo, 11)
var file_diff_proto_enumTypes = make([]protoimpl.EnumInfo, 1)
var file_diff_proto_msgTypes = make([]protoimpl.MessageInfo, 12)
var file_diff_proto_goTypes = []interface{}{
(*DiffRequest)(nil), // 0: rpc.DiffRequest
(*RawDiffResponse)(nil), // 1: rpc.RawDiffResponse
(*DiffShortStatResponse)(nil), // 2: rpc.DiffShortStatResponse
(*HunkHeader)(nil), // 3: rpc.HunkHeader
(*DiffFileHeader)(nil), // 4: rpc.DiffFileHeader
(*DiffFileHunkHeaders)(nil), // 5: rpc.DiffFileHunkHeaders
(*GetDiffHunkHeadersRequest)(nil), // 6: rpc.GetDiffHunkHeadersRequest
(*GetDiffHunkHeadersResponse)(nil), // 7: rpc.GetDiffHunkHeadersResponse
(*DiffCutRequest)(nil), // 8: rpc.DiffCutRequest
(*DiffCutResponse)(nil), // 9: rpc.DiffCutResponse
nil, // 10: rpc.DiffFileHeader.ExtensionsEntry
(*ReadRequest)(nil), // 11: rpc.ReadRequest
(DiffResponse_FileStatus)(0), // 0: rpc.DiffResponse.FileStatus
(*DiffRequest)(nil), // 1: rpc.DiffRequest
(*RawDiffResponse)(nil), // 2: rpc.RawDiffResponse
(*DiffShortStatResponse)(nil), // 3: rpc.DiffShortStatResponse
(*HunkHeader)(nil), // 4: rpc.HunkHeader
(*DiffFileHeader)(nil), // 5: rpc.DiffFileHeader
(*DiffFileHunkHeaders)(nil), // 6: rpc.DiffFileHunkHeaders
(*GetDiffHunkHeadersRequest)(nil), // 7: rpc.GetDiffHunkHeadersRequest
(*GetDiffHunkHeadersResponse)(nil), // 8: rpc.GetDiffHunkHeadersResponse
(*DiffCutRequest)(nil), // 9: rpc.DiffCutRequest
(*DiffCutResponse)(nil), // 10: rpc.DiffCutResponse
(*DiffResponse)(nil), // 11: rpc.DiffResponse
nil, // 12: rpc.DiffFileHeader.ExtensionsEntry
(*ReadRequest)(nil), // 13: rpc.ReadRequest
}
var file_diff_proto_depIdxs = []int32{
11, // 0: rpc.DiffRequest.base:type_name -> rpc.ReadRequest
10, // 1: rpc.DiffFileHeader.extensions:type_name -> rpc.DiffFileHeader.ExtensionsEntry
4, // 2: rpc.DiffFileHunkHeaders.file_header:type_name -> rpc.DiffFileHeader
3, // 3: rpc.DiffFileHunkHeaders.hunk_headers:type_name -> rpc.HunkHeader
11, // 4: rpc.GetDiffHunkHeadersRequest.base:type_name -> rpc.ReadRequest
5, // 5: rpc.GetDiffHunkHeadersResponse.files:type_name -> rpc.DiffFileHunkHeaders
11, // 6: rpc.DiffCutRequest.base:type_name -> rpc.ReadRequest
3, // 7: rpc.DiffCutResponse.hunk_header:type_name -> rpc.HunkHeader
0, // 8: rpc.DiffService.RawDiff:input_type -> rpc.DiffRequest
0, // 9: rpc.DiffService.DiffShortStat:input_type -> rpc.DiffRequest
6, // 10: rpc.DiffService.GetDiffHunkHeaders:input_type -> rpc.GetDiffHunkHeadersRequest
8, // 11: rpc.DiffService.DiffCut:input_type -> rpc.DiffCutRequest
1, // 12: rpc.DiffService.RawDiff:output_type -> rpc.RawDiffResponse
2, // 13: rpc.DiffService.DiffShortStat:output_type -> rpc.DiffShortStatResponse
7, // 14: rpc.DiffService.GetDiffHunkHeaders:output_type -> rpc.GetDiffHunkHeadersResponse
9, // 15: rpc.DiffService.DiffCut:output_type -> rpc.DiffCutResponse
12, // [12:16] is the sub-list for method output_type
8, // [8:12] is the sub-list for method input_type
8, // [8:8] is the sub-list for extension type_name
8, // [8:8] is the sub-list for extension extendee
0, // [0:8] is the sub-list for field type_name
13, // 0: rpc.DiffRequest.base:type_name -> rpc.ReadRequest
12, // 1: rpc.DiffFileHeader.extensions:type_name -> rpc.DiffFileHeader.ExtensionsEntry
5, // 2: rpc.DiffFileHunkHeaders.file_header:type_name -> rpc.DiffFileHeader
4, // 3: rpc.DiffFileHunkHeaders.hunk_headers:type_name -> rpc.HunkHeader
13, // 4: rpc.GetDiffHunkHeadersRequest.base:type_name -> rpc.ReadRequest
6, // 5: rpc.GetDiffHunkHeadersResponse.files:type_name -> rpc.DiffFileHunkHeaders
13, // 6: rpc.DiffCutRequest.base:type_name -> rpc.ReadRequest
4, // 7: rpc.DiffCutResponse.hunk_header:type_name -> rpc.HunkHeader
0, // 8: rpc.DiffResponse.status:type_name -> rpc.DiffResponse.FileStatus
1, // 9: rpc.DiffService.RawDiff:input_type -> rpc.DiffRequest
1, // 10: rpc.DiffService.Diff:input_type -> rpc.DiffRequest
1, // 11: rpc.DiffService.DiffShortStat:input_type -> rpc.DiffRequest
7, // 12: rpc.DiffService.GetDiffHunkHeaders:input_type -> rpc.GetDiffHunkHeadersRequest
9, // 13: rpc.DiffService.DiffCut:input_type -> rpc.DiffCutRequest
2, // 14: rpc.DiffService.RawDiff:output_type -> rpc.RawDiffResponse
11, // 15: rpc.DiffService.Diff:output_type -> rpc.DiffResponse
3, // 16: rpc.DiffService.DiffShortStat:output_type -> rpc.DiffShortStatResponse
8, // 17: rpc.DiffService.GetDiffHunkHeaders:output_type -> rpc.GetDiffHunkHeadersResponse
10, // 18: rpc.DiffService.DiffCut:output_type -> rpc.DiffCutResponse
14, // [14:19] is the sub-list for method output_type
9, // [9:14] is the sub-list for method input_type
9, // [9:9] is the sub-list for extension type_name
9, // [9:9] is the sub-list for extension extendee
0, // [0:9] is the sub-list for field type_name
}
func init() { file_diff_proto_init() }
@ -1016,19 +1262,32 @@ func file_diff_proto_init() {
return nil
}
}
file_diff_proto_msgTypes[10].Exporter = func(v interface{}, i int) interface{} {
switch v := v.(*DiffResponse); i {
case 0:
return &v.state
case 1:
return &v.sizeCache
case 2:
return &v.unknownFields
default:
return nil
}
}
}
type x struct{}
out := protoimpl.TypeBuilder{
File: protoimpl.DescBuilder{
GoPackagePath: reflect.TypeOf(x{}).PkgPath(),
RawDescriptor: file_diff_proto_rawDesc,
NumEnums: 0,
NumMessages: 11,
NumEnums: 1,
NumMessages: 12,
NumExtensions: 0,
NumServices: 1,
},
GoTypes: file_diff_proto_goTypes,
DependencyIndexes: file_diff_proto_depIdxs,
EnumInfos: file_diff_proto_enumTypes,
MessageInfos: file_diff_proto_msgTypes,
}.Build()
File_diff_proto = out.File

View File

@ -23,6 +23,7 @@ const _ = grpc.SupportPackageIsVersion7
// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream.
type DiffServiceClient interface {
RawDiff(ctx context.Context, in *DiffRequest, opts ...grpc.CallOption) (DiffService_RawDiffClient, error)
Diff(ctx context.Context, in *DiffRequest, opts ...grpc.CallOption) (DiffService_DiffClient, error)
DiffShortStat(ctx context.Context, in *DiffRequest, opts ...grpc.CallOption) (*DiffShortStatResponse, error)
GetDiffHunkHeaders(ctx context.Context, in *GetDiffHunkHeadersRequest, opts ...grpc.CallOption) (*GetDiffHunkHeadersResponse, error)
DiffCut(ctx context.Context, in *DiffCutRequest, opts ...grpc.CallOption) (*DiffCutResponse, error)
@ -68,6 +69,38 @@ func (x *diffServiceRawDiffClient) Recv() (*RawDiffResponse, error) {
return m, nil
}
func (c *diffServiceClient) Diff(ctx context.Context, in *DiffRequest, opts ...grpc.CallOption) (DiffService_DiffClient, error) {
stream, err := c.cc.NewStream(ctx, &DiffService_ServiceDesc.Streams[1], "/rpc.DiffService/Diff", opts...)
if err != nil {
return nil, err
}
x := &diffServiceDiffClient{stream}
if err := x.ClientStream.SendMsg(in); err != nil {
return nil, err
}
if err := x.ClientStream.CloseSend(); err != nil {
return nil, err
}
return x, nil
}
type DiffService_DiffClient interface {
Recv() (*DiffResponse, error)
grpc.ClientStream
}
type diffServiceDiffClient struct {
grpc.ClientStream
}
func (x *diffServiceDiffClient) Recv() (*DiffResponse, error) {
m := new(DiffResponse)
if err := x.ClientStream.RecvMsg(m); err != nil {
return nil, err
}
return m, nil
}
func (c *diffServiceClient) DiffShortStat(ctx context.Context, in *DiffRequest, opts ...grpc.CallOption) (*DiffShortStatResponse, error) {
out := new(DiffShortStatResponse)
err := c.cc.Invoke(ctx, "/rpc.DiffService/DiffShortStat", in, out, opts...)
@ -100,6 +133,7 @@ func (c *diffServiceClient) DiffCut(ctx context.Context, in *DiffCutRequest, opt
// for forward compatibility
type DiffServiceServer interface {
RawDiff(*DiffRequest, DiffService_RawDiffServer) error
Diff(*DiffRequest, DiffService_DiffServer) error
DiffShortStat(context.Context, *DiffRequest) (*DiffShortStatResponse, error)
GetDiffHunkHeaders(context.Context, *GetDiffHunkHeadersRequest) (*GetDiffHunkHeadersResponse, error)
DiffCut(context.Context, *DiffCutRequest) (*DiffCutResponse, error)
@ -113,6 +147,9 @@ type UnimplementedDiffServiceServer struct {
func (UnimplementedDiffServiceServer) RawDiff(*DiffRequest, DiffService_RawDiffServer) error {
return status.Errorf(codes.Unimplemented, "method RawDiff not implemented")
}
func (UnimplementedDiffServiceServer) Diff(*DiffRequest, DiffService_DiffServer) error {
return status.Errorf(codes.Unimplemented, "method Diff not implemented")
}
func (UnimplementedDiffServiceServer) DiffShortStat(context.Context, *DiffRequest) (*DiffShortStatResponse, error) {
return nil, status.Errorf(codes.Unimplemented, "method DiffShortStat not implemented")
}
@ -156,6 +193,27 @@ func (x *diffServiceRawDiffServer) Send(m *RawDiffResponse) error {
return x.ServerStream.SendMsg(m)
}
func _DiffService_Diff_Handler(srv interface{}, stream grpc.ServerStream) error {
m := new(DiffRequest)
if err := stream.RecvMsg(m); err != nil {
return err
}
return srv.(DiffServiceServer).Diff(m, &diffServiceDiffServer{stream})
}
type DiffService_DiffServer interface {
Send(*DiffResponse) error
grpc.ServerStream
}
type diffServiceDiffServer struct {
grpc.ServerStream
}
func (x *diffServiceDiffServer) Send(m *DiffResponse) error {
return x.ServerStream.SendMsg(m)
}
func _DiffService_DiffShortStat_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) {
in := new(DiffRequest)
if err := dec(in); err != nil {
@ -236,6 +294,11 @@ var DiffService_ServiceDesc = grpc.ServiceDesc{
Handler: _DiffService_RawDiff_Handler,
ServerStreams: true,
},
{
StreamName: "Diff",
Handler: _DiffService_Diff_Handler,
ServerStreams: true,
},
},
Metadata: "diff.proto",
}

View File

@ -0,0 +1,85 @@
// Copyright 2022 Harness Inc. All rights reserved.
// Use of this source code is governed by the Polyform Free Trial License
// that can be found in the LICENSE.md file for this repository.
package pullreq
import (
"context"
"fmt"
"io"
"github.com/harness/gitness/gitrpc"
"github.com/harness/gitness/internal/auth"
"github.com/harness/gitness/internal/config"
"github.com/harness/gitness/types"
"github.com/harness/gitness/types/enum"
)
// RawDiff writes raw git diff to writer w.
func (c *Controller) RawDiff(
ctx context.Context,
session *auth.Session,
repoRef string,
pullreqNum int64,
setSHAs func(sourceSHA, mergeBaseSHA string),
w io.Writer,
) error {
repo, err := c.getRepoCheckAccess(ctx, session, repoRef, enum.PermissionRepoView)
if err != nil {
return fmt.Errorf("failed to acquire access to target repo: %w", err)
}
pr, err := c.pullreqStore.FindByNumber(ctx, repo.ID, pullreqNum)
if err != nil {
return fmt.Errorf("failed to get pull request by number: %w", err)
}
headRef := pr.SourceSHA
baseRef := pr.MergeBaseSHA
setSHAs(headRef, baseRef)
return c.gitRPCClient.RawDiff(ctx, &gitrpc.DiffParams{
ReadParams: gitrpc.CreateRPCReadParams(repo),
BaseRef: baseRef,
HeadRef: headRef,
MergeBase: true,
}, w)
}
func (c *Controller) Diff(
ctx context.Context,
session *auth.Session,
repoRef string,
pullreqNum int64,
) (types.Stream[*gitrpc.FileDiff], error) {
repo, err := c.getRepoCheckAccess(ctx, session, repoRef, enum.PermissionRepoEdit)
if err != nil {
return nil, fmt.Errorf("failed to acquire access to target repo: %w", err)
}
pr, err := c.pullreqStore.FindByNumber(ctx, repo.ID, pullreqNum)
if err != nil {
return nil, fmt.Errorf("failed to get pull request by number: %w", err)
}
headRef := pr.SourceBranch
if pr.SourceSHA != "" {
headRef = pr.SourceSHA
}
baseRef := pr.TargetBranch
if pr.State == enum.PullReqStateMerged {
baseRef = pr.MergeBaseSHA
}
reader := gitrpc.NewStreamReader(c.gitRPCClient.Diff(ctx, &gitrpc.DiffParams{
ReadParams: gitrpc.CreateRPCReadParams(repo),
BaseRef: baseRef,
HeadRef: headRef,
MergeBase: true,
IncludePatch: true,
}, config.ApiURL))
return reader, nil
}

View File

@ -13,6 +13,7 @@ import (
apiauth "github.com/harness/gitness/internal/api/auth"
"github.com/harness/gitness/internal/api/usererror"
"github.com/harness/gitness/internal/auth"
"github.com/harness/gitness/internal/config"
"github.com/harness/gitness/types"
"github.com/harness/gitness/types/enum"
)
@ -101,3 +102,35 @@ func (c *Controller) DiffStats(
FilesChanged: output.FilesChanged,
}, nil
}
func (c *Controller) Diff(
ctx context.Context,
session *auth.Session,
repoRef string,
path string,
includePatch bool,
) (types.Stream[*gitrpc.FileDiff], error) {
repo, err := c.repoStore.FindByRef(ctx, repoRef)
if err != nil {
return nil, err
}
if err = apiauth.CheckRepo(ctx, c.authorizer, session, repo, enum.PermissionRepoView, false); err != nil {
return nil, err
}
info, err := parseDiffPath(path)
if err != nil {
return nil, err
}
reader := gitrpc.NewStreamReader(c.gitRPCClient.Diff(ctx, &gitrpc.DiffParams{
ReadParams: gitrpc.CreateRPCReadParams(repo),
BaseRef: info.BaseRef,
HeadRef: info.HeadRef,
MergeBase: info.MergeBase,
IncludePatch: includePatch,
}, config.ApiURL))
return reader, nil
}

View File

@ -0,0 +1,59 @@
// Copyright 2022 Harness Inc. All rights reserved.
// Use of this source code is governed by the Polyform Free Trial License
// that can be found in the LICENSE.md file for this repository.
package pullreq
import (
"net/http"
"strings"
"github.com/harness/gitness/internal/api/controller/pullreq"
"github.com/harness/gitness/internal/api/render"
"github.com/harness/gitness/internal/api/request"
)
// HandleDiff returns raw git diff for PR.
func HandleDiff(pullreqCtrl *pullreq.Controller) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
session, _ := request.AuthSessionFrom(ctx)
repoRef, err := request.GetRepoRefFromPath(r)
if err != nil {
render.TranslatedUserError(w, err)
return
}
pullreqNumber, err := request.GetPullReqNumberFromPath(r)
if err != nil {
render.TranslatedUserError(w, err)
return
}
setSHAs := func(sourceSHA, mergeBaseSHA string) {
w.Header().Set("X-Source-Sha", sourceSHA)
w.Header().Set("X-Merge-Base-Sha", mergeBaseSHA)
}
if err = pullreqCtrl.RawDiff(ctx, session, repoRef, pullreqNumber, setSHAs, w); err != nil {
render.TranslatedUserError(w, err)
return
}
if strings.HasPrefix(r.Header.Get("Accept"), "text/plain") {
if err = pullreqCtrl.RawDiff(ctx, session, repoRef, pullreqNumber, setSHAs, w); err != nil {
render.TranslatedUserError(w, err)
}
return
}
stream, err := pullreqCtrl.Diff(ctx, session, repoRef, pullreqNumber)
if err != nil {
render.TranslatedUserError(w, err)
return
}
render.JSONArrayDynamic(ctx, w, stream)
}
}

View File

@ -6,14 +6,15 @@ package repo
import (
"net/http"
"strings"
"github.com/harness/gitness/internal/api/controller/repo"
"github.com/harness/gitness/internal/api/render"
"github.com/harness/gitness/internal/api/request"
)
// HandleRawDiff returns the diff between two commits, branches or tags.
func HandleRawDiff(repoCtrl *repo.Controller) http.HandlerFunc {
// HandleDiff returns the diff between two commits, branches or tags.
func HandleDiff(repoCtrl *repo.Controller) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
session, _ := request.AuthSessionFrom(ctx)
@ -25,32 +26,20 @@ func HandleRawDiff(repoCtrl *repo.Controller) http.HandlerFunc {
path := request.GetOptionalRemainderFromPath(r)
if strings.HasPrefix(r.Header.Get("Accept"), "text/plain") {
if err = repoCtrl.RawDiff(ctx, session, repoRef, path, w); err != nil {
render.TranslatedUserError(w, err)
}
return
}
}
}
// HandleDiffStats how diff statistics of two commits, branches or tags.
func HandleDiffStats(repoCtrl *repo.Controller) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
ctx := r.Context()
session, _ := request.AuthSessionFrom(ctx)
repoRef, err := request.GetRepoRefFromPath(r)
_, includePatch := request.QueryParam(r, "include_patch")
stream, err := repoCtrl.Diff(ctx, session, repoRef, path, includePatch)
if err != nil {
render.TranslatedUserError(w, err)
return
}
path := request.GetOptionalRemainderFromPath(r)
output, err := repoCtrl.DiffStats(ctx, session, repoRef, path)
if err != nil {
render.TranslatedUserError(w, err)
return
}
render.JSON(w, http.StatusOK, output)
render.JSONArrayDynamic(ctx, w, stream)
}
}

View File

@ -5,6 +5,7 @@
package openapi
import (
"github.com/harness/gitness/internal/config"
"github.com/harness/gitness/version"
"github.com/swaggest/openapi-go/openapi3"
@ -27,7 +28,7 @@ func Generate() *openapi3.Spec {
WithTitle("API Specification").
WithVersion(version.Version.String())
reflector.Spec.Servers = []openapi3.Server{{
URL: "/api/v1/",
URL: config.ApiURL,
}}
//

View File

@ -640,15 +640,16 @@ func repoOperations(reflector *openapi3.Reflector) {
_ = reflector.SetJSONResponse(&opCommitFiles, new(usererror.Error), http.StatusNotFound)
_ = reflector.Spec.AddOperation(http.MethodPost, "/repos/{repo_ref}/commits", opCommitFiles)
opRawDiff := openapi3.Operation{}
opRawDiff.WithTags("repository")
opRawDiff.WithMapOfAnything(map[string]interface{}{"operationId": "rawDiff"})
_ = reflector.SetRequest(&opRawDiff, new(getRawDiffRequest), http.MethodGet)
_ = reflector.SetStringResponse(&opRawDiff, http.StatusOK, "text/plain")
_ = reflector.SetJSONResponse(&opRawDiff, new(usererror.Error), http.StatusInternalServerError)
_ = reflector.SetJSONResponse(&opRawDiff, new(usererror.Error), http.StatusUnauthorized)
_ = reflector.SetJSONResponse(&opRawDiff, new(usererror.Error), http.StatusForbidden)
_ = reflector.Spec.AddOperation(http.MethodGet, "/repos/{repo_ref}/compare/{range}", opRawDiff)
opDiff := openapi3.Operation{}
opDiff.WithTags("repository")
opDiff.WithMapOfAnything(map[string]interface{}{"operationId": "rawDiff"})
_ = reflector.SetRequest(&opDiff, new(getRawDiffRequest), http.MethodGet)
_ = reflector.SetJSONResponse(&opDiff, new(types.DiffStats), http.StatusOK)
_ = reflector.SetStringResponse(&opDiff, http.StatusOK, "text/plain")
_ = reflector.SetJSONResponse(&opDiff, new(usererror.Error), http.StatusInternalServerError)
_ = reflector.SetJSONResponse(&opDiff, new(usererror.Error), http.StatusUnauthorized)
_ = reflector.SetJSONResponse(&opDiff, new(usererror.Error), http.StatusForbidden)
_ = reflector.Spec.AddOperation(http.MethodGet, "/repos/{repo_ref}/diff/{range}", opDiff)
opMergeCheck := openapi3.Operation{}
opMergeCheck.WithTags("repository")
@ -659,14 +660,4 @@ func repoOperations(reflector *openapi3.Reflector) {
_ = reflector.SetJSONResponse(&opMergeCheck, new(usererror.Error), http.StatusUnauthorized)
_ = reflector.SetJSONResponse(&opMergeCheck, new(usererror.Error), http.StatusForbidden)
_ = reflector.Spec.AddOperation(http.MethodPost, "/repos/{repo_ref}/merge-check/{range}", opMergeCheck)
opDiffStats := openapi3.Operation{}
opDiffStats.WithTags("repository")
opDiffStats.WithMapOfAnything(map[string]interface{}{"operationId": "diffStats"})
_ = reflector.SetRequest(&opDiffStats, new(getRawDiffRequest), http.MethodGet)
_ = reflector.SetJSONResponse(&opDiffStats, new(types.DiffStats), http.StatusOK)
_ = reflector.SetJSONResponse(&opDiffStats, new(usererror.Error), http.StatusInternalServerError)
_ = reflector.SetJSONResponse(&opDiffStats, new(usererror.Error), http.StatusUnauthorized)
_ = reflector.SetJSONResponse(&opDiffStats, new(usererror.Error), http.StatusForbidden)
_ = reflector.Spec.AddOperation(http.MethodGet, "/repos/{repo_ref}/diff-stats/{range}", opDiffStats)
}

5
internal/config/url.go Normal file
View File

@ -0,0 +1,5 @@
package config
const (
ApiURL = "/api/v1"
)

View File

@ -31,6 +31,7 @@ import (
handleruser "github.com/harness/gitness/internal/api/handler/user"
"github.com/harness/gitness/internal/api/handler/users"
handlerwebhook "github.com/harness/gitness/internal/api/handler/webhook"
"github.com/harness/gitness/internal/api/middleware/address"
middlewareauthn "github.com/harness/gitness/internal/api/middleware/authn"
"github.com/harness/gitness/internal/api/middleware/encode"
"github.com/harness/gitness/internal/api/middleware/logging"
@ -82,6 +83,7 @@ func NewAPIHandler(
r.Use(hlog.MethodHandler("http.method"))
r.Use(logging.HLogRequestIDHandler())
r.Use(logging.HLogAccessLogHandler())
r.Use(address.Handler("", ""))
// configure cors middleware
r.Use(corsHandler(config))
@ -248,15 +250,12 @@ func setupRepos(r chi.Router,
})
// diffs
r.Route("/compare", func(r chi.Router) {
r.Get("/*", handlerrepo.HandleRawDiff(repoCtrl))
r.Route("/diff", func(r chi.Router) {
r.Get("/*", handlerrepo.HandleDiff(repoCtrl))
})
r.Route("/merge-check", func(r chi.Router) {
r.Post("/*", handlerrepo.HandleMergeCheck(repoCtrl))
})
r.Route("/diff-stats", func(r chi.Router) {
r.Get("/*", handlerrepo.HandleDiffStats(repoCtrl))
})
SetupPullReq(r, pullreqCtrl)

View File

@ -79,6 +79,11 @@ export const Changes: React.FC<ChangesProps> = ({
path: `/api/v1/repos/${repoMetadata?.path}/+/compare/${
pullRequestMetadata ? `${pullRequestMetadata.merge_base_sha}...${pullRequestMetadata.source_sha}` : `${targetBranch}...${sourceBranch}`
}`,
requestOptions: {
headers: {
'Accept': 'text/plain'
}
},
lazy: !targetBranch || !sourceBranch
})
const {