Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/client
diff options
context:
space:
mode:
authorsword <ruili@jihulab.com>2023-06-08 12:07:59 +0300
committerrrylee <rrylee1994@gmail.com>2023-06-13 07:52:44 +0300
commit81a79bf943a252ba23faf7078fb57a735f851456 (patch)
tree415a38a2d761ee3ebf3fcee3a2dbc8f3cbb7c5ed /client
parent0cadacd729553ef5760a8a65a931aae1a159ed13 (diff)
fix: suggestions from code review
Diffstat (limited to 'client')
-rw-r--r--client/upload_pack.go45
1 files changed, 40 insertions, 5 deletions
diff --git a/client/upload_pack.go b/client/upload_pack.go
index ad35335f7..65d81746e 100644
--- a/client/upload_pack.go
+++ b/client/upload_pack.go
@@ -41,9 +41,23 @@ func UploadPack(ctx context.Context, conn *grpc.ClientConn, stdin io.Reader, std
}, stdout, stderr)
}
-// UploadPackWithSidechannel proxies an SSH git-upload-pack (git fetch)
+// UploadPackResult wraps ExitCode and PackfileNegotiationStatistics.
+type UploadPackResult struct {
+ ExitCode int32
+ PackfileNegotiationStatistics *gitalypb.PackfileNegotiationStatistics
+}
+
+// UploadPackWithSidechannelWithResult proxies an SSH git-upload-pack (git fetch)
// session to Gitaly using a sidechannel for the raw data transfer.
-func UploadPackWithSidechannel(ctx context.Context, conn *grpc.ClientConn, reg *SidechannelRegistry, stdin io.Reader, stdout, stderr io.Writer, req *gitalypb.SSHUploadPackWithSidechannelRequest) (*gitalypb.SSHUploadPackWithSidechannelResponse, int32, error) {
+func UploadPackWithSidechannelWithResult(
+ ctx context.Context,
+ conn *grpc.ClientConn,
+ reg *SidechannelRegistry,
+ stdin io.Reader,
+ stdout, stderr io.Writer,
+ req *gitalypb.SSHUploadPackWithSidechannelRequest,
+) (UploadPackResult, error) {
+ result := UploadPackResult{}
ctx, cancel := context.WithCancel(ctx)
defer cancel()
@@ -58,12 +72,33 @@ func UploadPackWithSidechannel(ctx context.Context, conn *grpc.ClientConn, reg *
sshClient := gitalypb.NewSSHServiceClient(conn)
resp, err := sshClient.SSHUploadPackWithSidechannel(ctx, req)
if err != nil {
- return nil, 0, err
+ return result, err
}
+ result.ExitCode = 0
+ result.PackfileNegotiationStatistics = resp.PackfileNegotiationStatistics
if err := wt.Close(); err != nil {
- return nil, 0, err
+ return result, err
+ }
+
+ return result, nil
+}
+
+// UploadPackWithSidechannel proxies an SSH git-upload-pack (git fetch)
+// session to Gitaly using a sidechannel for the raw data transfer.
+// Deprecated: use UploadPackWithSidechannelWithResult instead.
+func UploadPackWithSidechannel(
+ ctx context.Context,
+ conn *grpc.ClientConn,
+ reg *SidechannelRegistry,
+ stdin io.Reader,
+ stdout, stderr io.Writer,
+ req *gitalypb.SSHUploadPackWithSidechannelRequest,
+) (int32, error) {
+ result, err := UploadPackWithSidechannelWithResult(ctx, conn, reg, stdin, stdout, stderr, req)
+ if err != nil {
+ return 0, err
}
- return resp, 0, nil
+ return result.ExitCode, err
}