feat(api): extend commit and diff services with new functionality

- Add FindCommit, ListCommitsByOid, CommitIsAncestor RPCs to CommitService
- Add CheckObjectsExist, CommitsByMessage, GetCommitStats RPCs to CommitService
- Add LastCommitForPath, CountCommits, CountDivergingCommits RPCs to CommitService
- Add RawDiff, RawPatch, FindChangedPaths RPCs to DiffService
- Add FindMergeBase, WriteRef, SearchFilesByContent RPCs to RepositoryService
- Add SearchFilesByName, ObjectsSize, RepositorySize RPCs to RepositoryService
- Add FindLicense, OptimizeRepository, GetRawChanges RPCs to RepositoryService
- Add FetchRemote, CreateRepositoryFromURL RPCs to RepositoryService
- Implement server handlers for all new RPC methods
- Add new modules for commit counting, finding, and querying features
- Add new modules for diff changed paths and raw operations
- Add new modules for refs and remote operations
- Remove unnecessary comments from various source files
- Update proto definitions with new message types and service methods
This commit is contained in:
zhenyi
2026-06-08 15:37:08 +08:00
parent 8f472a0443
commit 66afd932ed
43 changed files with 3070 additions and 75 deletions
+107
View File
@@ -154,6 +154,102 @@ message CompareCommitsResponse {
Oid merge_base = 4;
}
message FindCommitRequest {
RepositoryHeader repository = 1;
ObjectSelector revision = 2;
bool include_stats = 3;
}
message ListCommitsByOidRequest {
RepositoryHeader repository = 1;
repeated bytes oids = 2; // binary OID values
bool include_stats = 3;
}
message ListCommitsByOidResponse {
repeated Commit commits = 1;
}
message CommitIsAncestorRequest {
RepositoryHeader repository = 1;
string ancestor_oid = 2;
string descendant_oid = 3;
}
message CommitIsAncestorResponse {
bool is_ancestor = 1;
}
message CheckObjectsExistRequest {
RepositoryHeader repository = 1;
repeated string revisions = 2; // hex OIDs or rev expressions
}
message RevisionExistence {
string revision = 1;
bool exists = 2;
}
message CheckObjectsExistResponse {
repeated RevisionExistence revisions = 1;
}
message CommitsByMessageRequest {
RepositoryHeader repository = 1;
string query = 2; // regex or literal to search in commit messages
string revision = 3; // limit to this branch/ref (empty = all branches)
uint32 limit = 4;
uint32 offset = 5;
bool case_insensitive = 6;
}
message CommitsByMessageResponse {
repeated Commit commits = 1;
}
message GetCommitStatsRequest {
RepositoryHeader repository = 1;
ObjectSelector revision = 2;
}
message LastCommitForPathRequest {
RepositoryHeader repository = 1;
string path = 2;
string revision = 3; // limit history to this ref
bool literal_pathspec = 4;
}
message LastCommitForPathResponse {
Commit commit = 1;
string path = 2;
}
message CountCommitsRequest {
RepositoryHeader repository = 1;
string revision = 2;
string path = 3;
string since = 4; // ISO 8601 date
string until = 5;
}
message CountCommitsResponse {
uint64 count = 1;
}
message CountDivergingCommitsRequest {
RepositoryHeader repository = 1;
string left = 2;
string right = 3;
}
message CountDivergingCommitsResponse {
uint64 left_count = 1;
uint64 right_count = 2;
}
service CommitService {
rpc ListCommits(ListCommitsRequest) returns (ListCommitsResponse);
rpc GetCommit(GetCommitRequest) returns (Commit);
@@ -162,4 +258,15 @@ service CommitService {
rpc RevertCommit(RevertCommitRequest) returns (CreateCommitResponse);
rpc CherryPickCommit(CherryPickCommitRequest) returns (CreateCommitResponse);
rpc CompareCommits(CompareCommitsRequest) returns (CompareCommitsResponse);
rpc FindCommit(FindCommitRequest) returns (Commit);
rpc ListCommitsByOid(ListCommitsByOidRequest) returns (ListCommitsByOidResponse);
rpc CommitIsAncestor(CommitIsAncestorRequest) returns (CommitIsAncestorResponse);
rpc CheckObjectsExist(CheckObjectsExistRequest) returns (CheckObjectsExistResponse);
rpc CommitsByMessage(CommitsByMessageRequest) returns (CommitsByMessageResponse);
rpc GetCommitStats(GetCommitStatsRequest) returns (CommitStats);
rpc LastCommitForPath(LastCommitForPathRequest) returns (LastCommitForPathResponse);
rpc CountCommits(CountCommitsRequest) returns (CountCommitsResponse);
rpc CountDivergingCommits(CountDivergingCommitsRequest) returns (CountDivergingCommitsResponse);
}