syntax = "proto3";

package git.v1;

import "common.proto";

// Mirrors: cmd/tree/mod.rs — TreeKind
enum TreeKind {
  TREE_KIND_BLOB = 0;
  TREE_KIND_TREE = 1;
  TREE_KIND_LFS_POINTER = 2;
}

// Mirrors: cmd/tree/mod.rs — TreeInfo
message TreeInfo {
  ObjectId oid = 1;
  uint64 entry_count = 2;
  bool is_empty = 3;
}

// Mirrors: cmd/tree/mod.rs — TreeEntry
message TreeEntry {
  string name = 1;
  ObjectId oid = 2;
  TreeKind kind = 3;
  uint32 filemode = 4;
  bool is_binary = 5;
  bool is_lfs = 6;
  string last_commit_message = 7;
  string last_commit_time = 8;
  string last_commit_author_name = 9;
  string last_commit_author_email = 10;
}

message TreeEntriesRequest {
  string repo_id = 1;
  ObjectId oid = 2;
  string base_path = 3;
  bool last = 4;
}

message TreeEntriesResponse {
  repeated TreeEntry entries = 1;
}

message TreeEntryByPathRequest {
  string repo_id = 1;
  ObjectId tree_oid = 2;
  string path = 3;
}

message TreeEntryByPathResponse {
  optional TreeEntry entry = 1;
}

message TreeEntryByPathFromCommitRequest {
  string repo_id = 1;
  ObjectId commit_oid = 2;
  string path = 3;
}

message TreeEntryByPathFromCommitResponse {
  optional TreeEntry entry = 1;
}

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

message ResolveTreeResponse {
  TreeInfo info = 1;
}

service TreeService {
  rpc TreeEntries(TreeEntriesRequest) returns (TreeEntriesResponse);
  rpc TreeEntryByPath(TreeEntryByPathRequest) returns (TreeEntryByPathResponse);
  rpc TreeEntryByPathFromCommit(TreeEntryByPathFromCommitRequest) returns (TreeEntryByPathFromCommitResponse);
  rpc ResolveTree(ResolveTreeRequest) returns (ResolveTreeResponse);
}