feat(core): implement Git repository operations with gRPC services

- Add advertise_refs functionality for Git protocol communication
- Implement archive service with TAR/ZIP format support and streaming
- Create blame service for Git file annotation with line tracking
- Add branch management including create, delete, rename and compare operations
- Implement merge checking with conflict detection and fast-forward handling
- Add cherry-pick functionality for applying commits between branches
- Integrate gix library for Git repository operations and object handling
- Add comprehensive test suite covering all Git operations
- Implement proper error handling and repository validation
- Add pagination support for large result sets
- Create protobuf definitions for all Git operations and data structures
- Add build system for gRPC code generation and dependency management
This commit is contained in:
zhenyi
2026-06-04 13:05:38 +08:00
commit dcb0fb74c5
98 changed files with 20569 additions and 0 deletions
+58
View File
@@ -0,0 +1,58 @@
syntax = "proto3";
package gitks;
import "oid.proto";
import "repository.proto";
message ArchiveOptions {
enum Format {
ARCHIVE_FORMAT_UNSPECIFIED = 0;
ARCHIVE_FORMAT_TAR = 1;
ARCHIVE_FORMAT_TAR_GZ = 2;
ARCHIVE_FORMAT_TAR_BZ2 = 3;
ARCHIVE_FORMAT_TAR_XZ = 4;
ARCHIVE_FORMAT_ZIP = 5;
}
Format format = 1;
string prefix = 2;
repeated string pathspec = 3;
int32 compression_level = 4;
bool include_global_extended_pax_headers = 5;
}
message ArchiveRequest {
RepositoryHeader repository = 1;
ObjectSelector treeish = 2;
ArchiveOptions options = 3;
}
message ArchiveChunk {
bytes data = 1;
}
message ArchiveEntry {
string path = 1;
Oid oid = 2;
uint32 mode = 3;
int64 size = 4;
ObjectType type = 5;
}
message ListArchiveEntriesRequest {
RepositoryHeader repository = 1;
ObjectSelector treeish = 2;
repeated string pathspec = 3;
Pagination pagination = 4;
}
message ListArchiveEntriesResponse {
repeated ArchiveEntry entries = 1;
PageInfo page_info = 2;
}
service ArchiveService {
rpc GetArchive(ArchiveRequest) returns (stream ArchiveChunk);
rpc ListArchiveEntries(ListArchiveEntriesRequest) returns (ListArchiveEntriesResponse);
}
+56
View File
@@ -0,0 +1,56 @@
syntax = "proto3";
package gitks;
import "commit.proto";
import "oid.proto";
import "repository.proto";
message LineRange {
uint32 start = 1;
uint32 end = 2;
}
message BlameOptions {
bool detect_move = 1;
bool detect_copy = 2;
uint32 score = 3;
repeated string ignore_revisions = 4;
}
message BlameRequest {
RepositoryHeader repository = 1;
ObjectSelector revision = 2;
string path = 3;
LineRange range = 4;
BlameOptions options = 5;
Pagination pagination = 6;
}
message BlameLine {
uint32 final_line = 1;
uint32 original_line = 2;
bytes content = 3;
}
message BlameHunk {
Commit commit = 1;
string original_path = 2;
string final_path = 3;
uint32 original_start_line = 4;
uint32 final_start_line = 5;
uint32 line_count = 6;
bool boundary = 7;
repeated BlameLine lines = 8;
}
message BlameResponse {
repeated BlameHunk hunks = 1;
PageInfo page_info = 2;
bool truncated = 3;
}
service BlameService {
rpc Blame(BlameRequest) returns (BlameResponse);
rpc StreamBlame(BlameRequest) returns (stream BlameHunk);
}
+114
View File
@@ -0,0 +1,114 @@
syntax = "proto3";
package gitks;
import "google/protobuf/empty.proto";
import "commit.proto";
import "oid.proto";
import "repository.proto";
message BranchUpstream {
string remote_name = 1;
string remote_url = 2;
string remote_branch_name = 3;
string local_branch_name = 4;
}
message Branch {
string name = 1;
string full_ref = 2;
Oid target_oid = 3;
Commit commit = 4;
BranchUpstream upstream = 5;
bool is_default = 6;
bool is_head = 7;
bool is_merged = 8;
bool is_detached = 9;
}
// Backward-compatible payload name used by earlier clients.
message PayloadBranch {
PayloadCommit commit = 1;
string name = 2;
BranchUpstream upstream = 3;
bool is_head = 4;
}
message RequestBranchInit {}
message ListBranchesRequest {
RepositoryHeader repository = 1;
string pattern = 2;
bool merged_into_head = 3;
bool not_merged_into_head = 4;
Pagination pagination = 5;
SortDirection sort_direction = 6;
}
message ListBranchesResponse {
repeated Branch branches = 1;
PageInfo page_info = 2;
}
message GetBranchRequest {
RepositoryHeader repository = 1;
string name = 2;
}
message CreateBranchRequest {
RepositoryHeader repository = 1;
string name = 2;
ObjectSelector start_point = 3;
bool force = 4;
}
message DeleteBranchRequest {
RepositoryHeader repository = 1;
string name = 2;
bool force = 3;
}
message RenameBranchRequest {
RepositoryHeader repository = 1;
string old_name = 2;
string new_name = 3;
}
message UpdateBranchTargetRequest {
RepositoryHeader repository = 1;
string name = 2;
Oid expected_old_oid = 3;
Oid new_oid = 4;
bool force = 5;
}
message SetBranchUpstreamRequest {
RepositoryHeader repository = 1;
string name = 2;
BranchUpstream upstream = 3;
}
message CompareBranchRequest {
RepositoryHeader repository = 1;
string source_branch = 2;
string target_branch = 3;
}
message CompareBranchResponse {
bool ahead = 1;
bool behind = 2;
uint32 ahead_by = 3;
uint32 behind_by = 4;
Oid merge_base = 5;
}
service BranchService {
rpc ListBranches(ListBranchesRequest) returns (ListBranchesResponse);
rpc GetBranch(GetBranchRequest) returns (Branch);
rpc CreateBranch(CreateBranchRequest) returns (Branch);
rpc DeleteBranch(DeleteBranchRequest) returns (google.protobuf.Empty);
rpc RenameBranch(RenameBranchRequest) returns (Branch);
rpc UpdateBranchTarget(UpdateBranchTargetRequest) returns (Branch);
rpc SetBranchUpstream(SetBranchUpstreamRequest) returns (Branch);
rpc CompareBranch(CompareBranchRequest) returns (CompareBranchResponse);
}
+165
View File
@@ -0,0 +1,165 @@
syntax = "proto3";
package gitks;
import "google/protobuf/timestamp.proto";
import "oid.proto";
import "repository.proto";
import "tagger.proto";
message PayloadCommit {
PayloadTagger author = 1;
PayloadTagger committer = 2;
Oid oid = 3;
string message = 4;
repeated Oid parents = 5;
Oid tree = 6;
google.protobuf.Timestamp timestamp = 7;
}
message CommitTrailer {
string key = 1;
string value = 2;
bool separator_present = 3;
}
message CommitStats {
uint32 additions = 1;
uint32 deletions = 2;
uint32 changed_files = 3;
}
message Commit {
Oid oid = 1;
string abbreviated_oid = 2;
repeated Oid parent_oids = 3;
Oid tree_oid = 4;
Signature author = 5;
Signature committer = 6;
string subject = 7;
string body = 8;
string message = 9;
repeated CommitTrailer trailers = 10;
VerifiedSignature signature = 11;
CommitStats stats = 12;
google.protobuf.Timestamp authored_at = 13;
google.protobuf.Timestamp committed_at = 14;
bytes raw = 15;
}
message ListCommitsRequest {
RepositoryHeader repository = 1;
ObjectSelector revision = 2;
string path = 3;
google.protobuf.Timestamp since = 4;
google.protobuf.Timestamp until = 5;
bool first_parent = 6;
bool all = 7;
bool reverse = 8;
uint32 max_parents = 9;
uint32 min_parents = 10;
Pagination pagination = 11;
}
message ListCommitsResponse {
repeated Commit commits = 1;
PageInfo page_info = 2;
}
message GetCommitRequest {
RepositoryHeader repository = 1;
ObjectSelector revision = 2;
bool include_stats = 3;
bool include_raw = 4;
}
message GetCommitAncestorsRequest {
RepositoryHeader repository = 1;
ObjectSelector revision = 2;
bool first_parent = 3;
Pagination pagination = 4;
}
message GetCommitAncestorsResponse {
repeated Commit commits = 1;
PageInfo page_info = 2;
}
message CreateCommitAction {
enum Action {
CREATE_COMMIT_ACTION_UNSPECIFIED = 0;
CREATE_COMMIT_ACTION_CREATE = 1;
CREATE_COMMIT_ACTION_UPDATE = 2;
CREATE_COMMIT_ACTION_DELETE = 3;
CREATE_COMMIT_ACTION_MOVE = 4;
CREATE_COMMIT_ACTION_CHMOD = 5;
}
Action action = 1;
string file_path = 2;
string previous_path = 3;
bytes content = 4;
string encoding = 5;
bool executable = 6;
Oid last_commit_oid = 7;
}
message CreateCommitRequest {
RepositoryHeader repository = 1;
string branch = 2;
string message = 3;
Signature author = 4;
Signature committer = 5;
repeated CreateCommitAction actions = 6;
ObjectSelector start_revision = 7;
bool force = 8;
repeated CommitTrailer trailers = 9;
}
message CreateCommitResponse {
Commit commit = 1;
string branch = 2;
}
message RevertCommitRequest {
RepositoryHeader repository = 1;
ObjectSelector commit = 2;
string branch = 3;
Signature committer = 4;
string message = 5;
}
message CherryPickCommitRequest {
RepositoryHeader repository = 1;
ObjectSelector commit = 2;
string branch = 3;
Signature committer = 4;
string message = 5;
uint32 mainline = 6;
}
message CompareCommitsRequest {
RepositoryHeader repository = 1;
ObjectSelector base = 2;
ObjectSelector head = 3;
bool straight = 4;
bool first_parent = 5;
Pagination pagination = 6;
}
message CompareCommitsResponse {
repeated Commit commits = 1;
CommitStats stats = 2;
PageInfo page_info = 3;
Oid merge_base = 4;
}
service CommitService {
rpc ListCommits(ListCommitsRequest) returns (ListCommitsResponse);
rpc GetCommit(GetCommitRequest) returns (Commit);
rpc GetCommitAncestors(GetCommitAncestorsRequest) returns (GetCommitAncestorsResponse);
rpc CreateCommit(CreateCommitRequest) returns (CreateCommitResponse);
rpc RevertCommit(RevertCommitRequest) returns (CreateCommitResponse);
rpc CherryPickCommit(CherryPickCommitRequest) returns (CreateCommitResponse);
rpc CompareCommits(CompareCommitsRequest) returns (CompareCommitsResponse);
}
+140
View File
@@ -0,0 +1,140 @@
syntax = "proto3";
package gitks;
import "oid.proto";
import "repository.proto";
message DiffOptions {
enum WhitespaceMode {
DIFF_WHITESPACE_MODE_UNSPECIFIED = 0;
DIFF_WHITESPACE_MODE_DEFAULT = 1;
DIFF_WHITESPACE_MODE_IGNORE_ALL = 2;
DIFF_WHITESPACE_MODE_IGNORE_CHANGE = 3;
DIFF_WHITESPACE_MODE_IGNORE_EOL = 4;
}
bool recursive = 1;
bool include_binary = 2;
bool include_patch = 3;
bool rename_detection = 4;
bool copy_detection = 5;
uint32 context_lines = 6;
repeated string pathspec = 7;
WhitespaceMode whitespace_mode = 8;
uint64 max_files = 9;
uint64 max_bytes = 10;
}
message DiffLine {
enum LineType {
DIFF_LINE_TYPE_UNSPECIFIED = 0;
DIFF_LINE_TYPE_CONTEXT = 1;
DIFF_LINE_TYPE_ADDED = 2;
DIFF_LINE_TYPE_DELETED = 3;
DIFF_LINE_TYPE_HUNK_HEADER = 4;
DIFF_LINE_TYPE_NO_NEWLINE = 5;
}
LineType type = 1;
int32 old_line = 2;
int32 new_line = 3;
bytes content = 4;
bool truncated = 5;
}
message DiffHunk {
string header = 1;
uint32 old_start = 2;
uint32 old_lines = 3;
uint32 new_start = 4;
uint32 new_lines = 5;
repeated DiffLine lines = 6;
}
message DiffFile {
enum ChangeType {
DIFF_FILE_CHANGE_TYPE_UNSPECIFIED = 0;
DIFF_FILE_CHANGE_TYPE_ADDED = 1;
DIFF_FILE_CHANGE_TYPE_MODIFIED = 2;
DIFF_FILE_CHANGE_TYPE_DELETED = 3;
DIFF_FILE_CHANGE_TYPE_RENAMED = 4;
DIFF_FILE_CHANGE_TYPE_COPIED = 5;
DIFF_FILE_CHANGE_TYPE_TYPE_CHANGED = 6;
DIFF_FILE_CHANGE_TYPE_UNMERGED = 7;
}
string old_path = 1;
string new_path = 2;
Oid old_oid = 3;
Oid new_oid = 4;
uint32 old_mode = 5;
uint32 new_mode = 6;
ChangeType change_type = 7;
bool binary = 8;
bool too_large = 9;
uint32 additions = 10;
uint32 deletions = 11;
repeated DiffHunk hunks = 12;
bytes patch = 13;
double similarity = 14;
}
message DiffStats {
uint32 additions = 1;
uint32 deletions = 2;
uint32 changed_files = 3;
}
message Diff {
repeated DiffFile files = 1;
DiffStats stats = 2;
bool overflow = 3;
}
message GetDiffRequest {
RepositoryHeader repository = 1;
ObjectSelector base = 2;
ObjectSelector head = 3;
DiffOptions options = 4;
Pagination pagination = 5;
}
message GetDiffResponse {
repeated DiffFile files = 1;
DiffStats stats = 2;
PageInfo page_info = 3;
bool overflow = 4;
}
message GetCommitDiffRequest {
RepositoryHeader repository = 1;
ObjectSelector commit = 2;
DiffOptions options = 3;
Pagination pagination = 4;
}
message GetPatchRequest {
RepositoryHeader repository = 1;
ObjectSelector base = 2;
ObjectSelector head = 3;
DiffOptions options = 4;
}
message GetPatchResponse {
bytes data = 1;
}
message GetDiffStatsRequest {
RepositoryHeader repository = 1;
ObjectSelector base = 2;
ObjectSelector head = 3;
DiffOptions options = 4;
}
service DiffService {
rpc GetDiff(GetDiffRequest) returns (GetDiffResponse);
rpc GetCommitDiff(GetCommitDiffRequest) returns (GetDiffResponse);
rpc GetPatch(GetPatchRequest) returns (stream GetPatchResponse);
rpc GetDiffStats(GetDiffStatsRequest) returns (DiffStats);
}
+139
View File
@@ -0,0 +1,139 @@
syntax = "proto3";
package gitks;
import "commit.proto";
import "diff.proto";
import "oid.proto";
import "repository.proto";
import "tagger.proto";
message MergeOptions {
enum Strategy {
MERGE_STRATEGY_UNSPECIFIED = 0;
MERGE_STRATEGY_RECURSIVE = 1;
MERGE_STRATEGY_ORT = 2;
MERGE_STRATEGY_RESOLVE = 3;
MERGE_STRATEGY_OCTOPUS = 4;
MERGE_STRATEGY_OURS = 5;
MERGE_STRATEGY_SUBTREE = 6;
}
enum FastForwardMode {
MERGE_FAST_FORWARD_MODE_UNSPECIFIED = 0;
MERGE_FAST_FORWARD_MODE_ALLOWED = 1;
MERGE_FAST_FORWARD_MODE_ONLY = 2;
MERGE_FAST_FORWARD_MODE_NO_FF = 3;
}
Strategy strategy = 1;
FastForwardMode fast_forward = 2;
bool squash = 3;
bool no_commit = 4;
bool allow_unrelated_histories = 5;
repeated string strategy_options = 6;
}
message MergeConflictSection {
string label = 1;
bytes content = 2;
}
message MergeConflict {
string path = 1;
uint32 mode = 2;
Oid base_oid = 3;
Oid ours_oid = 4;
Oid theirs_oid = 5;
repeated MergeConflictSection sections = 6;
bool binary = 7;
}
message MergeResult {
enum Status {
MERGE_RESULT_STATUS_UNSPECIFIED = 0;
MERGE_RESULT_STATUS_MERGED = 1;
MERGE_RESULT_STATUS_FAST_FORWARD = 2;
MERGE_RESULT_STATUS_ALREADY_UP_TO_DATE = 3;
MERGE_RESULT_STATUS_CONFLICTS = 4;
MERGE_RESULT_STATUS_ABORTED = 5;
}
Status status = 1;
Commit commit = 2;
Oid merge_base = 3;
repeated MergeConflict conflicts = 4;
DiffStats stats = 5;
string message = 6;
}
message MergeRequest {
RepositoryHeader repository = 1;
string target_branch = 2;
ObjectSelector source = 3;
Signature committer = 4;
string message = 5;
MergeOptions options = 6;
}
message CheckMergeRequest {
RepositoryHeader repository = 1;
ObjectSelector target = 2;
ObjectSelector source = 3;
MergeOptions options = 4;
}
message ListMergeConflictsRequest {
RepositoryHeader repository = 1;
ObjectSelector target = 2;
ObjectSelector source = 3;
Pagination pagination = 4;
}
message ListMergeConflictsResponse {
repeated MergeConflict conflicts = 1;
PageInfo page_info = 2;
}
message ResolveMergeConflict {
string path = 1;
bytes content = 2;
}
message ResolveMergeConflictsRequest {
RepositoryHeader repository = 1;
string target_branch = 2;
ObjectSelector source = 3;
repeated ResolveMergeConflict resolutions = 4;
Signature committer = 5;
string message = 6;
}
message RebaseRequest {
RepositoryHeader repository = 1;
string branch = 2;
ObjectSelector upstream = 3;
Signature committer = 4;
}
message RebaseResult {
enum Status {
REBASE_RESULT_STATUS_UNSPECIFIED = 0;
REBASE_RESULT_STATUS_REBASED = 1;
REBASE_RESULT_STATUS_ALREADY_UP_TO_DATE = 2;
REBASE_RESULT_STATUS_CONFLICTS = 3;
REBASE_RESULT_STATUS_ABORTED = 4;
}
Status status = 1;
Commit head = 2;
repeated MergeConflict conflicts = 3;
}
service MergeService {
rpc CheckMerge(CheckMergeRequest) returns (MergeResult);
rpc Merge(MergeRequest) returns (MergeResult);
rpc ListMergeConflicts(ListMergeConflictsRequest) returns (ListMergeConflictsResponse);
rpc ResolveMergeConflicts(ResolveMergeConflictsRequest) returns (MergeResult);
rpc Rebase(RebaseRequest) returns (RebaseResult);
}
+64
View File
@@ -0,0 +1,64 @@
syntax = "proto3";
package gitks;
// Git object hash algorithm. GitHub and Gitaly both need to support SHA-1 today
// and SHA-256 repositories as they become more common.
enum ObjectFormat {
OBJECT_FORMAT_UNSPECIFIED = 0;
OBJECT_FORMAT_SHA1 = 1;
OBJECT_FORMAT_SHA256 = 2;
}
// Git object kind.
enum ObjectType {
OBJECT_TYPE_UNSPECIFIED = 0;
OBJECT_TYPE_COMMIT = 1;
OBJECT_TYPE_TREE = 2;
OBJECT_TYPE_BLOB = 3;
OBJECT_TYPE_TAG = 4;
}
// Canonical object id. `value` preserves the original binary representation used
// by the existing API; `hex` is the normalized lowercase hex form for clients.
message Oid {
bytes value = 1;
string hex = 2;
ObjectFormat format = 3;
}
message ObjectName {
// Revision expression, refname, oid hex, or pseudo-ref such as HEAD.
string revision = 1;
}
message ObjectSelector {
oneof selector {
Oid oid = 1;
ObjectName revision = 2;
}
}
message ObjectIdentity {
Oid oid = 1;
ObjectType type = 2;
int64 size = 3;
string abbreviated_oid = 4;
}
message Pagination {
uint32 page_size = 1;
string page_token = 2;
}
message PageInfo {
string next_page_token = 1;
bool has_next_page = 2;
uint64 total_count = 3;
}
enum SortDirection {
SORT_DIRECTION_UNSPECIFIED = 0;
SORT_DIRECTION_ASC = 1;
SORT_DIRECTION_DESC = 2;
}
+134
View File
@@ -0,0 +1,134 @@
syntax = "proto3";
package gitks;
import "oid.proto";
import "repository.proto";
message GitProtocolFeatures {
uint32 version = 1;
repeated string capabilities = 2;
repeated string server_options = 3;
repeated string agent = 4;
}
message ReferenceAdvertisement {
string name = 1;
Oid target_oid = 2;
Oid peeled_oid = 3;
bool symbolic = 4;
string symbolic_target = 5;
}
message AdvertiseRefsRequest {
RepositoryHeader repository = 1;
GitProtocolFeatures protocol = 2;
string service = 3;
}
message AdvertiseRefsResponse {
repeated ReferenceAdvertisement references = 1;
repeated string capabilities = 2;
}
message UploadPackRequest {
RepositoryHeader repository = 1;
GitProtocolFeatures protocol = 2;
bytes packet = 3;
bool done = 4;
}
message UploadPackResponse {
bytes packet = 1;
string stderr = 2;
}
message ReceivePackRequest {
RepositoryHeader repository = 1;
GitProtocolFeatures protocol = 2;
bytes packet = 3;
bool done = 4;
}
message ReceivePackResponse {
bytes packet = 1;
string stderr = 2;
}
message PackObjectsOptions {
repeated Oid wants = 1;
repeated Oid haves = 2;
repeated string shallow_revisions = 3;
uint32 deepen = 4;
bool thin_pack = 5;
bool include_tag = 6;
bool use_bitmaps = 7;
bool delta_base_offset = 8;
repeated string pathspec = 9;
}
message PackObjectsRequest {
RepositoryHeader repository = 1;
PackObjectsOptions options = 2;
}
message PackfileChunk {
bytes data = 1;
}
message IndexPackRequest {
RepositoryHeader repository = 1;
bytes data = 2;
bool done = 3;
bool keep = 4;
bool strict = 5;
}
message IndexPackResponse {
Oid pack_hash = 1;
uint64 object_count = 2;
string stderr = 3;
}
message ListPackfilesRequest {
RepositoryHeader repository = 1;
Pagination pagination = 2;
}
message PackfileInfo {
string name = 1;
Oid pack_hash = 2;
uint64 size_bytes = 3;
uint64 index_size_bytes = 4;
uint64 object_count = 5;
bool has_bitmap = 6;
bool has_rev_index = 7;
bool kept = 8;
}
message ListPackfilesResponse {
repeated PackfileInfo packfiles = 1;
PageInfo page_info = 2;
}
message FsckRequest {
RepositoryHeader repository = 1;
bool strict = 2;
bool connectivity_only = 3;
}
message FsckResponse {
bool ok = 1;
repeated string errors = 2;
repeated string warnings = 3;
}
service PackService {
rpc AdvertiseRefs(AdvertiseRefsRequest) returns (AdvertiseRefsResponse);
rpc UploadPack(stream UploadPackRequest) returns (stream UploadPackResponse);
rpc ReceivePack(stream ReceivePackRequest) returns (stream ReceivePackResponse);
rpc PackObjects(PackObjectsRequest) returns (stream PackfileChunk);
rpc IndexPack(stream IndexPackRequest) returns (IndexPackResponse);
rpc ListPackfiles(ListPackfilesRequest) returns (ListPackfilesResponse);
rpc Fsck(FsckRequest) returns (FsckResponse);
}
+157
View File
@@ -0,0 +1,157 @@
syntax = "proto3";
package gitks;
import "google/protobuf/empty.proto";
import "oid.proto";
// Repository identity used by storage-facing RPCs.
message RepositoryHeader {
// Logical storage shard or disk name.
string storage_name = 1;
// Path relative to the storage root, usually ending in `.git` for bare repos.
string relative_path = 2;
// Optional absolute path for embedded/local deployments.
string storage_path = 3;
}
message Repository {
RepositoryHeader header = 1;
bool bare = 2;
bool empty = 3;
ObjectFormat object_format = 4;
string default_branch = 5;
string git_object_directory = 6;
repeated string git_alternate_object_directories = 7;
}
message RepositoryStatistics {
uint64 size_bytes = 1;
uint64 loose_object_count = 2;
uint64 packed_object_count = 3;
uint64 packfile_count = 4;
uint64 reference_count = 5;
uint64 commit_graph_size_bytes = 6;
uint64 multi_pack_index_size_bytes = 7;
}
message RepositoryConfigEntry {
string key = 1;
repeated string values = 2;
}
message RepositoryObjectFormatRequest {
RepositoryHeader repository = 1;
}
message RepositoryObjectFormatResponse {
ObjectFormat object_format = 1;
}
message GetRepositoryRequest {
RepositoryHeader repository = 1;
}
message InitRepositoryRequest {
RepositoryHeader repository = 1;
bool bare = 2;
ObjectFormat object_format = 3;
string initial_branch = 4;
}
message DeleteRepositoryRequest {
RepositoryHeader repository = 1;
}
message RepositoryExistsRequest {
RepositoryHeader repository = 1;
}
message RepositoryExistsResponse {
bool exists = 1;
}
message GetDefaultBranchRequest {
RepositoryHeader repository = 1;
}
message GetDefaultBranchResponse {
string name = 1;
}
message SetDefaultBranchRequest {
RepositoryHeader repository = 1;
string name = 2;
}
message GetRepositoryConfigRequest {
RepositoryHeader repository = 1;
repeated string keys = 2;
}
message GetRepositoryConfigResponse {
repeated RepositoryConfigEntry entries = 1;
}
message SetRepositoryConfigRequest {
RepositoryHeader repository = 1;
repeated RepositoryConfigEntry entries = 2;
}
message RepositoryStatisticsRequest {
RepositoryHeader repository = 1;
}
message RepositoryHealthRequest {
RepositoryHeader repository = 1;
bool connectivity_only = 2;
}
message RepositoryHealthResponse {
bool ok = 1;
repeated string warnings = 2;
repeated string errors = 3;
RepositoryStatistics statistics = 4;
}
message GarbageCollectRequest {
RepositoryHeader repository = 1;
bool prune = 2;
bool aggressive = 3;
}
message RepackRequest {
RepositoryHeader repository = 1;
bool full = 2;
bool write_bitmaps = 3;
bool write_multi_pack_index = 4;
}
message WriteCommitGraphRequest {
RepositoryHeader repository = 1;
bool replace = 2;
bool split = 3;
}
message RepositoryMaintenanceResponse {
bool ok = 1;
string stdout = 2;
string stderr = 3;
}
service RepositoryService {
rpc GetRepository(GetRepositoryRequest) returns (Repository);
rpc InitRepository(InitRepositoryRequest) returns (Repository);
rpc DeleteRepository(DeleteRepositoryRequest) returns (google.protobuf.Empty);
rpc RepositoryExists(RepositoryExistsRequest) returns (RepositoryExistsResponse);
rpc GetObjectFormat(RepositoryObjectFormatRequest) returns (RepositoryObjectFormatResponse);
rpc GetDefaultBranch(GetDefaultBranchRequest) returns (GetDefaultBranchResponse);
rpc SetDefaultBranch(SetDefaultBranchRequest) returns (google.protobuf.Empty);
rpc GetRepositoryConfig(GetRepositoryConfigRequest) returns (GetRepositoryConfigResponse);
rpc SetRepositoryConfig(SetRepositoryConfigRequest) returns (google.protobuf.Empty);
rpc GetRepositoryStatistics(RepositoryStatisticsRequest) returns (RepositoryStatistics);
rpc CheckRepositoryHealth(RepositoryHealthRequest) returns (RepositoryHealthResponse);
rpc GarbageCollect(GarbageCollectRequest) returns (RepositoryMaintenanceResponse);
rpc Repack(RepackRequest) returns (RepositoryMaintenanceResponse);
rpc WriteCommitGraph(WriteCommitGraphRequest) returns (RepositoryMaintenanceResponse);
}
+67
View File
@@ -0,0 +1,67 @@
syntax = "proto3";
package gitks;
import "google/protobuf/empty.proto";
import "oid.proto";
import "repository.proto";
import "tagger.proto";
message Tag {
string name = 1;
string full_ref = 2;
Oid target_oid = 3;
ObjectType target_type = 4;
Oid tag_oid = 5;
bool annotated = 6;
Signature tagger = 7;
string message = 8;
VerifiedSignature signature = 9;
bytes raw = 10;
}
message ListTagsRequest {
RepositoryHeader repository = 1;
string pattern = 2;
Pagination pagination = 3;
SortDirection sort_direction = 4;
}
message ListTagsResponse {
repeated Tag tags = 1;
PageInfo page_info = 2;
}
message GetTagRequest {
RepositoryHeader repository = 1;
string name = 2;
bool include_raw = 3;
}
message CreateTagRequest {
RepositoryHeader repository = 1;
string name = 2;
ObjectSelector target = 3;
string message = 4;
Signature tagger = 5;
bool force = 6;
bool annotated = 7;
}
message DeleteTagRequest {
RepositoryHeader repository = 1;
string name = 2;
}
message VerifyTagRequest {
RepositoryHeader repository = 1;
string name = 2;
}
service TagService {
rpc ListTags(ListTagsRequest) returns (ListTagsResponse);
rpc GetTag(GetTagRequest) returns (Tag);
rpc CreateTag(CreateTagRequest) returns (Tag);
rpc DeleteTag(DeleteTagRequest) returns (google.protobuf.Empty);
rpc VerifyTag(VerifyTagRequest) returns (VerifiedSignature);
}
+51
View File
@@ -0,0 +1,51 @@
syntax = "proto3";
package gitks;
import "google/protobuf/timestamp.proto";
// Git identity attached to commits and tags.
message Identity {
string name = 1;
string email = 2;
}
// Git signature with timestamp and timezone offset.
message Signature {
Identity identity = 1;
google.protobuf.Timestamp when = 2;
// Offset in minutes east of UTC, as stored by git.
int32 timezone_offset = 3;
}
// Backward-compatible payload name used by earlier Rust structs.
message PayloadTagger {
string email = 1;
string name = 2;
}
message VerifiedSignature {
enum Reason {
REASON_UNSPECIFIED = 0;
REASON_VALID = 1;
REASON_EXPIRED_KEY = 2;
REASON_NOT_SIGNING_KEY = 3;
REASON_GPGVERIFY_ERROR = 4;
REASON_GPGVERIFY_UNAVAILABLE = 5;
REASON_UNSIGNED = 6;
REASON_UNKNOWN_SIGNATURE_TYPE = 7;
REASON_NO_USER = 8;
REASON_UNVERIFIED_EMAIL = 9;
REASON_BAD_EMAIL = 10;
REASON_UNKNOWN_KEY = 11;
REASON_MALFORMED_SIGNATURE = 12;
REASON_INVALID = 13;
}
bool verified = 1;
Reason reason = 2;
string signature = 3;
string payload = 4;
string key_fingerprint = 5;
string signer = 6;
}
+118
View File
@@ -0,0 +1,118 @@
syntax = "proto3";
package gitks;
import "oid.proto";
import "repository.proto";
message TreeEntry {
enum EntryType {
TREE_ENTRY_TYPE_UNSPECIFIED = 0;
TREE_ENTRY_TYPE_TREE = 1;
TREE_ENTRY_TYPE_BLOB = 2;
TREE_ENTRY_TYPE_COMMIT = 3;
TREE_ENTRY_TYPE_SYMLINK = 4;
TREE_ENTRY_TYPE_EXECUTABLE = 5;
}
string name = 1;
string path = 2;
Oid oid = 3;
EntryType type = 4;
uint32 mode = 5;
int64 size = 6;
}
message Tree {
Oid oid = 1;
string path = 2;
repeated TreeEntry entries = 3;
bool truncated = 4;
}
message Blob {
Oid oid = 1;
string path = 2;
uint32 mode = 3;
int64 size = 4;
bytes data = 5;
string encoding = 6;
bool binary = 7;
bool truncated = 8;
}
message FileMetadata {
string path = 1;
Oid oid = 2;
uint32 mode = 3;
int64 size = 4;
ObjectType type = 5;
bool binary = 6;
}
message ListTreeRequest {
RepositoryHeader repository = 1;
ObjectSelector revision = 2;
string path = 3;
bool recursive = 4;
Pagination pagination = 5;
}
message ListTreeResponse {
repeated TreeEntry entries = 1;
PageInfo page_info = 2;
bool truncated = 3;
}
message GetTreeRequest {
RepositoryHeader repository = 1;
ObjectSelector revision = 2;
string path = 3;
}
message GetBlobRequest {
RepositoryHeader repository = 1;
ObjectSelector revision = 2;
string path = 3;
Oid oid = 4;
uint64 max_bytes = 5;
}
message GetRawBlobRequest {
RepositoryHeader repository = 1;
ObjectSelector revision = 2;
string path = 3;
Oid oid = 4;
}
message GetRawBlobResponse {
bytes data = 1;
}
message GetFileMetadataRequest {
RepositoryHeader repository = 1;
ObjectSelector revision = 2;
string path = 3;
}
message FindFilesRequest {
RepositoryHeader repository = 1;
ObjectSelector revision = 2;
string pattern = 3;
repeated string pathspec = 4;
Pagination pagination = 5;
}
message FindFilesResponse {
repeated FileMetadata files = 1;
PageInfo page_info = 2;
}
service TreeService {
rpc ListTree(ListTreeRequest) returns (ListTreeResponse);
rpc GetTree(GetTreeRequest) returns (Tree);
rpc GetBlob(GetBlobRequest) returns (Blob);
rpc GetRawBlob(GetRawBlobRequest) returns (stream GetRawBlobResponse);
rpc GetFileMetadata(GetFileMetadataRequest) returns (FileMetadata);
rpc FindFiles(FindFilesRequest) returns (FindFilesResponse);
}