syntax = "proto3";

package git.v1;

import "common.proto";

// Mirrors: cmd/commit/mod.rs — CommitMeta
message CommitMeta {
  ObjectId oid = 1;
  string message = 2;
  string summary = 3;
  CommitSignature author = 4;
  CommitSignature committer = 5;
  ObjectId tree_id = 6;
  repeated ObjectId parent_ids = 7;
  optional string encoding = 8;
}

// Mirrors: cmd/commit/mod.rs — CommitRefInfo
message CommitRefInfo {
  string name = 1;
  ObjectId target = 2;
  bool is_remote = 3;
  bool is_tag = 4;
}

// Mirrors: cmd/commit/commit_summary.rs — CommitSummary
message CommitSummary {
  optional CommitMeta head = 1;
  uint64 count = 2;
}

// Mirrors: cmd/commit/commit_walker.rs — CommitWalkSort
enum CommitWalkSort {
  COMMIT_WALK_SORT_NONE = 0;
  COMMIT_WALK_SORT_TOPOLOGICAL = 1;
  COMMIT_WALK_SORT_TIME = 2;
  COMMIT_WALK_SORT_REVERSE = 3;
}

// Mirrors: cmd/commit/commit_walker.rs — CommitWalkParams
message CommitWalkParams {
  repeated ObjectId start_oids = 1;
  repeated ObjectId hide_oids = 2;
  optional uint64 limit = 3;
  uint64 skip = 4;
  bool first_parent = 5;
  CommitWalkSort sort = 6;
}

// Mirrors: cmd/commit/commit_cherry_pick.rs — CommitCherryPickParams
message CommitCherryPickParams {
  ObjectId cherrypick_oid = 1;
  CommitSignature author = 2;
  CommitSignature committer = 3;
  optional string message = 4;
  uint32 mainline = 5;
  optional string update_ref = 6;
}

// Mirrors: cmd/commit/commit_cherry_pick.rs — CommitCherryPickSequence
message CommitCherryPickSequence {
  repeated ObjectId cherrypick_oids = 1;
  CommitSignature author = 2;
  CommitSignature committer = 3;
  optional string update_ref = 4;
}

message CommitInfoRequest {
  string repo_id = 1;
  ObjectId oid = 2;
}

message CommitInfoResponse {
  CommitMeta commit = 1;
}

message CommitHistoryRequest {
  string repo_id = 1;
  uint64 limit = 2;
  uint64 skip = 3;
  CommitWalkSort sort = 4;
  optional string branch = 5;
}

message CommitHistoryResponse {
  repeated CommitMeta commits = 1;
}

message CommitSummaryRequest {
  string repo_id = 1;
}

message CommitSummaryResponse {
  CommitSummary summary = 1;
}

message CommitWalkRequest {
  string repo_id = 1;
  CommitWalkParams params = 2;
}

message CommitWalkResponse {
  repeated CommitMeta commits = 1;
}

message CommitRefsRequest {
  string repo_id = 1;
}

message CommitRefsResponse {
  repeated CommitRefInfo refs = 1;
}

message CommitPrefixRequest {
  string repo_id = 1;
  string prefix = 2;
}

message CommitPrefixResponse {
  ObjectId oid = 1;
}

message CommitExistsRequest {
  string repo_id = 1;
  ObjectId oid = 2;
}

message CommitExistsResponse {
  bool exists = 1;
}

message CherryPickRequest {
  string repo_id = 1;
  CommitCherryPickParams params = 2;
}

message CherryPickResponse {
  ObjectId oid = 1;
}

message CherryPickSequenceRequest {
  string repo_id = 1;
  CommitCherryPickSequence params = 2;
}

message CherryPickSequenceResponse {
  ObjectId oid = 1;
}

message FileChange {
  string path = 1;
  bytes content = 2;
}

message CreateCommitRequest {
  string repo_id = 1;
  string branch = 2;
  string message = 3;
  string author_name = 4;
  string author_email = 5;
  string committer_name = 6;
  string committer_email = 7;
  repeated FileChange files = 8;
}

message CreateCommitResponse {
  ObjectId oid = 1;
}

service CommitService {
  rpc CommitInfo(CommitInfoRequest) returns (CommitInfoResponse);
  rpc CommitHistory(CommitHistoryRequest) returns (CommitHistoryResponse);
  rpc CommitHistoryStream(CommitHistoryRequest) returns (stream CommitMeta);
  rpc CommitSummary(CommitSummaryRequest) returns (CommitSummaryResponse);
  rpc CommitWalk(CommitWalkRequest) returns (CommitWalkResponse);
  rpc CommitRefs(CommitRefsRequest) returns (CommitRefsResponse);
  rpc CommitPrefix(CommitPrefixRequest) returns (CommitPrefixResponse);
  rpc CommitExists(CommitExistsRequest) returns (CommitExistsResponse);
  rpc CherryPick(CherryPickRequest) returns (CherryPickResponse);
  rpc CherryPickSequence(CherryPickSequenceRequest) returns (CherryPickSequenceResponse);
  rpc CreateCommit(CreateCommitRequest) returns (CreateCommitResponse);
}