SSHTransfer returns either an suitable transfer object or nil if the server is not using an SSH remote or the git-lfs-transfer style of SSH remote.
(operation, remote string)
| 53 | // server is not using an SSH remote or the git-lfs-transfer style of SSH |
| 54 | // remote. |
| 55 | func (c *Client) SSHTransfer(operation, remote string) *ssh.SSHTransfer { |
| 56 | if len(operation) == 0 { |
| 57 | return nil |
| 58 | } |
| 59 | endpoint := c.Endpoints.Endpoint(operation, remote) |
| 60 | if len(endpoint.SSHMetadata.UserAndHost) == 0 { |
| 61 | return nil |
| 62 | } |
| 63 | uc := config.NewURLConfig(c.context.GitEnv()) |
| 64 | if val, ok := uc.Get("lfs", endpoint.OriginalUrl, "sshtransfer"); ok && val != "negotiate" && val != "always" { |
| 65 | tracerx.Printf("skipping pure SSH protocol connection by request (%s, %s)", operation, remote) |
| 66 | return nil |
| 67 | } |
| 68 | ctx := c.Context() |
| 69 | tracerx.Printf("attempting pure SSH protocol connection (%s, %s)", operation, remote) |
| 70 | sshTransfer, err := ssh.NewSSHTransfer(ctx.OSEnv(), ctx.GitEnv(), &endpoint.SSHMetadata, operation) |
| 71 | if err != nil { |
| 72 | tracerx.Printf("pure SSH protocol connection failed (%s, %s): %s", operation, remote, err) |
| 73 | return nil |
| 74 | } |
| 75 | return sshTransfer |
| 76 | } |
no test coverage detected