CommitService.RawBlame structured errors
In Gitaly 16.4, this gRPC method gets structured errors, we have to implement them as well:
~/heptapod/gitaly $ git diff c7099d645d162a8760f7f84e9f3e0c45229240c1..e450c7ca1115ddc16b3db84a5400b781ed81e2e6 -- proto/*.proto internal/backup
diff --git a/proto/commit.proto b/proto/commit.proto
index 919ede288..467e1e631 100644
--- a/proto/commit.proto
+++ b/proto/commit.proto
@@ -108,7 +108,8 @@ service CommitService {
};
}
- // This comment is left unintentionally blank.
+ // RawBlame blames lines in a blob to when they have last been changed. Returns the raw output of the git-blame(1)
+ // command.
rpc RawBlame(RawBlameRequest) returns (stream RawBlameResponse) {
option (op_type) = {
op: ACCESSOR
@@ -682,25 +683,43 @@ message CommitLanguagesResponse {
repeated Language languages = 1;
}
-// This comment is left unintentionally blank.
+// RawBlameRequest is a request for the RawBlame RPC.
message RawBlameRequest {
- // This comment is left unintentionally blank.
+ // Repository is the repositroy where to perform the blame.
Repository repository = 1 [(target_repository)=true];
- // This comment is left unintentionally blank.
+ // Revision is the committish at which to start the blame.
bytes revision = 2;
- // This comment is left unintentionally blank.
+ // Path is the path of the blob that should be blamed.
bytes path = 3;
- // Comma-separated range of line numbers to perform the blame on: "1,1000".
- // Optional - if no range is provided, the whole file will be blamed.
+ // Range is the comma-separated range of line numbers to perform the blame on, e.g. "1,1000". Optional - if no range
+ // is provided, the whole file will be blamed.
bytes range = 4;
}
-// This comment is left unintentionally blank.
+// RawBlameResponse is a response for the RawBlame RPC. The response will be chunked into multiple message if the
+// returned data exceeds gRPC message limits.
message RawBlameResponse {
- // This comment is left unintentionally blank.
+ // Data is the raw data as generated by git-blame(1).
bytes data = 1;
}
+// RawBlameError is used as error detail when the RawBlame RPC fails in a specific way.
+message RawBlameError {
+ // OutOfRangeError indicates that the specified file range that is to be blamed exceeds the length of the blamed
+ // file.
+ message OutOfRangeError {
+ // ActualLines contains the actual number of lines that can be blamed in the file.
+ uint64 actual_lines = 1;
+ }
+
+ oneof error {
+ // PathNotFound is returned when the blamed path cannot be found in the revision.
+ PathNotFoundError path_not_found = 1;
+ // OutOfRangeError is returned when the specified blamed range exceeds the file length.
+ OutOfRangeError out_of_range = 2;
+ }
+}
+
// LastCommitForPathRequest is a request for the LastCommitForPath RPC.
message LastCommitForPathRequest {
// Repository is the repository to run the query in.
diff --git a/proto/errors.proto b/proto/errors.proto
index 6697d1883..caaca1995 100644
--- a/proto/errors.proto
+++ b/proto/errors.proto
@@ -199,3 +199,9 @@ message PathError {
// ErrorType is the type of path error that occurred.
ErrorType error_type = 2;
}
+
+// PathNotFoundError is an error returned when a given path cannot be found.
+message PathNotFoundError {
+ // Path is the path that could not be found.
+ bytes path = 1;
+}