syntax = "proto3";

package gitaly;

option go_package = "gitlab.com/gitlab-org/gitaly-proto/go/gitalypb";

import "shared.proto";

service ConflictsService {
  rpc ListConflictFiles(ListConflictFilesRequest) returns (stream ListConflictFilesResponse) {
    option (op_type).op = ACCESSOR;
  }
  rpc ResolveConflicts(stream ResolveConflictsRequest) returns (ResolveConflictsResponse) {
    option (op_type) = {
      op: MUTATOR
      target_repository_field: "1.1"
    };
  }
}

message ListConflictFilesRequest {
  Repository repository = 1;
  string our_commit_oid = 2;
  string their_commit_oid = 3;
}

message ConflictFileHeader {
  Repository repository = 1;
  string commit_oid = 2;
  bytes their_path = 3;
  bytes our_path = 4;
  int32 our_mode = 5;
}

message ConflictFile {
  oneof conflict_file_payload {
    ConflictFileHeader header = 1;
    bytes content = 2;
  }
}

message ListConflictFilesResponse {
  repeated ConflictFile files = 1;
}

message ResolveConflictsRequestHeader {
  Repository repository = 1;
  string our_commit_oid = 2;
  Repository target_repository = 3;
  string their_commit_oid = 4;
  bytes source_branch = 5;
  bytes target_branch = 6;
  bytes commit_message = 7;
  User user = 8;
}

message ResolveConflictsRequest {
  oneof resolve_conflicts_request_payload {
    ResolveConflictsRequestHeader header = 1;
    bytes files_json = 2;
  }
}

message ResolveConflictsResponse {
  string resolution_error = 1;
}
