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
+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);
}