drone/gitrpc/proto/diff.proto

143 lines
3.5 KiB
Protocol Buffer

syntax = "proto3";
package rpc;
option go_package = "github.com/harness/gitness/gitrpc/rpc";
import "shared.proto";
// DiffService is a service which provides RPCs to inspect differences
// introduced between a set of commits.
service DiffService {
rpc RawDiff(DiffRequest) returns (stream RawDiffResponse) {}
rpc Diff(DiffRequest) returns (stream DiffResponse) {}
rpc CommitDiff(CommitDiffRequest) returns (stream CommitDiffResponse);
rpc DiffShortStat(DiffRequest) returns (DiffShortStatResponse) {}
rpc GetDiffHunkHeaders(GetDiffHunkHeadersRequest) returns (GetDiffHunkHeadersResponse) {}
rpc DiffCut(DiffCutRequest) returns (DiffCutResponse) {}
rpc DiffFileStat(DiffRequest) returns (DiffFileStatResponse) {}
}
message DiffRequest {
ReadRequest base = 1;
// base_ref is left side of compare and can be branch, commit and tag
string base_ref = 2;
// head_ref is right side of compare and can be branch, commit and tag
string head_ref = 3;
// 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 {
bytes data = 1;
}
message DiffShortStatResponse {
int32 files = 1;
int32 additions = 2;
int32 deletions = 3;
}
message HunkHeader {
int32 old_line = 1;
int32 old_span = 2;
int32 new_line = 3;
int32 new_span = 4;
string text = 5;
}
message DiffFileHeader {
string old_file_name = 1;
string new_file_name = 2;
map<string, string> extensions = 3;
}
message DiffFileHunkHeaders {
DiffFileHeader file_header = 1;
repeated HunkHeader hunk_headers = 2;
}
message GetDiffHunkHeadersRequest {
ReadRequest base = 1;
string source_commit_sha = 2;
string target_commit_sha = 4;
}
message GetDiffHunkHeadersResponse {
repeated DiffFileHunkHeaders files = 1;
}
message DiffCutRequest {
ReadRequest base = 1;
string source_commit_sha = 2;
string source_branch = 3;
string target_commit_sha = 4;
string target_branch = 5;
string path = 6;
int32 line_start = 7;
bool line_start_new = 8;
int32 line_end = 9;
bool line_end_new = 10;
}
message DiffCutResponse {
HunkHeader hunk_header = 1;
string lines_header = 2;
repeated string lines = 3;
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;
}
message CommitDiffRequest {
ReadRequest base = 1;
string sha = 2;
}
message CommitDiffResponse {
bytes data = 1;
}
message DiffFileStatResponse {
repeated string files = 1;
}