syntax = "proto3";

package git.v1;

import "common.proto";

// Mirrors: cmd/branch/branch_list.rs — BranchListItem
message BranchListItem {
  string name = 1;
  ObjectId oid = 2;
  bool is_head = 3;
  bool is_remote = 4;
  bool is_current = 5;
  optional string upstream = 6;
}

// Mirrors: cmd/branch/branch_summary.rs — BranchSummary
message BranchSummary {
  uint64 local_count = 1;
  uint64 remote_count = 2;
  uint64 all_count = 3;
}

// Mirrors: cmd/branch/branch_fork.rs — BranchForkParams
message BranchForkParams {
  string name = 1;
  ObjectId oid = 2;
  bool force = 3;
}

// Mirrors: cmd/branch/branch_delete.rs — BranchDeleteParams
message BranchDeleteParams {
  string name = 1;
  bool force = 2;
}

// Mirrors: cmd/branch/branch_rename.rs — BranchReNameParams
message BranchReNameParams {
  string old_branch = 1;
  string new_branch = 2;
  bool force = 3;
}

message BranchListRequest {
  string repo_id = 1;
}

message BranchListResponse {
  repeated BranchListItem branches = 1;
}

message BranchInfoRequest {
  string repo_id = 1;
  string branch = 2;
}

message BranchInfoResponse {
  BranchListItem branch = 1;
}

message BranchSummaryRequest {
  string repo_id = 1;
}

message BranchSummaryResponse {
  BranchSummary summary = 1;
}

message BranchHeadRequest {
  string repo_id = 1;
}

message BranchHeadResponse {
  string head_name = 1;
}

message BranchAheadBehindRequest {
  string repo_id = 1;
  string local_branch = 2;
  string remote_branch = 3;
}

message BranchAheadBehindResponse {
  uint64 ahead = 1;
  uint64 behind = 2;
}

message BranchUpstreamRequest {
  string repo_id = 1;
  string branch = 2;
}

message BranchUpstreamResponse {
  string upstream_name = 1;
}

message BranchForkRequest {
  string repo_id = 1;
  BranchForkParams params = 2;
}

message BranchForkResponse {}

message BranchDeleteRequest {
  string repo_id = 1;
  BranchDeleteParams params = 2;
}

message BranchDeleteResponse {}

message BranchRenameRequest {
  string repo_id = 1;
  BranchReNameParams params = 2;
}

message BranchRenameResponse {}

service BranchService {
  rpc BranchList(BranchListRequest) returns (BranchListResponse);
  rpc BranchInfo(BranchInfoRequest) returns (BranchInfoResponse);
  rpc BranchSummary(BranchSummaryRequest) returns (BranchSummaryResponse);
  rpc BranchHead(BranchHeadRequest) returns (BranchHeadResponse);
  rpc BranchAheadBehind(BranchAheadBehindRequest) returns (BranchAheadBehindResponse);
  rpc BranchUpstream(BranchUpstreamRequest) returns (BranchUpstreamResponse);
  rpc BranchFork(BranchForkRequest) returns (BranchForkResponse);
  rpc BranchDelete(BranchDeleteRequest) returns (BranchDeleteResponse);
  rpc BranchRename(BranchRenameRequest) returns (BranchRenameResponse);
}